summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qaudioinput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/audio/qaudioinput.cpp')
-rw-r--r--src/multimedia/audio/qaudioinput.cpp111
1 files changed, 61 insertions, 50 deletions
diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp
index 3b997848f..8b368d59f 100644
--- a/src/multimedia/audio/qaudioinput.cpp
+++ b/src/multimedia/audio/qaudioinput.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtMultimedia module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -47,7 +47,6 @@
#include "qaudiodevicefactory_p.h"
-
QT_BEGIN_NAMESPACE
/*!
@@ -61,7 +60,7 @@ QT_BEGIN_NAMESPACE
You can construct an audio input with the system's
\l{QAudioDeviceInfo::defaultInputDevice()}{default audio input
device}. It is also possible to create QAudioInput with a
- specific QAudioDeviceId. When you create the audio input, you
+ specific QAudioDeviceInfo. When you create the audio input, you
should also send in the QAudioFormat to be used for the recording
(see the QAudioFormat class description for details).
@@ -69,7 +68,7 @@ QT_BEGIN_NAMESPACE
QAudioInput lets you record audio with an audio input device. The
default constructor of this class will use the systems default
- audio device, but you can also specify a QAudioDeviceId for a
+ audio device, but you can also specify a QAudioDeviceInfo for a
specific device. You also need to pass in the QAudioFormat in
which you wish to record.
@@ -121,14 +120,19 @@ QT_BEGIN_NAMESPACE
when the state changes (stateChanged()).
QAudioInput provides several ways of measuring the time that has
- passed since the start() of the recording. The \c totalTime()
+ passed since the start() of the recording. The \c processedUSecs()
function returns the length of the stream in microseconds written,
i.e., it leaves out the times the audio input was suspended or idle.
- The clock() function returns the time elapsed since start() was called regardless of
+ The elapsedUSecs() function returns the time elapsed since start() was called regardless of
which states the QAudioInput has been in.
If an error should occur, you can fetch its reason with error().
- The possible error reasons are described by the QAudio::Error enum.
+ The possible error reasons are described by the QAudio::Error
+ enum. The QAudioInput will enter the \l{QAudio::}{StoppedState} when
+ an error is encountered. Connect to the stateChanged() signal to
+ handle the error:
+
+ \snippet doc/src/snippets/audio/main.cpp 0
\sa QAudioOutput, QAudioDeviceInfo
*/
@@ -149,14 +153,14 @@ QAudioInput::QAudioInput(const QAudioFormat &format, QObject *parent):
/*!
Construct a new audio input and attach it to \a parent.
- The \a id of the audio input device is used with the input
+ The device referenced by \a audioDevice is used with the input
\a format parameters.
*/
-QAudioInput::QAudioInput(const QAudioDeviceId &id, const QAudioFormat &format, QObject *parent):
+QAudioInput::QAudioInput(const QAudioDeviceInfo &audioDevice, const QAudioFormat &format, QObject *parent):
QObject(parent)
{
- d = QAudioDeviceFactory::createInputDevice(id, format);
+ d = QAudioDeviceFactory::createInputDevice(audioDevice, format);
connect(d, SIGNAL(notify()), SIGNAL(notify()));
connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State)));
}
@@ -171,37 +175,44 @@ QAudioInput::~QAudioInput()
}
/*!
- Uses the \a device as the QIODevice to transfer data.
- If \a device is null then the class creates an internal QIODevice.
+ Uses the \a device as the QIODevice to transfer data.
+ Passing a QIODevice allows the data to be transfered without any extra code.
+ All that is required is to open the QIODevice.
+
+ \sa QIODevice
+*/
+
+void QAudioInput::start(QIODevice* device)
+{
+ /*
+ -If currently not StoppedState, stop
+ -If previous start was push mode, delete internal QIODevice.
+ -open audio input.
+ If ok, NoError and ActiveState, else OpenError and StoppedState.
+ -emit stateChanged()
+ */
+ d->start(device);
+}
+
+/*!
Returns a pointer to the QIODevice being used to handle the data
transfer. This QIODevice can be used to read() audio data
directly.
- Passing a QIODevice allows the data to be transfered without any extra code.
- All that is required is to open the QIODevice.
- /sa QIODevice
+ \sa QIODevice
*/
-QIODevice* QAudioInput::start(QIODevice* device)
+QIODevice* QAudioInput::start()
{
/*
- PULL MODE (valid QIODevice)
- -If currently not StopState, stop
- -If previous start was push mode, delete internal QIODevice.
- -open audio input.
- If ok, NoError and ActiveState, else OpenError and StopState.
- -emit stateChanged()
- -return device
-
- PUSH MODE (device = 0)
- -If currently not StopState, stop
+ -If currently not StoppedState, stop
-If no internal QIODevice, create one.
-open audio input.
- -If ok, NoError and IdleState, else OpenError and StopState
+ -If ok, NoError and IdleState, else OpenError and StoppedState
-emit stateChanged()
-return internal QIODevice
*/
- return d->start(device);
+ return d->start(0);
}
/*!
@@ -220,8 +231,8 @@ QAudioFormat QAudioInput::format() const
void QAudioInput::stop()
{
/*
- -If StopState, return
- -set to StopState
+ -If StoppedState, return
+ -set to StoppedState
-detach from audio device
-emit stateChanged()
*/
@@ -250,7 +261,7 @@ void QAudioInput::suspend()
/*
-If not ActiveState|IdleState, return
-stop processing audio, saving all buffered audio data
- -set NoError and SuspendState
+ -set NoError and SuspendedState
-emit stateChanged()
*/
d->suspend();
@@ -263,7 +274,7 @@ void QAudioInput::suspend()
void QAudioInput::resume()
{
/*
- -If SuspendState, return
+ -If SuspendedState, return
-resume audio
-(PULL MODE): set ActiveState, NoError
-(PUSH MODE): set IdleState, NoError
@@ -352,9 +363,9 @@ int QAudioInput::notifyInterval() const
was called in microseconds.
*/
-qint64 QAudioInput::totalTime() const
+qint64 QAudioInput::processedUSecs() const
{
- return d->totalTime();
+ return d->processedUSecs();
}
/*!
@@ -362,9 +373,9 @@ qint64 QAudioInput::totalTime() const
Suspend states.
*/
-qint64 QAudioInput::clock() const
+qint64 QAudioInput::elapsedUSecs() const
{
- return d->clock();
+ return d->elapsedUSecs();
}
/*!