summaryrefslogtreecommitdiff
path: root/src/multimedia/audio
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/audio')
-rw-r--r--src/multimedia/audio/qaudio.cpp24
-rw-r--r--src/multimedia/audio/qaudio.h2
-rw-r--r--src/multimedia/audio/qaudiodevicefactory.cpp22
-rw-r--r--src/multimedia/audio/qaudiodevicefactory_p.h2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo.cpp8
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo.h2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp6
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_alsa_p.h2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_mac_p.h2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp3
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_win32_p.h2
-rw-r--r--src/multimedia/audio/qaudioengine.cpp8
-rw-r--r--src/multimedia/audio/qaudioengine.h8
-rw-r--r--src/multimedia/audio/qaudioengineplugin.h4
-rw-r--r--src/multimedia/audio/qaudioformat.cpp13
-rw-r--r--src/multimedia/audio/qaudioformat.h2
-rw-r--r--src/multimedia/audio/qaudioinput.cpp63
-rw-r--r--src/multimedia/audio/qaudioinput.h8
-rw-r--r--src/multimedia/audio/qaudioinput_alsa_p.cpp28
-rw-r--r--src/multimedia/audio/qaudioinput_alsa_p.h4
-rw-r--r--src/multimedia/audio/qaudioinput_mac_p.cpp24
-rw-r--r--src/multimedia/audio/qaudioinput_mac_p.h4
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp39
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.h4
-rw-r--r--src/multimedia/audio/qaudiooutput.cpp52
-rw-r--r--src/multimedia/audio/qaudiooutput.h8
-rw-r--r--src/multimedia/audio/qaudiooutput_alsa_p.cpp32
-rw-r--r--src/multimedia/audio/qaudiooutput_alsa_p.h4
-rw-r--r--src/multimedia/audio/qaudiooutput_mac_p.cpp26
-rw-r--r--src/multimedia/audio/qaudiooutput_mac_p.h4
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp26
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.h4
33 files changed, 230 insertions, 212 deletions
diff --git a/src/multimedia/audio/qaudio.cpp b/src/multimedia/audio/qaudio.cpp
index 04378d4c9e..b687f3411f 100644
--- a/src/multimedia/audio/qaudio.cpp
+++ b/src/multimedia/audio/qaudio.cpp
@@ -71,23 +71,23 @@ public:
/*!
\enum QAudio::Error
- \value NoError No errors have occurred
- \value OpenError An error opening the audio device
- \value IOError An error occurred during read/write of audio device
- \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate
- \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time.
+ \value NoError No errors have occurred
+ \value OpenError An error opening the audio device
+ \value IOError An error occurred during read/write of audio device
+ \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate
+ \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time.
*/
/*!
\enum QAudio::State
- \value ActiveState Audio data is being processed, this state is set after start() is called
- and while audio data is available to be processed.
- \value SuspendState The audio device is in a suspended state, this state will only be entered
- after suspend() is called.
- \value StopState The audio device is closed, not processing any audio data
- \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state
- is set after start() is called and while no audio data is available to be processed.
+ \value ActiveState Audio data is being processed, this state is set after start() is called
+ and while audio data is available to be processed.
+ \value SuspendedState The audio device is in a suspended state, this state will only be entered
+ after suspend() is called.
+ \value StoppedState The audio device is closed, not processing any audio data
+ \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state
+ is set after start() is called and while no audio data is available to be processed.
*/
/*!
diff --git a/src/multimedia/audio/qaudio.h b/src/multimedia/audio/qaudio.h
index a66f0b182c..531e1a7968 100644
--- a/src/multimedia/audio/qaudio.h
+++ b/src/multimedia/audio/qaudio.h
@@ -56,7 +56,7 @@ QT_MODULE(Multimedia)
namespace QAudio
{
enum Error { NoError, OpenError, IOError, UnderrunError, FatalError };
- enum State { ActiveState, SuspendState, StopState, IdleState };
+ enum State { ActiveState, SuspendedState, StoppedState, IdleState };
enum Mode { AudioInput, AudioOutput };
}
diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp
index 8804fb6e51..89e439419e 100644
--- a/src/multimedia/audio/qaudiodevicefactory.cpp
+++ b/src/multimedia/audio/qaudiodevicefactory.cpp
@@ -94,10 +94,10 @@ public:
int bufferSize() const { return 0; }
void setNotifyInterval(int ) {}
int notifyInterval() const { return 0; }
- qint64 totalTime() const { return 0; }
- qint64 clock() const { return 0; }
+ qint64 processedUSecs() const { return 0; }
+ qint64 elapsedUSecs() const { return 0; }
QAudio::Error error() const { return QAudio::OpenError; }
- QAudio::State state() const { return QAudio::StopState; }
+ QAudio::State state() const { return QAudio::StoppedState; }
QAudioFormat format() const { return QAudioFormat(); }
};
@@ -115,18 +115,18 @@ public:
int bufferSize() const { return 0; }
void setNotifyInterval(int ) {}
int notifyInterval() const { return 0; }
- qint64 totalTime() const { return 0; }
- qint64 clock() const { return 0; }
+ qint64 processedUSecs() const { return 0; }
+ qint64 elapsedUSecs() const { return 0; }
QAudio::Error error() const { return QAudio::OpenError; }
- QAudio::State state() const { return QAudio::StopState; }
+ QAudio::State state() const { return QAudio::StoppedState; }
QAudioFormat format() const { return QAudioFormat(); }
};
-QList<QAudioDeviceInfo> QAudioDeviceFactory::deviceList(QAudio::Mode mode)
+QList<QAudioDeviceInfo> QAudioDeviceFactory::availableDevices(QAudio::Mode mode)
{
QList<QAudioDeviceInfo> devices;
#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA))
- foreach (const QByteArray &handle, QAudioDeviceInfoInternal::deviceList(mode))
+ foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode))
devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode);
#endif
QFactoryLoader* l = loader();
@@ -134,7 +134,7 @@ QList<QAudioDeviceInfo> QAudioDeviceFactory::deviceList(QAudio::Mode mode)
foreach (QString const& key, l->keys()) {
QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(l->instance(key));
if (plugin) {
- foreach (QByteArray const& handle, plugin->deviceList(mode))
+ foreach (QByteArray const& handle, plugin->availableDevices(mode))
devices << QAudioDeviceInfo(key, handle, mode);
}
@@ -149,7 +149,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice()
QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(QLatin1String("default")));
if (plugin) {
- QList<QByteArray> list = plugin->deviceList(QAudio::AudioInput);
+ QList<QByteArray> list = plugin->availableDevices(QAudio::AudioInput);
if (list.size() > 0)
return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput);
}
@@ -164,7 +164,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice()
QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(QLatin1String("default")));
if (plugin) {
- QList<QByteArray> list = plugin->deviceList(QAudio::AudioOutput);
+ QList<QByteArray> list = plugin->availableDevices(QAudio::AudioOutput);
if (list.size() > 0)
return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput);
}
diff --git a/src/multimedia/audio/qaudiodevicefactory_p.h b/src/multimedia/audio/qaudiodevicefactory_p.h
index 008e4a8b23..2466455405 100644
--- a/src/multimedia/audio/qaudiodevicefactory_p.h
+++ b/src/multimedia/audio/qaudiodevicefactory_p.h
@@ -72,7 +72,7 @@ class QAbstractAudioDeviceInfo;
class QAudioDeviceFactory
{
public:
- static QList<QAudioDeviceInfo> deviceList(QAudio::Mode mode);
+ static QList<QAudioDeviceInfo> availableDevices(QAudio::Mode mode);
static QAudioDeviceInfo defaultInputDevice();
static QAudioDeviceInfo defaultOutputDevice();
diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp
index dce2884762..5e3adcb434 100644
--- a/src/multimedia/audio/qaudiodeviceinfo.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo.cpp
@@ -121,7 +121,7 @@ public:
classes that communicate with the device--such as
QAudioInput, and QAudioOutput. The static
functions defaultInputDevice(), defaultOutputDevice(), and
- deviceList() let you get a list of all available
+ availableDevices() let you get a list of all available
devices. Devices are fetch according to the value of mode
this is specified by the QAudio::Mode enum.
The QAudioDeviceInfo returned are only valid for the QAudio::Mode.
@@ -129,7 +129,7 @@ public:
For instance:
\code
- foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(QAudio::AudioOutput))
+ foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput))
qDebug() << "Device name: " << deviceInfo.deviceName();
\endcode
@@ -327,9 +327,9 @@ QAudioDeviceInfo QAudioDeviceInfo::defaultOutputDevice()
Returns a list of audio devices that support \a mode.
*/
-QList<QAudioDeviceInfo> QAudioDeviceInfo::deviceList(QAudio::Mode mode)
+QList<QAudioDeviceInfo> QAudioDeviceInfo::availableDevices(QAudio::Mode mode)
{
- return QAudioDeviceFactory::deviceList(mode);
+ return QAudioDeviceFactory::availableDevices(mode);
}
diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h
index 53b9904cac..5c7cb9858f 100644
--- a/src/multimedia/audio/qaudiodeviceinfo.h
+++ b/src/multimedia/audio/qaudiodeviceinfo.h
@@ -92,7 +92,7 @@ public:
static QAudioDeviceInfo defaultInputDevice();
static QAudioDeviceInfo defaultOutputDevice();
- static QList<QAudioDeviceInfo> deviceList(QAudio::Mode mode);
+ static QList<QAudioDeviceInfo> availableDevices(QAudio::Mode mode);
private:
QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode);
diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
index e828238a99..5de6c70445 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
@@ -382,7 +382,7 @@ void QAudioDeviceInfoInternal::updateLists()
close();
}
-QList<QByteArray> QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode)
+QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
{
QList<QByteArray> devices;
QByteArray filter;
@@ -444,7 +444,7 @@ QList<QByteArray> QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode)
QByteArray QAudioDeviceInfoInternal::defaultInputDevice()
{
- QList<QByteArray> devices = deviceList(QAudio::AudioInput);
+ QList<QByteArray> devices = availableDevices(QAudio::AudioInput);
if(devices.size() == 0)
return QByteArray();
@@ -453,7 +453,7 @@ QByteArray QAudioDeviceInfoInternal::defaultInputDevice()
QByteArray QAudioDeviceInfoInternal::defaultOutputDevice()
{
- QList<QByteArray> devices = deviceList(QAudio::AudioOutput);
+ QList<QByteArray> devices = availableDevices(QAudio::AudioOutput);
if(devices.size() == 0)
return QByteArray();
diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h
index 10078caa8e..5a807af271 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h
+++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h
@@ -92,7 +92,7 @@ public:
QList<QAudioFormat::SampleType> sampleTypeList();
static QByteArray defaultInputDevice();
static QByteArray defaultOutputDevice();
- static QList<QByteArray> deviceList(QAudio::Mode);
+ static QList<QByteArray> availableDevices(QAudio::Mode);
private:
bool open();
diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp
index ec07748c1c..8905119d92 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp
@@ -324,7 +324,7 @@ QByteArray QAudioDeviceInfoInternal::defaultOutputDevice()
return get_device_info(audioDevice, QAudio::AudioOutput);
}
-QList<QByteArray> QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode)
+QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
{
QList<QByteArray> devices;
diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h
index 60532a8520..0fd3ef50cf 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h
+++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h
@@ -87,7 +87,7 @@ public:
static QByteArray defaultInputDevice();
static QByteArray defaultOutputDevice();
- static QList<QByteArray> deviceList(QAudio::Mode mode);
+ static QList<QByteArray> availableDevices(QAudio::Mode mode);
};
QT_END_NAMESPACE
diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
index 69d5c94e2d..33af022904 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
@@ -103,6 +103,7 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const
} else {
nearest.setFrequency(11025);
nearest.setChannels(1);
+ nearest.setByteOrder(QAudioFormat::LittleEndian);
nearest.setSampleType(QAudioFormat::SignedInt);
nearest.setSampleSize(8);
nearest.setCodec(QLatin1String("audio/pcm"));
@@ -333,7 +334,7 @@ void QAudioDeviceInfoInternal::updateLists()
}
}
-QList<QByteArray> QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode)
+QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
{
Q_UNUSED(mode)
diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h
index 0d2ee29143..e191b6f1c3 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h
+++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h
@@ -93,7 +93,7 @@ public:
QList<QAudioFormat::SampleType> sampleTypeList();
static QByteArray defaultInputDevice();
static QByteArray defaultOutputDevice();
- static QList<QByteArray> deviceList(QAudio::Mode);
+ static QList<QByteArray> availableDevices(QAudio::Mode);
private:
QAudio::Mode mode;
diff --git a/src/multimedia/audio/qaudioengine.cpp b/src/multimedia/audio/qaudioengine.cpp
index c6e9d9795b..88e3804bf9 100644
--- a/src/multimedia/audio/qaudioengine.cpp
+++ b/src/multimedia/audio/qaudioengine.cpp
@@ -189,12 +189,12 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn virtual qint64 QAbstractAudioOutput::totalTime() const
+ \fn virtual qint64 QAbstractAudioOutput::processedUSecs() const
Returns the amount of audio data processed since start() was called in milliseconds.
*/
/*!
- \fn virtual qint64 QAbstractAudioOutput::clock() const
+ \fn virtual qint64 QAbstractAudioOutput::elapsedUSecs() const
Returns the milliseconds since start() was called, including time in Idle and suspend states.
*/
@@ -304,12 +304,12 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn virtual qint64 QAbstractAudioInput::totalTime() const
+ \fn virtual qint64 QAbstractAudioInput::processedUSecs() const
Returns the amount of audio data processed since start() was called in milliseconds.
*/
/*!
- \fn virtual qint64 QAbstractAudioInput::clock() const
+ \fn virtual qint64 QAbstractAudioInput::elapsedUSecs() const
Returns the milliseconds since start() was called, including time in Idle and suspend states.
*/
diff --git a/src/multimedia/audio/qaudioengine.h b/src/multimedia/audio/qaudioengine.h
index 57a9ae69df..f9e80c157a 100644
--- a/src/multimedia/audio/qaudioengine.h
+++ b/src/multimedia/audio/qaudioengine.h
@@ -86,8 +86,8 @@ public:
virtual int bufferSize() const = 0;
virtual void setNotifyInterval(int milliSeconds) = 0;
virtual int notifyInterval() const = 0;
- virtual qint64 totalTime() const = 0;
- virtual qint64 clock() const = 0;
+ virtual qint64 processedUSecs() const = 0;
+ virtual qint64 elapsedUSecs() const = 0;
virtual QAudio::Error error() const = 0;
virtual QAudio::State state() const = 0;
virtual QAudioFormat format() const = 0;
@@ -113,8 +113,8 @@ public:
virtual int bufferSize() const = 0;
virtual void setNotifyInterval(int milliSeconds) = 0;
virtual int notifyInterval() const = 0;
- virtual qint64 totalTime() const = 0;
- virtual qint64 clock() const = 0;
+ virtual qint64 processedUSecs() const = 0;
+ virtual qint64 elapsedUSecs() const = 0;
virtual QAudio::Error error() const = 0;
virtual QAudio::State state() const = 0;
virtual QAudioFormat format() const = 0;
diff --git a/src/multimedia/audio/qaudioengineplugin.h b/src/multimedia/audio/qaudioengineplugin.h
index fe30e0d5df..82dfa15a12 100644
--- a/src/multimedia/audio/qaudioengineplugin.h
+++ b/src/multimedia/audio/qaudioengineplugin.h
@@ -60,7 +60,7 @@ QT_MODULE(Multimedia)
struct Q_MULTIMEDIA_EXPORT QAudioEngineFactoryInterface : public QFactoryInterface
{
- virtual QList<QByteArray> deviceList(QAudio::Mode) const = 0;
+ virtual QList<QByteArray> availableDevices(QAudio::Mode) const = 0;
virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0;
virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0;
virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0;
@@ -80,7 +80,7 @@ public:
~QAudioEnginePlugin();
virtual QStringList keys() const = 0;
- virtual QList<QByteArray> deviceList(QAudio::Mode) const = 0;
+ virtual QList<QByteArray> availableDevices(QAudio::Mode) const = 0;
virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0;
virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0;
virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0;
diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp
index 86fe85b7a7..b2bbe144e9 100644
--- a/src/multimedia/audio/qaudioformat.cpp
+++ b/src/multimedia/audio/qaudioformat.cpp
@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
+#include <QDebug>
#include <QtMultimedia/qaudioformat.h>
@@ -214,16 +214,13 @@ bool QAudioFormat::operator!=(const QAudioFormat& other) const
}
/*!
- Returns true if any of the parameters are invalid.
+ Returns true if all of the parameters are valid.
*/
-bool QAudioFormat::isNull() const
+bool QAudioFormat::isValid() const
{
- return d->frequency == -1 && d->channels == -1 &&
- d->sampleSize == -1 &&
- d->byteOrder == QAudioFormat::Endian(QSysInfo::ByteOrder) &&
- d->sampleType == QAudioFormat::Unknown &&
- d->codec.isNull();
+ return d->frequency != -1 && d->channels != -1 && d->sampleSize != -1 &&
+ d->sampleType != QAudioFormat::Unknown && !d->codec.isEmpty();
}
/*!
diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h
index d5841ce722..7e92c2f45d 100644
--- a/src/multimedia/audio/qaudioformat.h
+++ b/src/multimedia/audio/qaudioformat.h
@@ -71,7 +71,7 @@ public:
bool operator==(const QAudioFormat &other) const;
bool operator!=(const QAudioFormat &other) const;
- bool isNull() const;
+ bool isValid() const;
void setFrequency(int frequency);
int frequency() const;
diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp
index 7a3be230f6..e794eafddf 100644
--- a/src/multimedia/audio/qaudioinput.cpp
+++ b/src/multimedia/audio/qaudioinput.cpp
@@ -121,15 +121,15 @@ 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 QAudioInput will enter the \l{QAudio::}{StopState} when
+ enum. The QAudioInput will enter the \l{QAudio::}{StoppedState} when
an error is encountered. Connect to the stateChanged() signal to
handle the error:
@@ -176,37 +176,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
*/
-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);
}
/*!
@@ -225,8 +232,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()
*/
@@ -255,7 +262,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();
@@ -268,7 +275,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
@@ -357,9 +364,9 @@ int QAudioInput::notifyInterval() const
was called in microseconds.
*/
-qint64 QAudioInput::totalTime() const
+qint64 QAudioInput::processedUSecs() const
{
- return d->totalTime();
+ return d->processedUSecs();
}
/*!
@@ -367,9 +374,9 @@ qint64 QAudioInput::totalTime() const
Suspend states.
*/
-qint64 QAudioInput::clock() const
+qint64 QAudioInput::elapsedUSecs() const
{
- return d->clock();
+ return d->elapsedUSecs();
}
/*!
diff --git a/src/multimedia/audio/qaudioinput.h b/src/multimedia/audio/qaudioinput.h
index c8094f5257..bf93a270b7 100644
--- a/src/multimedia/audio/qaudioinput.h
+++ b/src/multimedia/audio/qaudioinput.h
@@ -71,7 +71,9 @@ public:
QAudioFormat format() const;
- QIODevice* start(QIODevice *device = 0);
+ void start(QIODevice *device);
+ QIODevice* start();
+
void stop();
void reset();
void suspend();
@@ -86,8 +88,8 @@ public:
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp
index 9eb8cfb3c8..8a8f0db003 100644
--- a/src/multimedia/audio/qaudioinput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp
@@ -75,7 +75,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor
intervalTime = 1000;
audioBuffer = 0;
errorState = QAudio::NoError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
audioSource = 0;
pullMode = true;
resuming = false;
@@ -206,7 +206,7 @@ int QAudioInputPrivate::setFormat()
QIODevice* QAudioInputPrivate::start(QIODevice* device)
{
- if(deviceState != QAudio::StopState)
+ if(deviceState != QAudio::StoppedState)
close();
if(!pullMode && audioSource) {
@@ -234,10 +234,10 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
void QAudioInputPrivate::stop()
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
return;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
close();
emit stateChanged(deviceState);
@@ -283,7 +283,7 @@ bool QAudioInputPrivate::open()
}
if (( err < 0)||(handle == 0)) {
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
return false;
}
@@ -367,7 +367,7 @@ bool QAudioInputPrivate::open()
if( err < 0) {
qWarning()<<errMessage;
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
return false;
}
@@ -413,7 +413,7 @@ bool QAudioInputPrivate::open()
void QAudioInputPrivate::close()
{
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
timer->stop();
if ( handle ) {
@@ -490,7 +490,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
if(l < 0) {
close();
errorState = QAudio::IOError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
} else if(l == 0) {
errorState = QAudio::NoError;
@@ -508,7 +508,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
void QAudioInputPrivate::resume()
{
- if(deviceState == QAudio::SuspendState) {
+ if(deviceState == QAudio::SuspendedState) {
int err = 0;
if(handle) {
@@ -558,7 +558,7 @@ int QAudioInputPrivate::notifyInterval() const
return intervalTime;
}
-qint64 QAudioInputPrivate::totalTime() const
+qint64 QAudioInputPrivate::processedUSecs() const
{
return totalTimeValue;
}
@@ -567,14 +567,14 @@ void QAudioInputPrivate::suspend()
{
if(deviceState == QAudio::ActiveState||resuming) {
timer->stop();
- deviceState = QAudio::SuspendState;
+ deviceState = QAudio::SuspendedState;
emit stateChanged(deviceState);
}
}
void QAudioInputPrivate::userFeed()
{
- if(deviceState == QAudio::StopState || deviceState == QAudio::SuspendState)
+ if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState)
return;
#ifdef DEBUG_AUDIO
QTime now(QTime::currentTime());
@@ -606,12 +606,12 @@ bool QAudioInputPrivate::deviceReady()
return true;
}
-qint64 QAudioInputPrivate::clock() const
+qint64 QAudioInputPrivate::elapsedUSecs() const
{
if(!handle)
return 0;
- if (deviceState == QAudio::StopState)
+ if (deviceState == QAudio::StoppedState)
return 0;
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
diff --git a/src/multimedia/audio/qaudioinput_alsa_p.h b/src/multimedia/audio/qaudioinput_alsa_p.h
index 2ed74532df..67d5cf55e1 100644
--- a/src/multimedia/audio/qaudioinput_alsa_p.h
+++ b/src/multimedia/audio/qaudioinput_alsa_p.h
@@ -91,8 +91,8 @@ public:
int bufferSize() const;
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
QAudioFormat format() const;
diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp
index cb059206a6..d63045fc74 100644
--- a/src/multimedia/audio/qaudioinput_mac_p.cpp
+++ b/src/multimedia/audio/qaudioinput_mac_p.cpp
@@ -526,7 +526,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device, QAudioFormat co
internalBufferSize = default_buffer_size;
clockFrequency = AudioGetHostClockFrequency() / 1000;
errorCode = QAudio::NoError;
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
intervalTimer = new QTimer(this);
intervalTimer->setInterval(1000);
@@ -708,7 +708,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
QIODevice* op = device;
if (!open()) {
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
errorCode = QAudio::OpenError;
return audioIO;
}
@@ -736,12 +736,12 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
void QAudioInputPrivate::stop()
{
QMutexLocker lock(&mutex);
- if (stateCode != QAudio::StopState) {
+ if (stateCode != QAudio::StoppedState) {
audioThreadStop();
audioBuffer->flush(true);
errorCode = QAudio::NoError;
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode));
}
}
@@ -749,11 +749,11 @@ void QAudioInputPrivate::stop()
void QAudioInputPrivate::reset()
{
QMutexLocker lock(&mutex);
- if (stateCode != QAudio::StopState) {
+ if (stateCode != QAudio::StoppedState) {
audioThreadStop();
errorCode = QAudio::NoError;
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode));
}
}
@@ -765,7 +765,7 @@ void QAudioInputPrivate::suspend()
audioThreadStop();
errorCode = QAudio::NoError;
- stateCode = QAudio::SuspendState;
+ stateCode = QAudio::SuspendedState;
QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode));
}
}
@@ -773,7 +773,7 @@ void QAudioInputPrivate::suspend()
void QAudioInputPrivate::resume()
{
QMutexLocker lock(&mutex);
- if (stateCode == QAudio::SuspendState) {
+ if (stateCode == QAudio::SuspendedState) {
audioThreadStart();
errorCode = QAudio::NoError;
@@ -812,14 +812,14 @@ int QAudioInputPrivate::notifyInterval() const
return intervalTimer->interval();
}
-qint64 QAudioInputPrivate::totalTime() const
+qint64 QAudioInputPrivate::processedUSecs() const
{
return totalFrames * 1000000 / audioFormat.frequency();
}
-qint64 QAudioInputPrivate::clock() const
+qint64 QAudioInputPrivate::elapsedUSecs() const
{
- if (stateCode == QAudio::StopState)
+ if (stateCode == QAudio::StoppedState)
return 0;
return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000);
@@ -875,7 +875,7 @@ void QAudioInputPrivate::audioDeviceError()
audioDeviceStop();
errorCode = QAudio::IOError;
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection);
}
}
diff --git a/src/multimedia/audio/qaudioinput_mac_p.h b/src/multimedia/audio/qaudioinput_mac_p.h
index a080648a2e..2dbb808d20 100644
--- a/src/multimedia/audio/qaudioinput_mac_p.h
+++ b/src/multimedia/audio/qaudioinput_mac_p.h
@@ -129,8 +129,8 @@ public:
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index a059e76a21..b7f9ffd823 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -71,7 +71,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor
totalTimeValue = 0;
intervalTime = 1000;
errorState = QAudio::NoError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
audioSource = 0;
pullMode = true;
resuming = false;
@@ -173,7 +173,7 @@ QAudioFormat QAudioInputPrivate::format() const
QIODevice* QAudioInputPrivate::start(QIODevice* device)
{
- if(deviceState != QAudio::StopState)
+ if(deviceState != QAudio::StoppedState)
close();
if(!pullMode && audioSource) {
@@ -201,7 +201,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
void QAudioInputPrivate::stop()
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
return;
close();
@@ -260,7 +260,7 @@ bool QAudioInputPrivate::open()
(DWORD_PTR) this,
CALLBACK_FUNCTION) != MMSYSERR_NOERROR) {
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
qWarning("QAudioInput: failed to open audio device");
return false;
@@ -269,7 +269,7 @@ bool QAudioInputPrivate::open()
if(waveBlocks == 0) {
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
qWarning("QAudioInput: failed to allocate blocks. open failed");
return false;
@@ -286,7 +286,7 @@ bool QAudioInputPrivate::open()
if(result != MMSYSERR_NOERROR) {
qWarning("QAudioInput: failed to setup block %d,err=%d",i,result);
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
return false;
}
@@ -295,7 +295,7 @@ bool QAudioInputPrivate::open()
if(result) {
qWarning("QAudioInput: failed to start audio input");
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
return false;
}
@@ -309,12 +309,12 @@ bool QAudioInputPrivate::open()
void QAudioInputPrivate::close()
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
return;
waveInReset(hWaveIn);
waveInClose(hWaveIn);
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
int count = 0;
while(!finished && count < 100) {
@@ -333,6 +333,9 @@ void QAudioInputPrivate::close()
int QAudioInputPrivate::bytesReady() const
{
+ if(period_size == 0 || buffer_size == 0)
+ return 0;
+
int buf = ((buffer_size/period_size)-waveFreeBlockCount)*period_size;
if(buf < 0)
buf = 0;
@@ -400,14 +403,14 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
if(result != MMSYSERR_NOERROR) {
qWarning("QAudioInput: failed to prepare block %d,err=%d",header,result);
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
}
result = waveInAddBuffer(hWaveIn, &waveBlocks[header], sizeof(WAVEHDR));
if(result != MMSYSERR_NOERROR) {
qWarning("QAudioInput: failed to setup block %d,err=%d",header,result);
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
}
header++;
@@ -435,14 +438,14 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
void QAudioInputPrivate::resume()
{
- if(deviceState == QAudio::SuspendState) {
+ if(deviceState == QAudio::SuspendedState) {
deviceState = QAudio::ActiveState;
for(int i=0; i<buffer_size/period_size; i++) {
result = waveInAddBuffer(hWaveIn, &waveBlocks[i], sizeof(WAVEHDR));
if(result != MMSYSERR_NOERROR) {
qWarning("QAudioInput: failed to setup block %d,err=%d",i,result);
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
return;
}
@@ -488,7 +491,7 @@ int QAudioInputPrivate::notifyInterval() const
return intervalTime;
}
-qint64 QAudioInputPrivate::totalTime() const
+qint64 QAudioInputPrivate::processedUSecs() const
{
return totalTimeValue;
}
@@ -497,7 +500,7 @@ void QAudioInputPrivate::suspend()
{
if(deviceState == QAudio::ActiveState) {
waveInReset(hWaveIn);
- deviceState = QAudio::SuspendState;
+ deviceState = QAudio::SuspendedState;
emit stateChanged(deviceState);
}
}
@@ -510,7 +513,7 @@ void QAudioInputPrivate::feedback()
#endif
bytesAvailable = bytesReady();
- if(!(deviceState==QAudio::StopState||deviceState==QAudio::SuspendState))
+ if(!(deviceState==QAudio::StoppedState||deviceState==QAudio::SuspendedState))
emit processMore();
}
@@ -539,9 +542,9 @@ bool QAudioInputPrivate::deviceReady()
return true;
}
-qint64 QAudioInputPrivate::clock() const
+qint64 QAudioInputPrivate::elapsedUSecs() const
{
- if (deviceState == QAudio::StopState)
+ if (deviceState == QAudio::StoppedState)
return 0;
return timeStampOpened.elapsed()*1000;
diff --git a/src/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h
index 26c470d3ba..a2bd6876f1 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.h
+++ b/src/multimedia/audio/qaudioinput_win32_p.h
@@ -91,8 +91,8 @@ public:
int bufferSize() const;
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp
index 81b949632e..f8f2fa1a33 100644
--- a/src/multimedia/audio/qaudiooutput.cpp
+++ b/src/multimedia/audio/qaudiooutput.cpp
@@ -125,12 +125,12 @@ QT_BEGIN_NAMESPACE
not emitted. A typical use-case would be to update a
\l{QSlider}{slider} that allows seeking in the stream.
If you want the time since playback started regardless of which
- states the audio output has been in, clock() is the function for you.
+ states the audio output has been in, elapsedUSecs() is the function for you.
If an error occurs, you can fetch the \l{QAudio::Error}{error
type} with the error() function. Please see the QAudio::Error enum
for a description of the possible errors that are reported. When
- an error is encountered, the state changes to QAudio::StopState.
+ an error is encountered, the state changes to QAudio::StoppedState.
You can check for errors by connecting to the stateChanged()
signal:
@@ -188,36 +188,42 @@ QAudioFormat QAudioOutput::format() const
/*!
Uses the \a device as the QIODevice to transfer data.
- If \a device is null then the class creates an internal QIODevice.
- Returns a pointer to the QIODevice being used to handle the data
- transfer. This QIODevice can be used to write() 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
*/
-QIODevice* QAudioOutput::start(QIODevice* device)
+void QAudioOutput::start(QIODevice* device)
{
/*
- PULL MODE (valid QIODevice)
- -If currently not StopState, stop.
+ -If currently not StoppedState, stop.
-If previous start was push mode, delete internal QIODevice.
-open audio output.
- -If ok, NoError and ActiveState, else OpenError and StopState
+ -If ok, NoError and ActiveState, else OpenError and StoppedState
-emit stateChanged()
- -return device
+ */
+ d->start(device);
+}
+
+/*!
+ Returns a pointer to the QIODevice being used to handle the data
+ transfer. This QIODevice can be used to write() audio data directly.
- PUSH MODE (device = 0)
- -If currently not StopState, stop.
+ \sa QIODevice
+*/
+
+QIODevice* QAudioOutput::start()
+{
+ /*
+ -If currently not StoppedState, stop.
-If no internal QIODevice, create one.
-open audio output.
- -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);
}
/*!
@@ -227,8 +233,8 @@ QIODevice* QAudioOutput::start(QIODevice* device)
void QAudioOutput::stop()
{
/*
- -If StopState, return
- -set to StopState
+ -If StoppedState, return
+ -set to StoppedState
-detach from audio device
-emit stateChanged()
*/
@@ -257,7 +263,7 @@ void QAudioOutput::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();
@@ -270,7 +276,7 @@ void QAudioOutput::suspend()
void QAudioOutput::resume()
{
/*
- -If SuspendState, return
+ -If SuspendedState, return
-resume audio
-(PULL MODE): set ActiveState, NoError
-(PUSH MODE): set IdleState, NoError
@@ -358,9 +364,9 @@ int QAudioOutput::notifyInterval() const
was called in microseconds.
*/
-qint64 QAudioOutput::totalTime() const
+qint64 QAudioOutput::processedUSecs() const
{
- return d->totalTime();
+ return d->processedUSecs();
}
/*!
@@ -368,9 +374,9 @@ qint64 QAudioOutput::totalTime() const
Suspend states.
*/
-qint64 QAudioOutput::clock() const
+qint64 QAudioOutput::elapsedUSecs() const
{
- return d->clock();
+ return d->elapsedUSecs();
}
/*!
diff --git a/src/multimedia/audio/qaudiooutput.h b/src/multimedia/audio/qaudiooutput.h
index bb3496e246..38bab8eefa 100644
--- a/src/multimedia/audio/qaudiooutput.h
+++ b/src/multimedia/audio/qaudiooutput.h
@@ -71,7 +71,9 @@ public:
QAudioFormat format() const;
- QIODevice* start(QIODevice *device = 0);
+ void start(QIODevice *device);
+ QIODevice* start();
+
void stop();
void reset();
void suspend();
@@ -86,8 +88,8 @@ public:
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
index 689da89050..e9784d28d8 100644
--- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
@@ -77,7 +77,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF
intervalTime = 1000;
audioBuffer = 0;
errorState = QAudio::NoError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
audioSource = 0;
pullMode = true;
resuming = false;
@@ -215,8 +215,8 @@ int QAudioOutputPrivate::setFormat()
QIODevice* QAudioOutputPrivate::start(QIODevice* device)
{
- if(deviceState != QAudio::StopState)
- deviceState = QAudio::StopState;
+ if(deviceState != QAudio::StoppedState)
+ deviceState = QAudio::StoppedState;
errorState = QAudio::NoError;
@@ -256,9 +256,9 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device)
void QAudioOutputPrivate::stop()
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
return;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
close();
emit stateChanged(deviceState);
}
@@ -304,7 +304,7 @@ bool QAudioOutputPrivate::open()
}
if (( err < 0)||(handle == 0)) {
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
return false;
}
snd_pcm_nonblock( handle, 0 );
@@ -387,7 +387,7 @@ bool QAudioOutputPrivate::open()
if( err < 0) {
qWarning()<<errMessage;
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
return false;
}
snd_pcm_hw_params_get_buffer_size(hwparams,&buffer_frames);
@@ -431,7 +431,7 @@ bool QAudioOutputPrivate::open()
void QAudioOutputPrivate::close()
{
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
timer->stop();
if ( handle ) {
@@ -494,7 +494,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len )
if(err < 0) {
close();
errorState = QAudio::FatalError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
}
return 0;
@@ -507,7 +507,7 @@ int QAudioOutputPrivate::periodSize() const
void QAudioOutputPrivate::setBufferSize(int value)
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
buffer_size = value;
}
@@ -529,14 +529,14 @@ int QAudioOutputPrivate::notifyInterval() const
return intervalTime;
}
-qint64 QAudioOutputPrivate::totalTime() const
+qint64 QAudioOutputPrivate::processedUSecs() const
{
return totalTimeValue;
}
void QAudioOutputPrivate::resume()
{
- if(deviceState == QAudio::SuspendState) {
+ if(deviceState == QAudio::SuspendedState) {
int err = 0;
if(handle) {
@@ -571,7 +571,7 @@ void QAudioOutputPrivate::suspend()
{
if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState || resuming) {
timer->stop();
- deviceState = QAudio::SuspendState;
+ deviceState = QAudio::SuspendedState;
errorState = QAudio::NoError;
emit stateChanged(deviceState);
}
@@ -579,7 +579,7 @@ void QAudioOutputPrivate::suspend()
void QAudioOutputPrivate::userFeed()
{
- if(deviceState == QAudio::StopState || deviceState == QAudio::SuspendState)
+ if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState)
return;
#ifdef DEBUG_AUDIO
QTime now(QTime::currentTime());
@@ -658,12 +658,12 @@ bool QAudioOutputPrivate::deviceReady()
return true;
}
-qint64 QAudioOutputPrivate::clock() const
+qint64 QAudioOutputPrivate::elapsedUSecs() const
{
if(!handle)
return 0;
- if (deviceState == QAudio::StopState)
+ if (deviceState == QAudio::StoppedState)
return 0;
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.h b/src/multimedia/audio/qaudiooutput_alsa_p.h
index 298e89e4e9..619ecefc67 100644
--- a/src/multimedia/audio/qaudiooutput_alsa_p.h
+++ b/src/multimedia/audio/qaudiooutput_alsa_p.h
@@ -91,8 +91,8 @@ public:
int bufferSize() const;
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
QAudioFormat format() const;
diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp
index f23db80735..e0651bf4c0 100644
--- a/src/multimedia/audio/qaudiooutput_mac_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp
@@ -288,7 +288,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device, const QAudioF
internalBufferSize = default_buffer_size;
clockFrequency = AudioGetHostClockFrequency() / 1000;
errorCode = QAudio::NoError;
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
audioThreadState = Stopped;
intervalTimer = new QTimer(this);
@@ -436,7 +436,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device)
QIODevice* op = device;
if (!open()) {
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
errorCode = QAudio::OpenError;
return audioIO;
}
@@ -468,10 +468,10 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device)
void QAudioOutputPrivate::stop()
{
QMutexLocker lock(&mutex);
- if (stateCode != QAudio::StopState) {
+ if (stateCode != QAudio::StoppedState) {
audioThreadDrain();
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
errorCode = QAudio::NoError;
QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode));
}
@@ -480,10 +480,10 @@ void QAudioOutputPrivate::stop()
void QAudioOutputPrivate::reset()
{
QMutexLocker lock(&mutex);
- if (stateCode != QAudio::StopState) {
+ if (stateCode != QAudio::StoppedState) {
audioThreadStop();
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
errorCode = QAudio::NoError;
QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode));
}
@@ -495,7 +495,7 @@ void QAudioOutputPrivate::suspend()
if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) {
audioThreadStop();
- stateCode = QAudio::SuspendState;
+ stateCode = QAudio::SuspendedState;
errorCode = QAudio::NoError;
QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode));
}
@@ -504,7 +504,7 @@ void QAudioOutputPrivate::suspend()
void QAudioOutputPrivate::resume()
{
QMutexLocker lock(&mutex);
- if (stateCode == QAudio::SuspendState) {
+ if (stateCode == QAudio::SuspendedState) {
audioThreadStart();
stateCode = QAudio::ActiveState;
@@ -525,7 +525,7 @@ int QAudioOutputPrivate::periodSize() const
void QAudioOutputPrivate::setBufferSize(int bs)
{
- if (stateCode == QAudio::StopState)
+ if (stateCode == QAudio::StoppedState)
internalBufferSize = bs;
}
@@ -544,14 +544,14 @@ int QAudioOutputPrivate::notifyInterval() const
return intervalTimer->interval();
}
-qint64 QAudioOutputPrivate::totalTime() const
+qint64 QAudioOutputPrivate::processedUSecs() const
{
return totalFrames * 1000000 / audioFormat.frequency();
}
-qint64 QAudioOutputPrivate::clock() const
+qint64 QAudioOutputPrivate::elapsedUSecs() const
{
- if (stateCode == QAudio::StopState)
+ if (stateCode == QAudio::StoppedState)
return 0;
return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000);
@@ -614,7 +614,7 @@ void QAudioOutputPrivate::audioDeviceError()
audioDeviceStop();
errorCode = QAudio::IOError;
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection);
}
}
diff --git a/src/multimedia/audio/qaudiooutput_mac_p.h b/src/multimedia/audio/qaudiooutput_mac_p.h
index 04b3239f36..76d06a9bf6 100644
--- a/src/multimedia/audio/qaudiooutput_mac_p.h
+++ b/src/multimedia/audio/qaudiooutput_mac_p.h
@@ -128,8 +128,8 @@ public:
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index 1810ed2fd5..2cfc472d65 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -71,7 +71,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF
intervalTime = 1000;
audioBuffer = 0;
errorState = QAudio::NoError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
audioSource = 0;
pullMode = true;
finished = false;
@@ -157,7 +157,7 @@ QAudioFormat QAudioOutputPrivate::format() const
QIODevice* QAudioOutputPrivate::start(QIODevice* device)
{
- if(deviceState != QAudio::StopState)
+ if(deviceState != QAudio::StoppedState)
close();
if(!pullMode && audioSource) {
@@ -187,7 +187,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device)
void QAudioOutputPrivate::stop()
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
return;
close();
if(!pullMode && audioSource) {
@@ -255,7 +255,7 @@ bool QAudioOutputPrivate::open()
(DWORD_PTR) this,
CALLBACK_FUNCTION) != MMSYSERR_NOERROR) {
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
qWarning("QAudioOutput: open error");
return false;
@@ -277,10 +277,10 @@ bool QAudioOutputPrivate::open()
void QAudioOutputPrivate::close()
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
return;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
int delay = (buffer_size-bytesFree())*1000/(settings.frequency()
*settings.channels()*(settings.sampleSize()/8));
waveOutReset(hWaveOut);
@@ -308,7 +308,7 @@ int QAudioOutputPrivate::periodSize() const
void QAudioOutputPrivate::setBufferSize(int value)
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
buffer_size = value;
}
@@ -330,7 +330,7 @@ int QAudioOutputPrivate::notifyInterval() const
return intervalTime;
}
-qint64 QAudioOutputPrivate::totalTime() const
+qint64 QAudioOutputPrivate::processedUSecs() const
{
return totalTimeValue;
}
@@ -390,7 +390,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len )
void QAudioOutputPrivate::resume()
{
- if(deviceState == QAudio::SuspendState) {
+ if(deviceState == QAudio::SuspendedState) {
deviceState = QAudio::ActiveState;
errorState = QAudio::NoError;
waveOutRestart(hWaveOut);
@@ -403,7 +403,7 @@ void QAudioOutputPrivate::suspend()
{
if(deviceState == QAudio::ActiveState) {
waveOutPause(hWaveOut);
- deviceState = QAudio::SuspendState;
+ deviceState = QAudio::SuspendedState;
errorState = QAudio::NoError;
emit stateChanged(deviceState);
}
@@ -417,7 +417,7 @@ void QAudioOutputPrivate::feedback()
#endif
bytesAvailable = bytesFree();
- if(!(deviceState==QAudio::StopState||deviceState==QAudio::SuspendState)) {
+ if(!(deviceState==QAudio::StoppedState||deviceState==QAudio::SuspendedState)) {
if(bytesAvailable >= period_size)
QMetaObject::invokeMethod(this, "deviceReady", Qt::QueuedConnection);
}
@@ -491,9 +491,9 @@ bool QAudioOutputPrivate::deviceReady()
return true;
}
-qint64 QAudioOutputPrivate::clock() const
+qint64 QAudioOutputPrivate::elapsedUSecs() const
{
- if (deviceState == QAudio::StopState)
+ if (deviceState == QAudio::StoppedState)
return 0;
return timeStampOpened.elapsed()*1000;
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h
index bcf8e1e752..f90b8c2e33 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.h
+++ b/src/multimedia/audio/qaudiooutput_win32_p.h
@@ -90,8 +90,8 @@ public:
int bufferSize() const;
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;