Qt 4.8
qaudioinput_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 QAUDIOINPUTWIN_H
54 #define QAUDIOINPUTWIN_H
55 
56 #include <windows.h>
57 #include <mmsystem.h>
58 
59 #include <QtCore/qfile.h>
60 #include <QtCore/qdebug.h>
61 #include <QtCore/qtimer.h>
62 #include <QtCore/qstring.h>
63 #include <QtCore/qstringlist.h>
64 #include <QtCore/qdatetime.h>
65 #include <QtCore/qmutex.h>
66 
67 #include <QtMultimedia/qaudio.h>
68 #include <QtMultimedia/qaudiodeviceinfo.h>
69 #include <QtMultimedia/qaudioengine.h>
70 
71 
73 
75 {
76  Q_OBJECT
77 public:
80 
81  qint64 read(char* data, qint64 len);
82 
83  QAudioFormat format() const;
84  QIODevice* start(QIODevice* device = 0);
85  void stop();
86  void reset();
87  void suspend();
88  void resume();
89  int bytesReady() const;
90  int periodSize() const;
91  void setBufferSize(int value);
92  int bufferSize() const;
93  void setNotifyInterval(int milliSeconds);
94  int notifyInterval() const;
95  qint64 processedUSecs() const;
96  qint64 elapsedUSecs() const;
97  QAudio::Error error() const;
98  QAudio::State state() const;
99 
104 
105 private:
110  int bytesAvailable;
111  int intervalTime;
116  bool pullMode;
117  bool resuming;
118  WAVEFORMATEX wfx;
119  HWAVEIN hWaveIn;
120  MMRESULT result;
121  WAVEHDR* waveBlocks;
122  volatile bool finished;
123  volatile int waveFreeBlockCount;
125 
126  QMutex mutex;
127  static void QT_WIN_CALLBACK waveInProc( HWAVEIN hWaveIn, UINT uMsg,
128  DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2 );
129 
130  WAVEHDR* allocateBlocks(int size, int count);
131  void freeBlocks(WAVEHDR* blockArray);
132  bool open();
133  void close();
134 
135 private slots:
136  void feedback();
137  bool deviceReady();
138 
139 signals:
140  void processMore();
141 };
142 
143 class InputPrivate : public QIODevice
144 {
145  Q_OBJECT
146 public:
148  ~InputPrivate();
149 
150  qint64 readData( char* data, qint64 len);
151  qint64 writeData(const char* data, qint64 len);
152 
153  void trigger();
154 private:
155  QAudioInputPrivate *audioDevice;
156 };
157 
159 
160 #endif
Error
Definition: qaudio.h:58
QAudioFormat format() const
Returns the QAudioFormat being used.
WAVEHDR * allocateBlocks(int size, int count)
void resume()
Resumes processing audio data after a suspend().
void suspend()
Stops processing audio data, preserving buffered audio data.
#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
qint64 processedUSecs() const
Returns the amount of audio data processed since start() was called in milliseconds.
int bufferSize() const
Returns the audio buffer size in milliseconds.
void stop()
Stops the audio input.
void setNotifyInterval(int milliSeconds)
Sets the interval for notify() signal to be emitted.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QIODevice * start(QIODevice *device=0)
Uses the device as the QIODevice to transfer data.
QAudioFormat audioFormat
int bytesReady() const
Returns the amount of audio data available to read in bytes.
void setBufferSize(int value)
Sets the audio buffer size to value in milliseconds.
QAudio::State state() const
Returns the state of audio processing.
#define QT_WIN_CALLBACK
Definition: qglobal.h:1178
The QTime class provides clock time functions.
Definition: qdatetime.h:148
qint64 read(char *data, qint64 len)
int notifyInterval() const
Returns the notify interval in milliseconds.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QAudio::Error errorState
void freeBlocks(WAVEHDR *blockArray)
qint64 elapsedUSecs() const
Returns the milliseconds since start() was called, including time in Idle and suspend states...
static const char * data(const QByteArray &arr)
void reset()
Drops all audio data in the buffers, resets buffers to zero.
#define DWORD_PTR
__int64 qint64
Definition: qglobal.h:942
The QAbstractAudioInput class provides access for QAudioInput to access the audio device provided by ...
Definition: qaudioengine.h:100
static void QT_WIN_CALLBACK waveInProc(HWAVEIN hWaveIn, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
#define Q_OBJECT
Definition: qobjectdefs.h:157
State
Definition: qaudio.h:59
volatile int waveFreeBlockCount
int periodSize() const
Returns the period size in bytes.
QAudio::Error error() const
Returns the error state.
The QAudioFormat class stores audio parameter information.
Definition: qaudioformat.h:60
QAudio::State deviceState
#define slots
Definition: qobjectdefs.h:68
#define signals
Definition: qobjectdefs.h:69
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
QAudioInputPrivate(const QByteArray &device, const QAudioFormat &audioFormat)