200 /*! |
200 /*! |
201 Uses the \a device as the QIODevice to transfer data. |
201 Uses the \a device as the QIODevice to transfer data. |
202 Passing a QIODevice allows the data to be transfered without any extra code. |
202 Passing a QIODevice allows the data to be transfered without any extra code. |
203 All that is required is to open the QIODevice. |
203 All that is required is to open the QIODevice. |
204 |
204 |
|
205 If able to successfully output audio data to the systems audio device the |
|
206 state() is set to QAudio::ActiveState, error() is set to QAudio::NoError |
|
207 and the stateChanged() signal is emitted. |
|
208 |
|
209 If a problem occurs during this process the error() is set to QAudio::OpenError, |
|
210 state() is set to QAudio::StoppedState and stateChanged() signal is emitted. |
|
211 |
205 \sa QIODevice |
212 \sa QIODevice |
206 */ |
213 */ |
207 |
214 |
208 void QAudioOutput::start(QIODevice* device) |
215 void QAudioOutput::start(QIODevice* device) |
209 { |
216 { |
210 /* |
|
211 -If currently not StoppedState, stop. |
|
212 -If previous start was push mode, delete internal QIODevice. |
|
213 -open audio output. |
|
214 -If ok, NoError and ActiveState, else OpenError and StoppedState |
|
215 -emit stateChanged() |
|
216 */ |
|
217 d->start(device); |
217 d->start(device); |
218 } |
218 } |
219 |
219 |
220 /*! |
220 /*! |
221 Returns a pointer to the QIODevice being used to handle the data |
221 Returns a pointer to the QIODevice being used to handle the data |
222 transfer. This QIODevice can be used to write() audio data directly. |
222 transfer. This QIODevice can be used to write() audio data directly. |
223 |
223 |
|
224 If able to access the systems audio device the state() is set to |
|
225 QAudio::IdleState, error() is set to QAudio::NoError |
|
226 and the stateChanged() signal is emitted. |
|
227 |
|
228 If a problem occurs during this process the error() is set to QAudio::OpenError, |
|
229 state() is set to QAudio::StoppedState and stateChanged() signal is emitted. |
|
230 |
224 \sa QIODevice |
231 \sa QIODevice |
225 */ |
232 */ |
226 |
233 |
227 QIODevice* QAudioOutput::start() |
234 QIODevice* QAudioOutput::start() |
228 { |
235 { |
229 /* |
|
230 -If currently not StoppedState, stop. |
|
231 -If no internal QIODevice, create one. |
|
232 -open audio output. |
|
233 -If ok, NoError and IdleState, else OpenError and StoppedState |
|
234 -emit stateChanged() |
|
235 -return internal QIODevice |
|
236 */ |
|
237 return d->start(0); |
236 return d->start(0); |
238 } |
237 } |
239 |
238 |
240 /*! |
239 /*! |
241 Stops the audio output. |
240 Stops the audio output, detaching from the system resource. |
|
241 |
|
242 Sets error() to QAudio::NoError, state() to QAudio::StoppedState and |
|
243 emit stateChanged() signal. |
242 */ |
244 */ |
243 |
245 |
244 void QAudioOutput::stop() |
246 void QAudioOutput::stop() |
245 { |
247 { |
246 /* |
|
247 -If StoppedState, return |
|
248 -set to StoppedState |
|
249 -detach from audio device |
|
250 -emit stateChanged() |
|
251 */ |
|
252 d->stop(); |
248 d->stop(); |
253 } |
249 } |
254 |
250 |
255 /*! |
251 /*! |
256 Drops all audio data in the buffers, resets buffers to zero. |
252 Drops all audio data in the buffers, resets buffers to zero. |
257 */ |
253 */ |
258 |
254 |
259 void QAudioOutput::reset() |
255 void QAudioOutput::reset() |
260 { |
256 { |
261 /* |
|
262 -drop all buffered audio, set buffers to zero. |
|
263 -call stop() |
|
264 */ |
|
265 d->reset(); |
257 d->reset(); |
266 } |
258 } |
267 |
259 |
268 /*! |
260 /*! |
269 Stops processing audio data, preserving buffered audio data. |
261 Stops processing audio data, preserving buffered audio data. |
|
262 |
|
263 Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and |
|
264 emit stateChanged() signal. |
270 */ |
265 */ |
271 |
266 |
272 void QAudioOutput::suspend() |
267 void QAudioOutput::suspend() |
273 { |
268 { |
274 /* |
|
275 -If not ActiveState|IdleState, return |
|
276 -stop processing audio, saving all buffered audio data |
|
277 -set NoError and SuspendedState |
|
278 -emit stateChanged() |
|
279 */ |
|
280 d->suspend(); |
269 d->suspend(); |
281 } |
270 } |
282 |
271 |
283 /*! |
272 /*! |
284 Resumes processing audio data after a suspend(). |
273 Resumes processing audio data after a suspend(). |
|
274 |
|
275 Sets error() to QAudio::NoError. |
|
276 Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). |
|
277 Sets state() to QAudio::IdleState if you previously called start(). |
|
278 emits stateChanged() signal. |
285 */ |
279 */ |
286 |
280 |
287 void QAudioOutput::resume() |
281 void QAudioOutput::resume() |
288 { |
282 { |
289 /* |
|
290 -If SuspendedState, return |
|
291 -resume audio |
|
292 -(PULL MODE): set ActiveState, NoError |
|
293 -(PUSH MODE): set IdleState, NoError |
|
294 -kick start audio if needed |
|
295 -emit stateChanged() |
|
296 */ |
|
297 d->resume(); |
283 d->resume(); |
298 } |
284 } |
299 |
285 |
300 /*! |
286 /*! |
301 Returns the free space available in bytes in the audio buffer. |
287 Returns the free space available in bytes in the audio buffer. |
|
288 |
|
289 NOTE: returned value is only valid while in QAudio::ActiveState or QAudio::IdleState |
|
290 state, otherwise returns zero. |
302 */ |
291 */ |
303 |
292 |
304 int QAudioOutput::bytesFree() const |
293 int QAudioOutput::bytesFree() const |
305 { |
294 { |
306 /* |
|
307 -If not ActiveState|IdleState, return 0 |
|
308 -return space available in audio buffer in bytes |
|
309 */ |
|
310 return d->bytesFree(); |
295 return d->bytesFree(); |
311 } |
296 } |
312 |
297 |
313 /*! |
298 /*! |
314 Returns the period size in bytes. |
299 Returns the period size in bytes. |