Qt 4.8
qaudiooutput_win32_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtMultimedia module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 //
43 // W A R N I N G
44 // -------------
45 //
46 // This file is not part of the Qt API. It exists for the convenience
47 // of other Qt classes. This header file may change from version to
48 // version without notice, or even be removed.
49 //
50 // We mean it.
51 //
52 
53 #ifndef QAUDIOOUTPUTWIN_H
54 #define QAUDIOOUTPUTWIN_H
55 
56 #include <windows.h>
57 #include <mmsystem.h>
58 
59 #include <QtCore/qdebug.h>
60 #include <QtCore/qtimer.h>
61 #include <QtCore/qstring.h>
62 #include <QtCore/qstringlist.h>
63 #include <QtCore/qdatetime.h>
64 #include <QtCore/qmutex.h>
65 
66 #include <QtMultimedia/qaudio.h>
67 #include <QtMultimedia/qaudiodeviceinfo.h>
68 #include <QtMultimedia/qaudioengine.h>
69 
70 
72 
74 {
75  Q_OBJECT
76 public:
79 
80  qint64 write( const char *data, qint64 len );
81 
82  QAudioFormat format() const;
83  QIODevice* start(QIODevice* device = 0);
84  void stop();
85  void reset();
86  void suspend();
87  void resume();
88  int bytesFree() const;
89  int periodSize() const;
90  void setBufferSize(int value);
91  int bufferSize() const;
92  void setNotifyInterval(int milliSeconds);
93  int notifyInterval() const;
94  qint64 processedUSecs() const;
95  qint64 elapsedUSecs() const;
96  QAudio::Error error() const;
97  QAudio::State state() const;
98 
103 
104 private slots:
105  void feedback();
106  bool deviceReady();
107 
108 private:
110  bool resuming;
111  int bytesAvailable;
118  bool pullMode;
119  int intervalTime;
120  static void QT_WIN_CALLBACK waveOutProc( HWAVEOUT hWaveOut, UINT uMsg,
121  DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2 );
122 
123  QMutex mutex;
124 
125  WAVEHDR* allocateBlocks(int size, int count);
126  void freeBlocks(WAVEHDR* blockArray);
127  bool open();
128  void close();
129 
130  WAVEFORMATEX wfx;
131  HWAVEOUT hWaveOut;
132  MMRESULT result;
133  WAVEHDR header;
134  WAVEHDR* waveBlocks;
135  volatile bool finished;
136  volatile int waveFreeBlockCount;
138  char* audioBuffer;
139 };
140 
141 class OutputPrivate : public QIODevice
142 {
143  Q_OBJECT
144 public:
146  ~OutputPrivate();
147 
148  qint64 readData( char* data, qint64 len);
149  qint64 writeData(const char* data, qint64 len);
150 
151 private:
152  QAudioOutputPrivate *audioDevice;
153 };
154 
156 
157 #endif
static void QT_WIN_CALLBACK waveOutProc(HWAVEOUT hWaveOut, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
WAVEHDR * allocateBlocks(int size, int count)
qint64 write(const char *data, qint64 len)
Error
Definition: qaudio.h:58
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int qint32
Definition: qglobal.h:937
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
QAudio::State state() const
Returns the state of audio processing.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void resume()
Resumes processing audio data after a suspend()
The QAbstractAudioOutput class provides access for QAudioOutput to access the audio device provided b...
Definition: qaudioengine.h:73
QAudio::Error error() const
Returns the error state.
void reset()
Drops all audio data in the buffers, resets buffers to zero.
void setBufferSize(int value)
Sets the audio buffer size to value in bytes.
#define QT_WIN_CALLBACK
Definition: qglobal.h:1178
The QTime class provides clock time functions.
Definition: qdatetime.h:148
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QAudioOutputPrivate(const QByteArray &device, const QAudioFormat &audioFormat)
int notifyInterval() const
Returns the notify interval in milliseconds.
void freeBlocks(WAVEHDR *blockArray)
static const char * data(const QByteArray &arr)
qint64 elapsedUSecs() const
Returns the milliseconds since start() was called, including time in Idle and suspend states...
#define DWORD_PTR
qint64 processedUSecs() const
Returns the amount of audio data processed since start() was called in milliseconds.
__int64 qint64
Definition: qglobal.h:942
void suspend()
Stops processing audio data, preserving buffered audio data.
#define Q_OBJECT
Definition: qobjectdefs.h:157
int periodSize() const
Returns the period size in bytes.
QAudioFormat format() const
Returns the QAudioFormat being used.
State
Definition: qaudio.h:59
int bytesFree() const
Returns the free space available in bytes in the audio buffer.
void setNotifyInterval(int milliSeconds)
Sets the interval for notify() signal to be emitted.
int bufferSize() const
Returns the audio buffer size in bytes.
QIODevice * start(QIODevice *device=0)
Uses the device as the QIODevice to transfer data.
void stop()
Stops the audio output.
The QAudioFormat class stores audio parameter information.
Definition: qaudioformat.h:60
#define slots
Definition: qobjectdefs.h:68
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66