author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 10:37:55 +0300 | |
changeset 33 | 3e2da88830cd |
parent 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtMultimedia module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
||
43 |
#include <QtMultimedia/qaudio.h> |
|
44 |
#include <QtMultimedia/qaudiodeviceinfo.h> |
|
45 |
#include <QtMultimedia/qaudioengine.h> |
|
46 |
#include <QtMultimedia/qaudioinput.h> |
|
47 |
||
48 |
#include "qaudiodevicefactory_p.h" |
|
49 |
||
50 |
QT_BEGIN_NAMESPACE |
|
51 |
||
52 |
/*! |
|
53 |
\class QAudioInput |
|
54 |
\brief The QAudioInput class provides an interface for receiving audio data from an audio input device. |
|
55 |
||
56 |
\inmodule QtMultimedia |
|
57 |
\ingroup multimedia |
|
58 |
\since 4.6 |
|
59 |
||
60 |
You can construct an audio input with the system's |
|
61 |
\l{QAudioDeviceInfo::defaultInputDevice()}{default audio input |
|
62 |
device}. It is also possible to create QAudioInput with a |
|
63 |
specific QAudioDeviceInfo. When you create the audio input, you |
|
64 |
should also send in the QAudioFormat to be used for the recording |
|
65 |
(see the QAudioFormat class description for details). |
|
66 |
||
67 |
To record to a file: |
|
68 |
||
69 |
QAudioInput lets you record audio with an audio input device. The |
|
70 |
default constructor of this class will use the systems default |
|
71 |
audio device, but you can also specify a QAudioDeviceInfo for a |
|
72 |
specific device. You also need to pass in the QAudioFormat in |
|
73 |
which you wish to record. |
|
74 |
||
75 |
Starting up the QAudioInput is simply a matter of calling start() |
|
76 |
with a QIODevice opened for writing. For instance, to record to a |
|
77 |
file, you can: |
|
78 |
||
79 |
\code |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
QFile outputFile; // class member. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
QAudioInput* audio; // class member. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
\endcode |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
83 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
84 |
\code |
0 | 85 |
{ |
86 |
outputFile.setFileName("/tmp/test.raw"); |
|
87 |
outputFile.open( QIODevice::WriteOnly | QIODevice::Truncate ); |
|
88 |
||
89 |
QAudioFormat format; |
|
90 |
// set up the format you want, eg. |
|
91 |
format.setFrequency(8000); |
|
92 |
format.setChannels(1); |
|
93 |
format.setSampleSize(8); |
|
94 |
format.setCodec("audio/pcm"); |
|
95 |
format.setByteOrder(QAudioFormat::LittleEndian); |
|
96 |
format.setSampleType(QAudioFormat::UnSignedInt); |
|
97 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
98 |
QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice(); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
99 |
if (!info.isFormatSupported(format)) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
qWarning()<<"default format not supported try to use nearest"; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
101 |
format = info.nearestFormat(format); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
102 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
103 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
104 |
audio = new QAudioInput(format, this); |
0 | 105 |
QTimer::singleShot(3000, this, SLOT(stopRecording())); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
106 |
audio->start(&outputFile); |
0 | 107 |
// Records audio for 3000ms |
108 |
} |
|
109 |
\endcode |
|
110 |
||
111 |
This will start recording if the format specified is supported by |
|
112 |
the input device (you can check this with |
|
113 |
QAudioDeviceInfo::isFormatSupported(). In case there are any |
|
114 |
snags, use the error() function to check what went wrong. We stop |
|
115 |
recording in the \c stopRecording() slot. |
|
116 |
||
117 |
\code |
|
118 |
void stopRecording() |
|
119 |
{ |
|
120 |
audio->stop(); |
|
121 |
outputFile->close(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
delete audio; |
0 | 123 |
} |
124 |
\endcode |
|
125 |
||
126 |
At any point in time, QAudioInput will be in one of four states: |
|
127 |
active, suspended, stopped, or idle. These states are specified by |
|
128 |
the QAudio::State enum. You can request a state change directly through |
|
129 |
suspend(), resume(), stop(), reset(), and start(). The current |
|
130 |
state is reported by state(). QAudioOutput will also signal you |
|
131 |
when the state changes (stateChanged()). |
|
132 |
||
133 |
QAudioInput provides several ways of measuring the time that has |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
134 |
passed since the start() of the recording. The \c processedUSecs() |
0 | 135 |
function returns the length of the stream in microseconds written, |
136 |
i.e., it leaves out the times the audio input was suspended or idle. |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
The elapsedUSecs() function returns the time elapsed since start() was called regardless of |
0 | 138 |
which states the QAudioInput has been in. |
139 |
||
140 |
If an error should occur, you can fetch its reason with error(). |
|
141 |
The possible error reasons are described by the QAudio::Error |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
enum. The QAudioInput will enter the \l{QAudio::}{StoppedState} when |
0 | 143 |
an error is encountered. Connect to the stateChanged() signal to |
144 |
handle the error: |
|
145 |
||
146 |
\snippet doc/src/snippets/audio/main.cpp 0 |
|
147 |
||
148 |
\sa QAudioOutput, QAudioDeviceInfo |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
149 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
150 |
\section1 Symbian Platform Security Requirements |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
151 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
152 |
On Symbian, processes which use this class must have the |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
153 |
\c UserEnvironment platform security capability. If the client |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
154 |
process lacks this capability, calls to either overload of start() |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
155 |
will fail. |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
156 |
This failure is indicated by the QAudioInput object setting |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
157 |
its error() value to \l{QAudio::OpenError} and then emitting a |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
158 |
\l{stateChanged()}{stateChanged}(\l{QAudio::StoppedState}) signal. |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
159 |
|
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
160 |
Platform security capabilities are added via the |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
161 |
\l{qmake-variable-reference.html#target-capability}{TARGET.CAPABILITY} |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
162 |
qmake variable. |
0 | 163 |
*/ |
164 |
||
165 |
/*! |
|
166 |
Construct a new audio input and attach it to \a parent. |
|
167 |
The default audio input device is used with the output |
|
168 |
\a format parameters. |
|
169 |
*/ |
|
170 |
||
171 |
QAudioInput::QAudioInput(const QAudioFormat &format, QObject *parent): |
|
172 |
QObject(parent) |
|
173 |
{ |
|
174 |
d = QAudioDeviceFactory::createDefaultInputDevice(format); |
|
175 |
connect(d, SIGNAL(notify()), SIGNAL(notify())); |
|
176 |
connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); |
|
177 |
} |
|
178 |
||
179 |
/*! |
|
180 |
Construct a new audio input and attach it to \a parent. |
|
181 |
The device referenced by \a audioDevice is used with the input |
|
182 |
\a format parameters. |
|
183 |
*/ |
|
184 |
||
185 |
QAudioInput::QAudioInput(const QAudioDeviceInfo &audioDevice, const QAudioFormat &format, QObject *parent): |
|
186 |
QObject(parent) |
|
187 |
{ |
|
188 |
d = QAudioDeviceFactory::createInputDevice(audioDevice, format); |
|
189 |
connect(d, SIGNAL(notify()), SIGNAL(notify())); |
|
190 |
connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); |
|
191 |
} |
|
192 |
||
193 |
/*! |
|
194 |
Destroy this audio input. |
|
195 |
*/ |
|
196 |
||
197 |
QAudioInput::~QAudioInput() |
|
198 |
{ |
|
199 |
delete d; |
|
200 |
} |
|
201 |
||
202 |
/*! |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
203 |
Uses the \a device as the QIODevice to transfer data. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
204 |
Passing a QIODevice allows the data to be transfered without any extra code. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
205 |
All that is required is to open the QIODevice. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
206 |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
207 |
If able to successfully get audio data from the systems audio device the |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
208 |
state() is set to either QAudio::ActiveState or QAudio::IdleState, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
209 |
error() is set to QAudio::NoError and the stateChanged() signal is emitted. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
210 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
211 |
If a problem occurs during this process the error() is set to QAudio::OpenError, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
212 |
state() is set to QAudio::StoppedState and stateChanged() signal is emitted. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
213 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
214 |
\l{QAudioInput#Symbian Platform Security Requirements} |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
215 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
\sa QIODevice |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
void QAudioInput::start(QIODevice* device) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
221 |
d->start(device); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
224 |
/*! |
0 | 225 |
Returns a pointer to the QIODevice being used to handle the data |
226 |
transfer. This QIODevice can be used to read() audio data |
|
227 |
directly. |
|
228 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
229 |
If able to access the systems audio device the state() is set to |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
230 |
QAudio::IdleState, error() is set to QAudio::NoError |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
231 |
and the stateChanged() signal is emitted. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
232 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
233 |
If a problem occurs during this process the error() is set to QAudio::OpenError, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
234 |
state() is set to QAudio::StoppedState and stateChanged() signal is emitted. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
235 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
236 |
\l{QAudioInput#Symbian Platform Security Requirements} |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
237 |
|
0 | 238 |
\sa QIODevice |
239 |
*/ |
|
240 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
241 |
QIODevice* QAudioInput::start() |
0 | 242 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
243 |
return d->start(0); |
0 | 244 |
} |
245 |
||
246 |
/*! |
|
247 |
Returns the QAudioFormat being used. |
|
248 |
*/ |
|
249 |
||
250 |
QAudioFormat QAudioInput::format() const |
|
251 |
{ |
|
252 |
return d->format(); |
|
253 |
} |
|
254 |
||
255 |
/*! |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
256 |
Stops the audio input, detaching from the system resource. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
257 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
258 |
Sets error() to QAudio::NoError, state() to QAudio::StoppedState and |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
259 |
emit stateChanged() signal. |
0 | 260 |
*/ |
261 |
||
262 |
void QAudioInput::stop() |
|
263 |
{ |
|
264 |
d->stop(); |
|
265 |
} |
|
266 |
||
267 |
/*! |
|
268 |
Drops all audio data in the buffers, resets buffers to zero. |
|
269 |
*/ |
|
270 |
||
271 |
void QAudioInput::reset() |
|
272 |
{ |
|
273 |
d->reset(); |
|
274 |
} |
|
275 |
||
276 |
/*! |
|
277 |
Stops processing audio data, preserving buffered audio data. |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
278 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
279 |
Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
280 |
emit stateChanged() signal. |
0 | 281 |
*/ |
282 |
||
283 |
void QAudioInput::suspend() |
|
284 |
{ |
|
285 |
d->suspend(); |
|
286 |
} |
|
287 |
||
288 |
/*! |
|
289 |
Resumes processing audio data after a suspend(). |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
290 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
291 |
Sets error() to QAudio::NoError. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
292 |
Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
293 |
Sets state() to QAudio::IdleState if you previously called start(). |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
294 |
emits stateChanged() signal. |
0 | 295 |
*/ |
296 |
||
297 |
void QAudioInput::resume() |
|
298 |
{ |
|
299 |
d->resume(); |
|
300 |
} |
|
301 |
||
302 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
303 |
Sets the audio buffer size to \a value milliseconds. |
0 | 304 |
|
305 |
Note: This function can be called anytime before start(), calls to this |
|
306 |
are ignored after start(). It should not be assumed that the buffer size |
|
307 |
set is the actual buffer size used, calling bufferSize() anytime after start() |
|
308 |
will return the actual buffer size being used. |
|
309 |
||
310 |
*/ |
|
311 |
||
312 |
void QAudioInput::setBufferSize(int value) |
|
313 |
{ |
|
314 |
d->setBufferSize(value); |
|
315 |
} |
|
316 |
||
317 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
318 |
Returns the audio buffer size in milliseconds. |
0 | 319 |
|
320 |
If called before start(), returns platform default value. |
|
321 |
If called before start() but setBufferSize() was called prior, returns value set by setBufferSize(). |
|
322 |
If called after start(), returns the actual buffer size being used. This may not be what was set previously |
|
323 |
by setBufferSize(). |
|
324 |
||
325 |
*/ |
|
326 |
||
327 |
int QAudioInput::bufferSize() const |
|
328 |
{ |
|
329 |
return d->bufferSize(); |
|
330 |
} |
|
331 |
||
332 |
/*! |
|
333 |
Returns the amount of audio data available to read in bytes. |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
334 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
335 |
NOTE: returned value is only valid while in QAudio::ActiveState or QAudio::IdleState |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
336 |
state, otherwise returns zero. |
0 | 337 |
*/ |
338 |
||
339 |
int QAudioInput::bytesReady() const |
|
340 |
{ |
|
341 |
/* |
|
342 |
-If not ActiveState|IdleState, return 0 |
|
343 |
-return amount of audio data available to read |
|
344 |
*/ |
|
345 |
return d->bytesReady(); |
|
346 |
} |
|
347 |
||
348 |
/*! |
|
349 |
Returns the period size in bytes. |
|
350 |
||
351 |
Note: This is the recommended read size in bytes. |
|
352 |
*/ |
|
353 |
||
354 |
int QAudioInput::periodSize() const |
|
355 |
{ |
|
356 |
return d->periodSize(); |
|
357 |
} |
|
358 |
||
359 |
/*! |
|
360 |
Sets the interval for notify() signal to be emitted. |
|
361 |
This is based on the \a ms of audio data processed |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
362 |
not on actual real-time. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
363 |
The minimum resolution of the timer is platform specific and values |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
364 |
should be checked with notifyInterval() to confirm actual value |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
365 |
being used. |
0 | 366 |
*/ |
367 |
||
368 |
void QAudioInput::setNotifyInterval(int ms) |
|
369 |
{ |
|
370 |
d->setNotifyInterval(ms); |
|
371 |
} |
|
372 |
||
373 |
/*! |
|
374 |
Returns the notify interval in milliseconds. |
|
375 |
*/ |
|
376 |
||
377 |
int QAudioInput::notifyInterval() const |
|
378 |
{ |
|
379 |
return d->notifyInterval(); |
|
380 |
} |
|
381 |
||
382 |
/*! |
|
383 |
Returns the amount of audio data processed since start() |
|
384 |
was called in microseconds. |
|
385 |
*/ |
|
386 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
387 |
qint64 QAudioInput::processedUSecs() const |
0 | 388 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
389 |
return d->processedUSecs(); |
0 | 390 |
} |
391 |
||
392 |
/*! |
|
393 |
Returns the microseconds since start() was called, including time in Idle and |
|
394 |
Suspend states. |
|
395 |
*/ |
|
396 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
397 |
qint64 QAudioInput::elapsedUSecs() const |
0 | 398 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
399 |
return d->elapsedUSecs(); |
0 | 400 |
} |
401 |
||
402 |
/*! |
|
403 |
Returns the error state. |
|
404 |
*/ |
|
405 |
||
406 |
QAudio::Error QAudioInput::error() const |
|
407 |
{ |
|
408 |
return d->error(); |
|
409 |
} |
|
410 |
||
411 |
/*! |
|
412 |
Returns the state of audio processing. |
|
413 |
*/ |
|
414 |
||
415 |
QAudio::State QAudioInput::state() const |
|
416 |
{ |
|
417 |
return d->state(); |
|
418 |
} |
|
419 |
||
420 |
/*! |
|
421 |
\fn QAudioInput::stateChanged(QAudio::State state) |
|
422 |
This signal is emitted when the device \a state has changed. |
|
423 |
*/ |
|
424 |
||
425 |
/*! |
|
426 |
\fn QAudioInput::notify() |
|
427 |
This signal is emitted when x ms of audio data has been processed |
|
428 |
the interval set by setNotifyInterval(x). |
|
429 |
*/ |
|
430 |
||
431 |
QT_END_NAMESPACE |
|
432 |