diff options
author | Justin McPherson <justin.mcpherson@nokia.com> | 2009-09-24 01:55:52 (GMT) |
---|---|---|
committer | Justin McPherson <justin.mcpherson@nokia.com> | 2009-09-24 02:40:13 (GMT) |
commit | fb50411e4c0c132631f8237933fbb0972fa4c9aa (patch) | |
tree | 89aa19161710ccf0d2c0e11c0494ddef893eb19c /src | |
parent | 609dd32580b1e07213a2b2efdd4d854c34e8f6d7 (diff) | |
download | Qt-fb50411e4c0c132631f8237933fbb0972fa4c9aa.zip Qt-fb50411e4c0c132631f8237933fbb0972fa4c9aa.tar.gz Qt-fb50411e4c0c132631f8237933fbb0972fa4c9aa.tar.bz2 |
AudioService API changes; QString->const QString&, remove QAudioDeviceId use QAudioDeviceInfo.
Reviewed-by: Bill King
Diffstat (limited to 'src')
20 files changed, 274 insertions, 524 deletions
diff --git a/src/multimedia/audio/audio.pri b/src/multimedia/audio/audio.pri index c7fbbb0..c445941 100644 --- a/src/multimedia/audio/audio.pri +++ b/src/multimedia/audio/audio.pri @@ -5,9 +5,7 @@ HEADERS += $$PWD/qaudio.h \ $$PWD/qaudiodeviceinfo.h \ $$PWD/qaudioengineplugin.h \ $$PWD/qaudioengine.h \ - $$PWD/qaudiodevicefactory_p.h \ - $$PWD/qaudiodeviceid.h \ - $$PWD/qaudiodeviceid_p.h + $$PWD/qaudiodevicefactory_p.h SOURCES += $$PWD/qaudio.cpp \ @@ -17,8 +15,7 @@ SOURCES += $$PWD/qaudio.cpp \ $$PWD/qaudioinput.cpp \ $$PWD/qaudioengineplugin.cpp \ $$PWD/qaudioengine.cpp \ - $$PWD/qaudiodevicefactory.cpp \ - $$PWD/qaudiodeviceid.cpp + $$PWD/qaudiodevicefactory.cpp mac { HEADERS += $$PWD/qaudioinput_mac_p.h \ diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp index 9ed1d70..8804fb6 100644 --- a/src/multimedia/audio/qaudiodevicefactory.cpp +++ b/src/multimedia/audio/qaudiodevicefactory.cpp @@ -44,7 +44,6 @@ #include <QtMultimedia/qaudioengineplugin.h> #include <private/qfactoryloader_p.h> #include "qaudiodevicefactory_p.h" -#include "qaudiodeviceid_p.h" #if defined(Q_OS_WIN) #include "qaudiodeviceinfo_win32_p.h" @@ -123,12 +122,12 @@ public: QAudioFormat format() const { return QAudioFormat(); } }; -QList<QAudioDeviceId> QAudioDeviceFactory::deviceList(QAudio::Mode mode) +QList<QAudioDeviceInfo> QAudioDeviceFactory::deviceList(QAudio::Mode mode) { - QList<QAudioDeviceId> devices; + QList<QAudioDeviceInfo> devices; #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - foreach (const QByteArray &handle, QAudioDeviceInfoPrivate::deviceList(mode)) - devices += createDeviceId(QLatin1String("builtin"), mode, handle); + foreach (const QByteArray &handle, QAudioDeviceInfoInternal::deviceList(mode)) + devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode); #endif QFactoryLoader* l = loader(); @@ -136,7 +135,7 @@ QList<QAudioDeviceId> QAudioDeviceFactory::deviceList(QAudio::Mode mode) QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(l->instance(key)); if (plugin) { foreach (QByteArray const& handle, plugin->deviceList(mode)) - devices += createDeviceId(key, mode, handle); + devices << QAudioDeviceInfo(key, handle, mode); } delete plugin; @@ -145,50 +144,51 @@ QList<QAudioDeviceId> QAudioDeviceFactory::deviceList(QAudio::Mode mode) return devices; } -QAudioDeviceId QAudioDeviceFactory::defaultInputDevice() +QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() { QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(QLatin1String("default"))); if (plugin) { QList<QByteArray> list = plugin->deviceList(QAudio::AudioInput); if (list.size() > 0) - return createDeviceId(QLatin1String("default"), QAudio::AudioInput, list.at(0)); + return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput); } #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - return createDeviceId(QLatin1String("builtin"), QAudio::AudioInput, QAudioDeviceInfoPrivate::defaultInputDevice()); + return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultInputDevice(), QAudio::AudioInput); #endif - return QAudioDeviceId(); + return QAudioDeviceInfo(); } -QAudioDeviceId QAudioDeviceFactory::defaultOutputDevice() +QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() { QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(QLatin1String("default"))); if (plugin) { QList<QByteArray> list = plugin->deviceList(QAudio::AudioOutput); if (list.size() > 0) - return createDeviceId(QLatin1String("default"), QAudio::AudioOutput, list.at(0)); + return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); } #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - return createDeviceId(QLatin1String("builtin"), QAudio::AudioOutput, QAudioDeviceInfoPrivate::defaultOutputDevice()); + return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultOutputDevice(), QAudio::AudioOutput); #endif - return QAudioDeviceId(); + return QAudioDeviceInfo(); } -QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(QAudioDeviceId const& id) +QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode) { - if (id.isNull()) - return new QNullDeviceInfo(); + QAbstractAudioDeviceInfo *rc = 0; + #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - if (id.d->key == QLatin1String("builtin")) - return new QAudioDeviceInfoPrivate(id.d->handle, QAudio::Mode(id.d->mode)); + if (realm == QLatin1String("builtin")) + return new QAudioDeviceInfoInternal(handle, mode); #endif - QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(id.d->key)); + QAudioEngineFactoryInterface* plugin = + qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(realm)); if (plugin) - return plugin->createDeviceInfo(id.d->handle, QAudio::Mode(id.d->mode)); + rc = plugin->createDeviceInfo(handle, mode); - return new QNullDeviceInfo(); + return rc == 0 ? new QNullDeviceInfo() : rc; } QAbstractAudioInput* QAudioDeviceFactory::createDefaultInputDevice(QAudioFormat const &format) @@ -201,50 +201,39 @@ QAbstractAudioOutput* QAudioDeviceFactory::createDefaultOutputDevice(QAudioForma return createOutputDevice(defaultOutputDevice(), format); } -QAbstractAudioInput* QAudioDeviceFactory::createInputDevice(QAudioDeviceId const& id, QAudioFormat const &format) +QAbstractAudioInput* QAudioDeviceFactory::createInputDevice(QAudioDeviceInfo const& deviceInfo, QAudioFormat const &format) { - if (id.isNull()) + if (deviceInfo.isNull()) return new QNullInputDevice(); #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - if (id.d->key == QLatin1String("builtin")) { - if(!defaultInputDevice().isNull()) - return new QAudioInputPrivate(id.d->handle, format); - else - return new QNullInputDevice(); - } + if (deviceInfo.realm() == QLatin1String("builtin")) + return new QAudioInputPrivate(deviceInfo.handle(), format); #endif - QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance((id.d->key))); + QAudioEngineFactoryInterface* plugin = + qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(deviceInfo.realm())); if (plugin) - return plugin->createInput(id.d->handle, format); + return plugin->createInput(deviceInfo.handle(), format); return new QNullInputDevice(); } -QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceId const& id, QAudioFormat const &format) +QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceInfo const& deviceInfo, QAudioFormat const &format) { - if (id.isNull()) + if (deviceInfo.isNull()) return new QNullOutputDevice(); #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - if (id.d->key == QLatin1String("builtin")) { - if(!defaultOutputDevice().isNull()) - return new QAudioOutputPrivate(id.d->handle, format); - else - return new QNullOutputDevice(); - } + if (deviceInfo.realm() == QLatin1String("builtin")) + return new QAudioOutputPrivate(deviceInfo.handle(), format); #endif - QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(id.d->key)); + QAudioEngineFactoryInterface* plugin = + qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(deviceInfo.realm())); if (plugin) - return plugin->createOutput(id.d->handle, format); + return plugin->createOutput(deviceInfo.handle(), format); return new QNullOutputDevice(); } -QAudioDeviceId QAudioDeviceFactory::createDeviceId(QString const& key, int mode, QByteArray const& handle) -{ - return QAudioDeviceId(new QAudioDeviceIdPrivate(key, mode, handle)); -} - QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodevicefactory_p.h b/src/multimedia/audio/qaudiodevicefactory_p.h index 8e4cf5a..008e4a8 100644 --- a/src/multimedia/audio/qaudiodevicefactory_p.h +++ b/src/multimedia/audio/qaudiodevicefactory_p.h @@ -57,7 +57,6 @@ #include <QtCore/qbytearray.h> #include <QtCore/qlist.h> -#include <QtMultimedia/qaudiodeviceid.h> #include <QtMultimedia/qaudiodeviceinfo.h> QT_BEGIN_HEADER @@ -68,28 +67,26 @@ QT_MODULE(Multimedia) class QAbstractAudioInput; class QAbstractAudioOutput; - +class QAbstractAudioDeviceInfo; class QAudioDeviceFactory { public: - static QList<QAudioDeviceId> deviceList(QAudio::Mode mode); + static QList<QAudioDeviceInfo> deviceList(QAudio::Mode mode); - static QAudioDeviceId defaultInputDevice(); - static QAudioDeviceId defaultOutputDevice(); + static QAudioDeviceInfo defaultInputDevice(); + static QAudioDeviceInfo defaultOutputDevice(); - static QAbstractAudioDeviceInfo* audioDeviceInfo(QAudioDeviceId const &device); + static QAbstractAudioDeviceInfo* audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); static QAbstractAudioInput* createDefaultInputDevice(QAudioFormat const &format); static QAbstractAudioOutput* createDefaultOutputDevice(QAudioFormat const &format); - static QAbstractAudioInput* createInputDevice(QAudioDeviceId const &device, QAudioFormat const &format); - static QAbstractAudioOutput* createOutputDevice(QAudioDeviceId const &device, QAudioFormat const &format); + static QAbstractAudioInput* createInputDevice(QAudioDeviceInfo const &device, QAudioFormat const &format); + static QAbstractAudioOutput* createOutputDevice(QAudioDeviceInfo const &device, QAudioFormat const &format); static QAbstractAudioInput* createNullInput(); static QAbstractAudioOutput* createNullOutput(); - - static QAudioDeviceId createDeviceId(QString const& key, int mode, QByteArray const& handle); }; QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceid.cpp b/src/multimedia/audio/qaudiodeviceid.cpp deleted file mode 100644 index bdbc580..0000000 --- a/src/multimedia/audio/qaudiodeviceid.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 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 -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** 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.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. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore/qstring.h> -#include <QtCore/qbytearray.h> -#include <QtCore/qdatastream.h> - -#include <QtMultimedia/qaudiodeviceid.h> -#include "qaudiodeviceid_p.h" - - -QT_BEGIN_NAMESPACE - -/*! - \class QAudioDeviceId - \brief The QAudioDeviceId class provides means for identifying a unique input or output device on a system. - - \inmodule QtMultimedia - \ingroup multimedia - \since 4.6 - - \sa QAudioDeviceInfo, QAudioOutput, QAudioInput -*/ - -/*! - Construct a new null QAudioDeviceId. -*/ - -QAudioDeviceId::QAudioDeviceId() -{ -} - -/*! - Copy the QAudDeviceId referenced by \a other. -*/ - -QAudioDeviceId::QAudioDeviceId(const QAudioDeviceId &other): - d(other.d) -{ -} - -/*! - Destroy the QAudioDeviceId. -*/ - -QAudioDeviceId::~QAudioDeviceId() -{ -} - -/*! - Make a copy of the \a other QAudioDeviceId. -*/ - -QAudioDeviceId& QAudioDeviceId::operator=(const QAudioDeviceId &other) -{ - d = other.d; - return *this; -} - -/*! - Compare with the \a other QAudioDeviceId, return true if they are the same; - otherwise false. -*/ - -bool QAudioDeviceId::operator==(const QAudioDeviceId &other) const -{ - return (d.constData() == 0 && other.d.constData() == 0) || - (d.constData() != 0 && other.d.constData() != 0 && - d->key == other.d->key && d->mode == other.d->mode && d->handle == other.d->handle); -} - -/*! - Compare with the \a other QAudioDeviceId, return false if they are the same; - otherwise true. -*/ - -bool QAudioDeviceId::operator!=(const QAudioDeviceId &other) const -{ - return !(*this == other); -} - -/*! - Returns true if this is not a valid QAudioDeviceId; otherwise false. -*/ - -bool QAudioDeviceId::isNull() const -{ - return d.constData() == 0; -} - -/*! - \internal -*/ - -QAudioDeviceId::QAudioDeviceId(QAudioDeviceIdPrivate* data): - d(data) -{ -} - -/*! - \internal -*/ - -QAudioDeviceIdPrivate::QAudioDeviceIdPrivate(QString const& k, int m, QByteArray const& h): - key(k), mode(m), handle(h) -{ -} - -#ifndef QT_NO_DATASTREAM -Q_MULTIMEDIA_EXPORT QDataStream &operator<<(QDataStream &s, const QAudioDeviceId &id) -{ - s << id.d->key << id.d->mode << id.d->handle; - return s; -} - -Q_MULTIMEDIA_EXPORT QDataStream &operator>>(QDataStream &s, QAudioDeviceId &id) -{ - QString key; - int mode; - QByteArray handle; - - s >> key >> mode >> handle; - id = QAudioDeviceId(new QAudioDeviceIdPrivate(key, mode, handle)); - - return s; -} -#endif - - -QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceid.h b/src/multimedia/audio/qaudiodeviceid.h deleted file mode 100644 index 61d0d9a..0000000 --- a/src/multimedia/audio/qaudiodeviceid.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 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 -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** 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.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. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QAUDIODEVICEID_H -#define QAUDIODEVICEID_H - -#include <QtCore/qshareddata.h> -#include <QtCore/qmetatype.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAudioDeviceFactory; -class QAudioDeviceIdPrivate; - -class Q_MULTIMEDIA_EXPORT QAudioDeviceId -{ - friend class QAudioDeviceFactory; - friend Q_MULTIMEDIA_EXPORT QDataStream &operator<<(QDataStream&, const QAudioDeviceId&); - friend Q_MULTIMEDIA_EXPORT QDataStream &operator>>(QDataStream&, QAudioDeviceId&); - -public: - QAudioDeviceId(); - QAudioDeviceId(const QAudioDeviceId &other); - ~QAudioDeviceId(); - - QAudioDeviceId& operator=(const QAudioDeviceId &other); - bool operator==(const QAudioDeviceId &id) const; - bool operator!=(const QAudioDeviceId &id) const; - - bool isNull() const; - -private: - QAudioDeviceId(QAudioDeviceIdPrivate *data); - - QSharedDataPointer<QAudioDeviceIdPrivate> d; -}; - -#ifndef QT_NO_DATASTREAM -Q_MULTIMEDIA_EXPORT QDataStream &operator<<(QDataStream&, const QAudioDeviceId&); -Q_MULTIMEDIA_EXPORT QDataStream &operator>>(QDataStream&, QAudioDeviceId&); -#endif - -QT_END_NAMESPACE - -QT_END_HEADER - -Q_DECLARE_METATYPE(QAudioDeviceId) - - -#endif // QAUDIODEVICEID_H diff --git a/src/multimedia/audio/qaudiodeviceid_p.h b/src/multimedia/audio/qaudiodeviceid_p.h deleted file mode 100644 index 113e1f0..0000000 --- a/src/multimedia/audio/qaudiodeviceid_p.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 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 -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** 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.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. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QAUDIODEVICEIDPRIVATE_H -#define QAUDIODEVICEIDPRIVATE_H - -#include <QtCore/qstring.h> -#include <QtCore/qbytearray.h> -#include <QtCore/qshareddata.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAudioDeviceIdPrivate : public QSharedData -{ -public: - QAudioDeviceIdPrivate(QString const& k, int m, QByteArray const& h); - - QString key; - int mode; - QByteArray handle; -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIODEVICEIDPRIVATE_H diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp index e38a91e..dce2884 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -46,12 +46,52 @@ QT_BEGIN_NAMESPACE +class QAudioDeviceInfoPrivate : public QSharedData +{ +public: + QAudioDeviceInfoPrivate():info(0) {} + QAudioDeviceInfoPrivate(const QString &r, const QByteArray &h, QAudio::Mode m): + realm(r), handle(h), mode(m) + { + info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); + } + + QAudioDeviceInfoPrivate(const QAudioDeviceInfoPrivate &other): + QSharedData(other), + realm(other.realm), handle(other.handle), mode(other.mode) + { + info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); + } + + QAudioDeviceInfoPrivate& operator=(const QAudioDeviceInfoPrivate &other) + { + delete info; + + realm = other.realm; + handle = other.handle; + mode = other.mode; + info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); + return *this; + } + + ~QAudioDeviceInfoPrivate() + { + delete info; + } + + QString realm; + QByteArray handle; + QAudio::Mode mode; + QAbstractAudioDeviceInfo* info; +}; + + /*! \class QAudioDeviceInfo \brief The QAudioDeviceInfo class provides an interface to query audio devices and their functionality. - \inmodule QtMultimedia \ingroup multimedia + \since 4.6 QAudioDeviceInfo lets you query for audio devices--such as sound @@ -77,41 +117,45 @@ QT_BEGIN_NAMESPACE \dots 8 \snippet doc/src/snippets/audio/main.cpp 2 - A QAudioDeviceInfo is constructed with a QAudioDeviceId, which is - an identifier for a physical device. It is used by Qt to construct + A QAudioDeviceInfo is used by Qt to construct classes that communicate with the device--such as - QAudioDeviceInfo, QAudioInput, and QAudioOutput. The static + QAudioInput, and QAudioOutput. The static functions defaultInputDevice(), defaultOutputDevice(), and - deviceList() let you get a hold of the ids for all available - devices. You fetch ids based on whether you will use the device - for input or output; this is specified by the QAudio::Mode enum. - The QAudioDeviceId returned are only valid for the QAudio::Mode. + deviceList() 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. For instance: \code - foreach(QAudioDeviceId audioId, QAudioDeviceInfo::deviceList(QAudio::AudioOutput)) { - QAudioDeviceInfo info(audioId); - qDebug() << "Device name: " << info.deviceName(); - } + foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(QAudio::AudioOutput)) + qDebug() << "Device name: " << deviceInfo.deviceName(); \endcode In this code sample, we loop through all devices that are able to output sound, i.e., play an audio stream in a supported format. For each device we find, we simply print the deviceName(). - \sa QAudioOutput, QAudioInput, QAudioDeviceId + \sa QAudioOutput, QAudioInput */ /*! - Construct a new audio device info and attach it to \a parent. - Using the audio device with the specified \a id. + Constructs an empty QAudioDeviceInfo object. */ -QAudioDeviceInfo::QAudioDeviceInfo(const QAudioDeviceId &id, QObject *parent): - QObject(parent) +QAudioDeviceInfo::QAudioDeviceInfo(): + d(new QAudioDeviceInfoPrivate) +{ +} + +/*! + Constructs a copy of \a other. +*/ + +QAudioDeviceInfo::QAudioDeviceInfo(const QAudioDeviceInfo& other): + d(other.d) { - d = QAudioDeviceFactory::audioDeviceInfo(id); } /*! @@ -120,7 +164,25 @@ QAudioDeviceInfo::QAudioDeviceInfo(const QAudioDeviceId &id, QObject *parent): QAudioDeviceInfo::~QAudioDeviceInfo() { - delete d; +} + +/*! + Sets the QAudioDeviceInfo object to be equal to \a other. +*/ + +QAudioDeviceInfo& QAudioDeviceInfo::operator=(const QAudioDeviceInfo &other) +{ + d = other.d; + return *this; +} + +/*! + Returns whether this QAudioDeviceInfo object holds a device definition. +*/ + +bool QAudioDeviceInfo::isNull() const +{ + return d->info == 0; } /*! @@ -135,7 +197,7 @@ QAudioDeviceInfo::~QAudioDeviceInfo() QString QAudioDeviceInfo::deviceName() const { - return d->deviceName(); + return isNull() ? QString() : d->info->deviceName(); } /*! @@ -144,7 +206,7 @@ QString QAudioDeviceInfo::deviceName() const bool QAudioDeviceInfo::isFormatSupported(const QAudioFormat &settings) const { - return d->isFormatSupported(settings); + return isNull() ? false : d->info->isFormatSupported(settings); } /*! @@ -163,7 +225,7 @@ bool QAudioDeviceInfo::isFormatSupported(const QAudioFormat &settings) const QAudioFormat QAudioDeviceInfo::preferredFormat() const { - return d->preferredFormat(); + return isNull() ? QAudioFormat() : d->info->preferredFormat(); } /*! @@ -176,7 +238,7 @@ QAudioFormat QAudioDeviceInfo::preferredFormat() const QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const { - return d->nearestFormat(settings); + return isNull() ? QAudioFormat() : d->info->nearestFormat(settings); } /*! @@ -193,7 +255,7 @@ QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const QStringList QAudioDeviceInfo::supportedCodecs() const { - return d->codecList(); + return isNull() ? QStringList() : d->info->codecList(); } /*! @@ -202,7 +264,7 @@ QStringList QAudioDeviceInfo::supportedCodecs() const QList<int> QAudioDeviceInfo::supportedFrequencies() const { - return d->frequencyList(); + return isNull() ? QList<int>() : d->info->frequencyList(); } /*! @@ -211,7 +273,7 @@ QList<int> QAudioDeviceInfo::supportedFrequencies() const QList<int> QAudioDeviceInfo::supportedChannels() const { - return d->channelsList(); + return isNull() ? QList<int>() : d->info->channelsList(); } /*! @@ -220,7 +282,7 @@ QList<int> QAudioDeviceInfo::supportedChannels() const QList<int> QAudioDeviceInfo::supportedSampleSizes() const { - return d->sampleSizeList(); + return isNull() ? QList<int>() : d->info->sampleSizeList(); } /*! @@ -229,7 +291,7 @@ QList<int> QAudioDeviceInfo::supportedSampleSizes() const QList<QAudioFormat::Endian> QAudioDeviceInfo::supportedByteOrders() const { - return d->byteOrderList(); + return isNull() ? QList<QAudioFormat::Endian>() : d->info->byteOrderList(); } /*! @@ -238,7 +300,7 @@ QList<QAudioFormat::Endian> QAudioDeviceInfo::supportedByteOrders() const QList<QAudioFormat::SampleType> QAudioDeviceInfo::supportedSampleTypes() const { - return d->sampleTypeList(); + return isNull() ? QList<QAudioFormat::SampleType>() : d->info->sampleTypeList(); } /*! @@ -246,7 +308,7 @@ QList<QAudioFormat::SampleType> QAudioDeviceInfo::supportedSampleTypes() const All platform and audio plugin implementations provide a default audio device to use. */ -QAudioDeviceId QAudioDeviceInfo::defaultInputDevice() +QAudioDeviceInfo QAudioDeviceInfo::defaultInputDevice() { return QAudioDeviceFactory::defaultInputDevice(); } @@ -256,7 +318,7 @@ QAudioDeviceId QAudioDeviceInfo::defaultInputDevice() All platform and audio plugin implementations provide a default audio device to use. */ -QAudioDeviceId QAudioDeviceInfo::defaultOutputDevice() +QAudioDeviceInfo QAudioDeviceInfo::defaultOutputDevice() { return QAudioDeviceFactory::defaultOutputDevice(); } @@ -265,10 +327,48 @@ QAudioDeviceId QAudioDeviceInfo::defaultOutputDevice() Returns a list of audio devices that support \a mode. */ -QList<QAudioDeviceId> QAudioDeviceInfo::deviceList(QAudio::Mode mode) +QList<QAudioDeviceInfo> QAudioDeviceInfo::deviceList(QAudio::Mode mode) { return QAudioDeviceFactory::deviceList(mode); } + +/*! + \internal +*/ + +QAudioDeviceInfo::QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode): + d(new QAudioDeviceInfoPrivate(realm, handle, mode)) +{ +} + +/*! + \internal +*/ + +QString QAudioDeviceInfo::realm() const +{ + return d->realm; +} + +/*! + \internal +*/ + +QByteArray QAudioDeviceInfo::handle() const +{ + return d->handle; +} + + +/*! + \internal +*/ + +QAudio::Mode QAudioDeviceInfo::mode() const +{ + return d->mode; +} + QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h index b6adb85..53b9904 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.h +++ b/src/multimedia/audio/qaudiodeviceinfo.h @@ -52,7 +52,7 @@ #include <QtMultimedia/qaudio.h> #include <QtMultimedia/qaudioformat.h> -#include <QtMultimedia/qaudiodeviceid.h> + QT_BEGIN_HEADER @@ -60,17 +60,22 @@ QT_BEGIN_NAMESPACE QT_MODULE(Multimedia) +class QAudioDeviceFactory; -class QAbstractAudioDeviceInfo; - -class Q_MULTIMEDIA_EXPORT QAudioDeviceInfo : public QObject +class QAudioDeviceInfoPrivate; +class Q_MULTIMEDIA_EXPORT QAudioDeviceInfo { - Q_OBJECT + friend class QAudioDeviceFactory; public: - explicit QAudioDeviceInfo(const QAudioDeviceId &id, QObject *parent = 0); + QAudioDeviceInfo(); + QAudioDeviceInfo(const QAudioDeviceInfo& other); ~QAudioDeviceInfo(); + QAudioDeviceInfo& operator=(const QAudioDeviceInfo& other); + + bool isNull() const; + QString deviceName() const; bool isFormatSupported(const QAudioFormat &format) const; @@ -84,19 +89,24 @@ public: QList<QAudioFormat::Endian> supportedByteOrders() const; QList<QAudioFormat::SampleType> supportedSampleTypes() const; - static QAudioDeviceId defaultInputDevice(); - static QAudioDeviceId defaultOutputDevice(); + static QAudioDeviceInfo defaultInputDevice(); + static QAudioDeviceInfo defaultOutputDevice(); - static QList<QAudioDeviceId> deviceList(QAudio::Mode mode); + static QList<QAudioDeviceInfo> deviceList(QAudio::Mode mode); private: - Q_DISABLE_COPY(QAudioDeviceInfo) + QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); + QString realm() const; + QByteArray handle() const; + QAudio::Mode mode() const; - QAbstractAudioDeviceInfo* d; + QSharedDataPointer<QAudioDeviceInfoPrivate> d; }; QT_END_NAMESPACE QT_END_HEADER +Q_DECLARE_METATYPE(QAudioDeviceInfo) + #endif // QAUDIODEVICEINFO_H diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index c944cf0..dc24875 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE -QAudioDeviceInfoPrivate::QAudioDeviceInfoPrivate(QByteArray dev, QAudio::Mode mode) +QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) { handle = 0; @@ -62,17 +62,17 @@ QAudioDeviceInfoPrivate::QAudioDeviceInfoPrivate(QByteArray dev, QAudio::Mode mo this->mode = mode; } -QAudioDeviceInfoPrivate::~QAudioDeviceInfoPrivate() +QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() { close(); } -bool QAudioDeviceInfoPrivate::isFormatSupported(const QAudioFormat& format) const +bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const { return testSettings(format); } -QAudioFormat QAudioDeviceInfoPrivate::preferredFormat() const +QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const { QAudioFormat nearest; if(mode == QAudio::AudioOutput) { @@ -97,7 +97,7 @@ QAudioFormat QAudioDeviceInfoPrivate::preferredFormat() const return nearest; } -QAudioFormat QAudioDeviceInfoPrivate::nearestFormat(const QAudioFormat& format) const +QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) const { if(testSettings(format)) return format; @@ -105,48 +105,48 @@ QAudioFormat QAudioDeviceInfoPrivate::nearestFormat(const QAudioFormat& format) return preferredFormat(); } -QString QAudioDeviceInfoPrivate::deviceName() const +QString QAudioDeviceInfoInternal::deviceName() const { return device; } -QStringList QAudioDeviceInfoPrivate::codecList() +QStringList QAudioDeviceInfoInternal::codecList() { updateLists(); return codecz; } -QList<int> QAudioDeviceInfoPrivate::frequencyList() +QList<int> QAudioDeviceInfoInternal::frequencyList() { updateLists(); return freqz; } -QList<int> QAudioDeviceInfoPrivate::channelsList() +QList<int> QAudioDeviceInfoInternal::channelsList() { updateLists(); return channelz; } -QList<int> QAudioDeviceInfoPrivate::sampleSizeList() +QList<int> QAudioDeviceInfoInternal::sampleSizeList() { updateLists(); return sizez; } -QList<QAudioFormat::Endian> QAudioDeviceInfoPrivate::byteOrderList() +QList<QAudioFormat::Endian> QAudioDeviceInfoInternal::byteOrderList() { updateLists(); return byteOrderz; } -QList<QAudioFormat::SampleType> QAudioDeviceInfoPrivate::sampleTypeList() +QList<QAudioFormat::SampleType> QAudioDeviceInfoInternal::sampleTypeList() { updateLists(); return typez; } -bool QAudioDeviceInfoPrivate::open() +bool QAudioDeviceInfoInternal::open() { int err = 0; QString dev = device; @@ -166,14 +166,14 @@ bool QAudioDeviceInfoPrivate::open() return true; } -void QAudioDeviceInfoPrivate::close() +void QAudioDeviceInfoInternal::close() { if(handle) snd_pcm_close(handle); handle = 0; } -bool QAudioDeviceInfoPrivate::testSettings(const QAudioFormat& format) const +bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const { // Set nearest to closest settings that do work. // See if what is in settings will work (return value). @@ -324,7 +324,7 @@ bool QAudioDeviceInfoPrivate::testSettings(const QAudioFormat& format) const return false; } -void QAudioDeviceInfoPrivate::updateLists() +void QAudioDeviceInfoInternal::updateLists() { // redo all lists based on current settings freqz.clear(); @@ -358,7 +358,7 @@ void QAudioDeviceInfoPrivate::updateLists() close(); } -QList<QByteArray> QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode) +QList<QByteArray> QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) { QAudio::Mode _m; QList<QByteArray> devices; @@ -416,7 +416,7 @@ QList<QByteArray> QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode) return devices; } -QByteArray QAudioDeviceInfoPrivate::defaultInputDevice() +QByteArray QAudioDeviceInfoInternal::defaultInputDevice() { QList<QByteArray> devices = deviceList(QAudio::AudioInput); if(devices.size() == 0) @@ -425,7 +425,7 @@ QByteArray QAudioDeviceInfoPrivate::defaultInputDevice() return QByteArray("default"); } -QByteArray QAudioDeviceInfoPrivate::defaultOutputDevice() +QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() { QList<QByteArray> devices = deviceList(QAudio::AudioOutput); if(devices.size() == 0) diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h index 9990281..10078ca 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h @@ -71,12 +71,12 @@ const unsigned int MAX_SAMPLE_RATES = 5; const unsigned int SAMPLE_RATES[] = { 8000, 11025, 22050, 44100, 48000 }; -class QAudioDeviceInfoPrivate : public QAbstractAudioDeviceInfo +class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo { Q_OBJECT public: - QAudioDeviceInfoPrivate(QByteArray dev,QAudio::Mode mode); - ~QAudioDeviceInfoPrivate(); + QAudioDeviceInfoInternal(QByteArray dev,QAudio::Mode mode); + ~QAudioDeviceInfoInternal(); bool testSettings(const QAudioFormat& format) const; void updateLists(); diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp index 957a5c7..ec07748 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE -QAudioDeviceInfoPrivate::QAudioDeviceInfoPrivate(QByteArray const& handle, QAudio::Mode) +QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray const& handle, QAudio::Mode) { QDataStream ds(handle); quint32 did, tm; @@ -76,12 +76,12 @@ QAudioDeviceInfoPrivate::QAudioDeviceInfoPrivate(QByteArray const& handle, QAudi mode = QAudio::Mode(tm); } -bool QAudioDeviceInfoPrivate::isFormatSupported(const QAudioFormat& format) const +bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const { return format.codec() == QString::fromLatin1("audio/pcm"); } -QAudioFormat QAudioDeviceInfoPrivate::preferredFormat() const +QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const { QAudioFormat rc; @@ -134,7 +134,7 @@ QAudioFormat QAudioDeviceInfoPrivate::preferredFormat() const return rc; } -QAudioFormat QAudioDeviceInfoPrivate::nearestFormat(const QAudioFormat& format) const +QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) const { QAudioFormat rc(format); QAudioFormat target = preferredFormat(); @@ -158,17 +158,17 @@ QAudioFormat QAudioDeviceInfoPrivate::nearestFormat(const QAudioFormat& format) return rc; } -QString QAudioDeviceInfoPrivate::deviceName() const +QString QAudioDeviceInfoInternal::deviceName() const { return name; } -QStringList QAudioDeviceInfoPrivate::codecList() +QStringList QAudioDeviceInfoInternal::codecList() { return QStringList() << QString::fromLatin1("audio/pcm"); } -QList<int> QAudioDeviceInfoPrivate::frequencyList() +QList<int> QAudioDeviceInfoInternal::frequencyList() { QSet<int> rc; @@ -208,7 +208,7 @@ QList<int> QAudioDeviceInfoPrivate::frequencyList() return rc.toList(); } -QList<int> QAudioDeviceInfoPrivate::channelsList() +QList<int> QAudioDeviceInfoInternal::channelsList() { QList<int> rc; @@ -248,17 +248,17 @@ QList<int> QAudioDeviceInfoPrivate::channelsList() return rc; } -QList<int> QAudioDeviceInfoPrivate::sampleSizeList() +QList<int> QAudioDeviceInfoInternal::sampleSizeList() { return QList<int>() << 8 << 16 << 24 << 32 << 64; } -QList<QAudioFormat::Endian> QAudioDeviceInfoPrivate::byteOrderList() +QList<QAudioFormat::Endian> QAudioDeviceInfoInternal::byteOrderList() { return QList<QAudioFormat::Endian>() << QAudioFormat::LittleEndian << QAudioFormat::BigEndian; } -QList<QAudioFormat::SampleType> QAudioDeviceInfoPrivate::sampleTypeList() +QList<QAudioFormat::SampleType> QAudioDeviceInfoInternal::sampleTypeList() { return QList<QAudioFormat::SampleType>() << QAudioFormat::SignedInt << QAudioFormat::UnSignedInt << QAudioFormat::Float; } @@ -296,7 +296,7 @@ static QByteArray get_device_info(AudioDeviceID audioDevice, QAudio::Mode mode) return device; } -QByteArray QAudioDeviceInfoPrivate::defaultInputDevice() +QByteArray QAudioDeviceInfoInternal::defaultInputDevice() { AudioDeviceID audioDevice; UInt32 size = sizeof(audioDevice); @@ -310,7 +310,7 @@ QByteArray QAudioDeviceInfoPrivate::defaultInputDevice() return get_device_info(audioDevice, QAudio::AudioInput); } -QByteArray QAudioDeviceInfoPrivate::defaultOutputDevice() +QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() { AudioDeviceID audioDevice; UInt32 size = sizeof(audioDevice); @@ -324,7 +324,7 @@ QByteArray QAudioDeviceInfoPrivate::defaultOutputDevice() return get_device_info(audioDevice, QAudio::AudioOutput); } -QList<QByteArray> QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode) +QList<QByteArray> QAudioDeviceInfoInternal::deviceList(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 7e8e752..60532a8 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h @@ -62,14 +62,14 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class QAudioDeviceInfoPrivate : public QAbstractAudioDeviceInfo +class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo { public: AudioDeviceID deviceId; QString name; QAudio::Mode mode; - QAudioDeviceInfoPrivate(QByteArray const& handle, QAudio::Mode mode); + QAudioDeviceInfoInternal(QByteArray const& handle, QAudio::Mode mode); bool isFormatSupported(const QAudioFormat& format) const; QAudioFormat preferredFormat() const; diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index ba9f5e2..69d5c94 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -74,23 +74,23 @@ QT_BEGIN_NAMESPACE #endif -QAudioDeviceInfoPrivate::QAudioDeviceInfoPrivate(QByteArray dev, QAudio::Mode mode) +QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) { device = QLatin1String(dev); this->mode = mode; } -QAudioDeviceInfoPrivate::~QAudioDeviceInfoPrivate() +QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() { close(); } -bool QAudioDeviceInfoPrivate::isFormatSupported(const QAudioFormat& format) const +bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const { return testSettings(format); } -QAudioFormat QAudioDeviceInfoPrivate::preferredFormat() const +QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const { QAudioFormat nearest; if(mode == QAudio::AudioOutput) { @@ -110,7 +110,7 @@ QAudioFormat QAudioDeviceInfoPrivate::preferredFormat() const return nearest; } -QAudioFormat QAudioDeviceInfoPrivate::nearestFormat(const QAudioFormat& format) const +QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) const { if(testSettings(format)) return format; @@ -118,58 +118,58 @@ QAudioFormat QAudioDeviceInfoPrivate::nearestFormat(const QAudioFormat& format) return preferredFormat(); } -QString QAudioDeviceInfoPrivate::deviceName() const +QString QAudioDeviceInfoInternal::deviceName() const { return device; } -QStringList QAudioDeviceInfoPrivate::codecList() +QStringList QAudioDeviceInfoInternal::codecList() { updateLists(); return codecz; } -QList<int> QAudioDeviceInfoPrivate::frequencyList() +QList<int> QAudioDeviceInfoInternal::frequencyList() { updateLists(); return freqz; } -QList<int> QAudioDeviceInfoPrivate::channelsList() +QList<int> QAudioDeviceInfoInternal::channelsList() { updateLists(); return channelz; } -QList<int> QAudioDeviceInfoPrivate::sampleSizeList() +QList<int> QAudioDeviceInfoInternal::sampleSizeList() { updateLists(); return sizez; } -QList<QAudioFormat::Endian> QAudioDeviceInfoPrivate::byteOrderList() +QList<QAudioFormat::Endian> QAudioDeviceInfoInternal::byteOrderList() { updateLists(); return byteOrderz; } -QList<QAudioFormat::SampleType> QAudioDeviceInfoPrivate::sampleTypeList() +QList<QAudioFormat::SampleType> QAudioDeviceInfoInternal::sampleTypeList() { updateLists(); return typez; } -bool QAudioDeviceInfoPrivate::open() +bool QAudioDeviceInfoInternal::open() { return true; } -void QAudioDeviceInfoPrivate::close() +void QAudioDeviceInfoInternal::close() { } -bool QAudioDeviceInfoPrivate::testSettings(const QAudioFormat& format) const +bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const { // Set nearest to closest settings that do work. // See if what is in settings will work (return value). @@ -199,7 +199,7 @@ bool QAudioDeviceInfoPrivate::testSettings(const QAudioFormat& format) const return false; } -void QAudioDeviceInfoPrivate::updateLists() +void QAudioDeviceInfoInternal::updateLists() { // redo all lists based on current settings bool base = false; @@ -333,7 +333,7 @@ void QAudioDeviceInfoPrivate::updateLists() } } -QList<QByteArray> QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode) +QList<QByteArray> QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) { Q_UNUSED(mode) @@ -367,12 +367,12 @@ QList<QByteArray> QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode) return devices; } -QByteArray QAudioDeviceInfoPrivate::defaultOutputDevice() +QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() { return QByteArray("default"); } -QByteArray QAudioDeviceInfoPrivate::defaultInputDevice() +QByteArray QAudioDeviceInfoInternal::defaultInputDevice() { return QByteArray("default"); } diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h index 7cf7f45..0d2ee29 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h @@ -68,13 +68,13 @@ QT_BEGIN_NAMESPACE const unsigned int MAX_SAMPLE_RATES = 5; const unsigned int SAMPLE_RATES[] = { 8000, 11025, 22050, 44100, 48000 }; -class QAudioDeviceInfoPrivate : public QAbstractAudioDeviceInfo +class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo { Q_OBJECT public: - QAudioDeviceInfoPrivate(QByteArray dev,QAudio::Mode mode); - ~QAudioDeviceInfoPrivate(); + QAudioDeviceInfoInternal(QByteArray dev,QAudio::Mode mode); + ~QAudioDeviceInfoInternal(); bool open(); void close(); diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index c23e454..86fe85b 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -286,7 +286,7 @@ int QAudioFormat::sampleSize() const \sa QAudioDeviceInfo::supportedCodecs() */ -void QAudioFormat::setCodec(QString codec) +void QAudioFormat::setCodec(const QString &codec) { d->codec = codec; } diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h index 4cd6e23..d5841ce 100644 --- a/src/multimedia/audio/qaudioformat.h +++ b/src/multimedia/audio/qaudioformat.h @@ -82,7 +82,7 @@ public: void setSampleSize(int sampleSize); int sampleSize() const; - void setCodec(QString codec); + void setCodec(const QString &codec); QString codec() const; void setByteOrder(QAudioFormat::Endian byteOrder); diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index 3c0d98e..858846f 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -61,7 +61,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 +69,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. @@ -154,14 +154,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))); } diff --git a/src/multimedia/audio/qaudioinput.h b/src/multimedia/audio/qaudioinput.h index 277a6cf..c8094f5 100644 --- a/src/multimedia/audio/qaudioinput.h +++ b/src/multimedia/audio/qaudioinput.h @@ -48,7 +48,8 @@ #include <QtMultimedia/qaudio.h> #include <QtMultimedia/qaudioformat.h> -#include <QtMultimedia/qaudiodeviceid.h> +#include <QtMultimedia/qaudiodeviceinfo.h> + QT_BEGIN_HEADER @@ -65,7 +66,7 @@ class Q_MULTIMEDIA_EXPORT QAudioInput : public QObject public: explicit QAudioInput(const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); - explicit QAudioInput(const QAudioDeviceId &id, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); + explicit QAudioInput(const QAudioDeviceInfo &audioDeviceInfo, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); ~QAudioInput(); QAudioFormat format() const; diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp index 8a8edb4..3d3f5f5 100644 --- a/src/multimedia/audio/qaudiooutput.cpp +++ b/src/multimedia/audio/qaudiooutput.cpp @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE You can construct an audio output with the system's \l{QAudioDeviceInfo::defaultOutputDevice()}{default audio output device}. It is also possible to create QAudioOutput with a - specific QAudioDeviceId. When you create the audio output, you + specific QAudioDeviceInfo. When you create the audio output, you should also send in the QAudioFormat to be used for the playback (see the QAudioFormat class description for details). @@ -155,14 +155,14 @@ QAudioOutput::QAudioOutput(const QAudioFormat &format, QObject *parent): /*! Construct a new audio output and attach it to \a parent. - The \a id of the audio output device is used with the output + The device referenced by \a audioDevice is used with the output \a format parameters. */ -QAudioOutput::QAudioOutput(const QAudioDeviceId &id, const QAudioFormat &format, QObject *parent): +QAudioOutput::QAudioOutput(const QAudioDeviceInfo &audioDevice, const QAudioFormat &format, QObject *parent): QObject(parent) { - d = QAudioDeviceFactory::createOutputDevice(id, format); + d = QAudioDeviceFactory::createOutputDevice(audioDevice, format); connect(d, SIGNAL(notify()), SIGNAL(notify())); connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); } diff --git a/src/multimedia/audio/qaudiooutput.h b/src/multimedia/audio/qaudiooutput.h index 1ed3d06..bb3496e 100644 --- a/src/multimedia/audio/qaudiooutput.h +++ b/src/multimedia/audio/qaudiooutput.h @@ -48,7 +48,7 @@ #include <QtMultimedia/qaudio.h> #include <QtMultimedia/qaudioformat.h> -#include <QtMultimedia/qaudiodeviceid.h> +#include <QtMultimedia/qaudiodeviceinfo.h> QT_BEGIN_HEADER @@ -66,7 +66,7 @@ class Q_MULTIMEDIA_EXPORT QAudioOutput : public QObject public: explicit QAudioOutput(const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); - explicit QAudioOutput(const QAudioDeviceId &id, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); + explicit QAudioOutput(const QAudioDeviceInfo &audioDeviceInfo, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); ~QAudioOutput(); QAudioFormat format() const; |