Qt 4.8
qaudioinput.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/qaudioinput.h>
47 
48 #include "qaudiodevicefactory_p.h"
49 
51 
139  QObject(parent)
140 {
142  connect(d, SIGNAL(notify()), SIGNAL(notify()));
144 }
145 
153  QObject(parent)
154 {
155  d = QAudioDeviceFactory::createInputDevice(audioDevice, format);
156  connect(d, SIGNAL(notify()), SIGNAL(notify()));
158 }
159 
165 {
166  delete d;
167 }
168 
193 {
194  d->start(device);
195 }
196 
218 {
219  return d->start(0);
220 }
221 
227 {
228  return d->format();
229 }
230 
239 {
240  d->stop();
241 }
242 
248 {
249  d->reset();
250 }
251 
260 {
261  d->suspend();
262 }
263 
274 {
275  d->resume();
276 }
277 
289 {
290  d->setBufferSize(value);
291 }
292 
304 {
305  return d->bufferSize();
306 }
307 
316 {
317  /*
318  -If not ActiveState|IdleState, return 0
319  -return amount of audio data available to read
320  */
321  return d->bytesReady();
322 }
323 
331 {
332  return d->periodSize();
333 }
334 
345 {
346  d->setNotifyInterval(ms);
347 }
348 
354 {
355  return d->notifyInterval();
356 }
357 
364 {
365  return d->processedUSecs();
366 }
367 
374 {
375  return d->elapsedUSecs();
376 }
377 
383 {
384  return d->error();
385 }
386 
392 {
393  return d->state();
394 }
395 
414 
~QAudioInput()
Destroy this audio input.
Error
Definition: qaudio.h:58
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual qint64 elapsedUSecs() const =0
Returns the milliseconds since start() was called, including time in Idle and suspend states...
void setBufferSize(int bytes)
Sets the audio buffer size to value milliseconds.
qint64 elapsedUSecs() const
Returns the microseconds since start() was called, including time in Idle and Suspend states...
virtual void reset()=0
Drops all audio data in the buffers, resets buffers to zero.
qint64 processedUSecs() const
Returns the amount of audio data processed since start() was called in microseconds.
virtual void resume()=0
Resumes processing audio data after a suspend().
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
void setNotifyInterval(int milliSeconds)
Sets the interval for notify() signal to be emitted.
virtual QAudio::State state() const =0
Returns the state of audio processing.
#define SIGNAL(a)
Definition: qobjectdefs.h:227
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void reset()
Drops all audio data in the buffers, resets buffers to zero.
virtual QAudio::Error error() const =0
Returns the error state.
int bytesReady() const
Returns the amount of audio data available to read in bytes.
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 stop()=0
Stops the audio input.
virtual void setBufferSize(int value)=0
Sets the audio buffer size to value in milliseconds.
virtual int periodSize() const =0
Returns the period size in bytes.
The QAudioDeviceInfo class provides an interface to query audio devices and their functionality...
void stop()
Stops the audio input, detaching from the system resource.
__int64 qint64
Definition: qglobal.h:942
virtual int bytesReady() const =0
Returns the amount of audio data available to read in bytes.
int notifyInterval() const
Returns the notify interval in milliseconds.
virtual int notifyInterval() const =0
Returns the notify interval in milliseconds.
virtual qint64 processedUSecs() const =0
Returns the amount of audio data processed since start() was called in milliseconds.
void resume()
Resumes processing audio data after a suspend().
State
Definition: qaudio.h:59
QAbstractAudioInput * d
Definition: qaudioinput.h:104
void notify()
This signal is emitted when x ms of audio data has been processed the interval set by setNotifyInterv...
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
static QAbstractAudioInput * createDefaultInputDevice(QAudioFormat const &format)
virtual int bufferSize() const =0
Returns the audio buffer size in milliseconds.
QAudio::State state() const
Returns the state of audio processing.
int periodSize() const
Returns the period size in bytes.
virtual void setNotifyInterval(int milliSeconds)=0
Sets the interval for notify() signal to be emitted.
static QAbstractAudioInput * createInputDevice(QAudioDeviceInfo const &device, QAudioFormat const &format)
int bufferSize() const
Returns the audio buffer size in milliseconds.
QAudio::Error error() const
Returns the error state.
The QAudioFormat class stores audio parameter information.
Definition: qaudioformat.h:60
void stateChanged(QAudio::State)
This signal is emitted when the device state has changed.
QAudioInput(const QAudioFormat &format=QAudioFormat(), QObject *parent=0)
Construct a new audio input and attach it to parent.
virtual void suspend()=0
Stops processing audio data, preserving buffered audio data.
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
QAudioFormat format() const
Returns the QAudioFormat being used.
virtual QIODevice * start(QIODevice *device)=0
Uses the device as the QIODevice to transfer data.
QIODevice * start()
Returns a pointer to a new QIODevice that will be used to handle the data transfer.
void suspend()
Stops processing audio data, preserving buffered audio data.
virtual QAudioFormat format() const =0
Returns the QAudioFormat being used.