Qt 4.8
qaudiooutput.cpp
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 #include <QtMultimedia/qaudio.h>
44 #include <QtMultimedia/qaudiodeviceinfo.h>
45 #include <QtMultimedia/qaudioengine.h>
46 #include <QtMultimedia/qaudiooutput.h>
47 
48 #include "qaudiodevicefactory_p.h"
49 
50 
52 
126  QObject(parent)
127 {
129  connect(d, SIGNAL(notify()), SIGNAL(notify()));
131 }
132 
140  QObject(parent)
141 {
142  d = QAudioDeviceFactory::createOutputDevice(audioDevice, format);
143  connect(d, SIGNAL(notify()), SIGNAL(notify()));
145 }
146 
152 {
153  delete d;
154 }
155 
162 {
163  return d->format();
164 }
165 
186 {
187  d->start(device);
188 }
189 
209 {
210  return d->start(0);
211 }
212 
221 {
222  d->stop();
223 }
224 
230 {
231  d->reset();
232 }
233 
242 {
243  d->suspend();
244 }
245 
258 {
259  d->resume();
260 }
261 
270 {
271  return d->bytesFree();
272 }
273 
281 {
282  return d->periodSize();
283 }
284 
295 {
296  d->setBufferSize(value);
297 }
298 
310 {
311  return d->bufferSize();
312 }
313 
324 {
325  d->setNotifyInterval(ms);
326 }
327 
333 {
334  return d->notifyInterval();
335 }
336 
352 {
353  return d->processedUSecs();
354 }
355 
362 {
363  return d->elapsedUSecs();
364 }
365 
371 {
372  return d->error();
373 }
374 
380 {
381  return d->state();
382 }
383 
Error
Definition: qaudio.h:58
virtual qint64 elapsedUSecs() const =0
Returns the milliseconds since start() was called, including time in Idle and suspend states...
int notifyInterval() const
Returns the notify interval in milliseconds.
void setBufferSize(int bytes)
Sets the audio buffer size to value in bytes.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
qint64 elapsedUSecs() const
Returns the microseconds since start() was called, including time in Idle and Suspend states...
void stateChanged(QAudio::State)
This signal is emitted when the device state has changed.
virtual int periodSize() const =0
Returns the period size in bytes.
QAudio::Error error() const
Returns the error state.
void stop()
Stops the audio output, detaching from the system resource.
virtual void stop()=0
Stops the audio output.
int periodSize() const
Returns the period size in bytes.
void notify()
This signal is emitted when x ms of audio data has been processed the interval set by setNotifyInterv...
virtual QAudioFormat format() const =0
Returns the QAudioFormat being used.
virtual qint64 processedUSecs() const =0
Returns the amount of audio data processed since start() was called in milliseconds.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
~QAudioOutput()
Destroys this audio output.
void suspend()
Stops processing audio data, preserving buffered audio data.
int bufferSize() const
Returns the audio buffer size in bytes.
#define SIGNAL(a)
Definition: qobjectdefs.h:227
virtual void setBufferSize(int value)=0
Sets the audio buffer size to value in bytes.
virtual QAudio::State state() const =0
Returns the state of audio processing.
virtual QAudio::Error error() const =0
Returns the error state.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
virtual void reset()=0
Drops all audio data in the buffers, resets buffers to zero.
The QAudioDeviceInfo class provides an interface to query audio devices and their functionality...
void resume()
Resumes processing audio data after a suspend().
__int64 qint64
Definition: qglobal.h:942
QAudioFormat format() const
Returns the QAudioFormat being used.
virtual QIODevice * start(QIODevice *device)=0
Uses the device as the QIODevice to transfer data.
QAudio::State state() const
Returns the state of audio processing.
virtual int bufferSize() const =0
Returns the audio buffer size in bytes.
QAudioOutput(const QAudioFormat &format=QAudioFormat(), QObject *parent=0)
Construct a new audio output and attach it to parent.
void reset()
Drops all audio data in the buffers, resets buffers to zero.
virtual int notifyInterval() const =0
Returns the notify interval in milliseconds.
virtual int bytesFree() const =0
Returns the free space available in bytes in the audio buffer.
State
Definition: qaudio.h:59
QAbstractAudioOutput * d
Definition: qaudiooutput.h:104
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
virtual void setNotifyInterval(int milliSeconds)=0
Sets the interval for notify() signal to be emitted.
virtual void suspend()=0
Stops processing audio data, preserving buffered audio data.
virtual void resume()=0
Resumes processing audio data after a suspend()
QIODevice * start()
Returns a pointer to the QIODevice being used to handle the data transfer.
int bytesFree() const
Returns the free space available in bytes in the audio buffer.
qint64 processedUSecs() const
Returns the amount of audio data processed by the class since start() was called in microseconds...
The QAudioFormat class stores audio parameter information.
Definition: qaudioformat.h:60
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
static QAbstractAudioOutput * createDefaultOutputDevice(QAudioFormat const &format)
void setNotifyInterval(int milliSeconds)
Sets the interval for notify() signal to be emitted.
static QAbstractAudioOutput * createOutputDevice(QAudioDeviceInfo const &device, QAudioFormat const &format)