diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-12-16 14:19:22 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-01-20 15:12:11 +0000 |
commit | 494c116bf1248fd74bf800785c50673aff2a47fc (patch) | |
tree | 95a2696804b64e9ba46f7d8943f13d867c232466 /src/multimedia/audio | |
parent | f16dbe174cee73308cae2aae512fe837e07e0f55 (diff) |
Shuffle some code around
Move the QAudioSystemInterface class into the qaudiosystem.h
header file and make that one private.
Change-Id: Ib83dceaafcdf418f27264bfa6dbec8a1dafef13b
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/multimedia/audio')
17 files changed, 135 insertions, 230 deletions
diff --git a/src/multimedia/audio/alsa/qalsaaudiodeviceinfo_p.h b/src/multimedia/audio/alsa/qalsaaudiodeviceinfo_p.h index cdf08bfab..94711c539 100644 --- a/src/multimedia/audio/alsa/qalsaaudiodeviceinfo_p.h +++ b/src/multimedia/audio/alsa/qalsaaudiodeviceinfo_p.h @@ -61,7 +61,7 @@ #include <QtMultimedia/qaudio.h> #include <QtMultimedia/qaudiodeviceinfo.h> -#include <QtMultimedia/qaudiosystem.h> +#include <private/qaudiosystem_p.h> QT_BEGIN_NAMESPACE diff --git a/src/multimedia/audio/alsa/qalsaaudioinput_p.h b/src/multimedia/audio/alsa/qalsaaudioinput_p.h index 62e1be039..ee7d5f37c 100644 --- a/src/multimedia/audio/alsa/qalsaaudioinput_p.h +++ b/src/multimedia/audio/alsa/qalsaaudioinput_p.h @@ -64,7 +64,7 @@ #include <QtMultimedia/qaudio.h> #include <QtMultimedia/qaudiodeviceinfo.h> -#include <QtMultimedia/qaudiosystem.h> +#include <private/qaudiosystem_p.h> QT_BEGIN_NAMESPACE diff --git a/src/multimedia/audio/alsa/qalsaaudiooutput_p.h b/src/multimedia/audio/alsa/qalsaaudiooutput_p.h index 72b9c2e4c..df76aba30 100644 --- a/src/multimedia/audio/alsa/qalsaaudiooutput_p.h +++ b/src/multimedia/audio/alsa/qalsaaudiooutput_p.h @@ -63,7 +63,7 @@ #include <QtMultimedia/qaudio.h> #include <QtMultimedia/qaudiodeviceinfo.h> -#include <QtMultimedia/qaudiosystem.h> +#include <private/qaudiosystem_p.h> QT_BEGIN_NAMESPACE diff --git a/src/multimedia/audio/alsa/qalsainterface_p.h b/src/multimedia/audio/alsa/qalsainterface_p.h index 05ade0f68..ce4d7245e 100644 --- a/src/multimedia/audio/alsa/qalsainterface_p.h +++ b/src/multimedia/audio/alsa/qalsainterface_p.h @@ -40,7 +40,18 @@ #ifndef QALSAPLUGIN_H #define QALSAPLUGIN_H -#include <private/qaudiosysteminterface_p.h> +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qaudiosystem_p.h> QT_BEGIN_NAMESPACE diff --git a/src/multimedia/audio/audio.pri b/src/multimedia/audio/audio.pri index 54da659b2..7cd59c804 100644 --- a/src/multimedia/audio/audio.pri +++ b/src/multimedia/audio/audio.pri @@ -7,7 +7,6 @@ PUBLIC_HEADERS += \ audio/qaudioinput.h \ audio/qaudiooutput.h \ audio/qaudiodeviceinfo.h \ - audio/qaudiosystem.h \ audio/qsoundeffect.h \ audio/qaudioprobe.h \ audio/qaudiodecoder.h @@ -17,8 +16,8 @@ PRIVATE_HEADERS += \ audio/qaudiodevicefactory_p.h \ audio/qwavedecoder_p.h \ audio/qsamplecache_p.h \ - audio/qaudiosysteminterface_p.h \ audio/qaudiohelpers_p.h \ + audio/qaudiosystem_p.h \ SOURCES += \ audio/qaudio.cpp \ @@ -26,7 +25,6 @@ SOURCES += \ audio/qaudiodeviceinfo.cpp \ audio/qaudiooutput.cpp \ audio/qaudioinput.cpp \ - audio/qaudiosysteminterface.cpp \ audio/qaudiosystem.cpp \ audio/qaudiodevicefactory.cpp \ audio/qsoundeffect.cpp \ diff --git a/src/multimedia/audio/pulseaudio/qaudiodeviceinfo_pulse_p.h b/src/multimedia/audio/pulseaudio/qaudiodeviceinfo_pulse_p.h index 1cec772c0..6660f82db 100644 --- a/src/multimedia/audio/pulseaudio/qaudiodeviceinfo_pulse_p.h +++ b/src/multimedia/audio/pulseaudio/qaudiodeviceinfo_pulse_p.h @@ -57,7 +57,7 @@ #include "qaudio.h" #include "qaudiodeviceinfo.h" -#include "qaudiosystem.h" +#include <private/qaudiosystem_p.h> QT_BEGIN_NAMESPACE diff --git a/src/multimedia/audio/pulseaudio/qaudioinput_pulse_p.h b/src/multimedia/audio/pulseaudio/qaudioinput_pulse_p.h index dce212a25..9f4df7e5f 100644 --- a/src/multimedia/audio/pulseaudio/qaudioinput_pulse_p.h +++ b/src/multimedia/audio/pulseaudio/qaudioinput_pulse_p.h @@ -60,7 +60,7 @@ #include "qaudio.h" #include "qaudiodeviceinfo.h" -#include "qaudiosystem.h" +#include <private/qaudiosystem_p.h> #include <pulse/pulseaudio.h> diff --git a/src/multimedia/audio/pulseaudio/qaudiointerface_pulse_p.h b/src/multimedia/audio/pulseaudio/qaudiointerface_pulse_p.h index 42f39d4c9..c6988288c 100644 --- a/src/multimedia/audio/pulseaudio/qaudiointerface_pulse_p.h +++ b/src/multimedia/audio/pulseaudio/qaudiointerface_pulse_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <private/qaudiosysteminterface_p.h> +#include <private/qaudiosystem_p.h> QT_BEGIN_NAMESPACE diff --git a/src/multimedia/audio/pulseaudio/qaudiooutput_pulse_p.h b/src/multimedia/audio/pulseaudio/qaudiooutput_pulse_p.h index e11f2ab2f..6f765bc60 100644 --- a/src/multimedia/audio/pulseaudio/qaudiooutput_pulse_p.h +++ b/src/multimedia/audio/pulseaudio/qaudiooutput_pulse_p.h @@ -60,7 +60,7 @@ #include "qaudio.h" #include "qaudiodeviceinfo.h" -#include "qaudiosystem.h" +#include <private/qaudiosystem_p.h> #include <pulse/pulseaudio.h> diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp index c5cd2c098..e4a794ce3 100644 --- a/src/multimedia/audio/qaudiodevicefactory.cpp +++ b/src/multimedia/audio/qaudiodevicefactory.cpp @@ -39,8 +39,7 @@ #include <QtCore/qdebug.h> -#include "qaudiosystem.h" -#include "qaudiosysteminterface_p.h" +#include "qaudiosystem_p.h" #include "qmediapluginloader_p.h" #include "qaudiodevicefactory_p.h" diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp index dcd2c24a9..338dc4973 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -38,7 +38,7 @@ ****************************************************************************/ #include "qaudiodevicefactory_p.h" -#include "qaudiosystem.h" +#include "qaudiosystem_p.h" #include "qaudiodeviceinfo.h" #include <QtCore/qmap.h> diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index 872dce819..e75b85bf9 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -40,7 +40,7 @@ #include "qaudio.h" #include "qaudiodeviceinfo.h" -#include "qaudiosystem.h" +#include "qaudiosystem_p.h" #include "qaudioinput.h" #include "qaudiodevicefactory_p.h" diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp index e37da9bdf..79b713796 100644 --- a/src/multimedia/audio/qaudiooutput.cpp +++ b/src/multimedia/audio/qaudiooutput.cpp @@ -40,7 +40,7 @@ #include "qaudio.h" #include "qaudiodeviceinfo.h" -#include "qaudiosystem.h" +#include "qaudiosystem_p.h" #include "qaudiooutput.h" #include "qaudiodevicefactory_p.h" diff --git a/src/multimedia/audio/qaudiosystem.cpp b/src/multimedia/audio/qaudiosystem.cpp index b11993e55..039ab3061 100644 --- a/src/multimedia/audio/qaudiosystem.cpp +++ b/src/multimedia/audio/qaudiosystem.cpp @@ -37,7 +37,14 @@ ** ****************************************************************************/ -#include "qaudiosystem.h" +#include <private/qtmultimediaglobal_p.h> +#include "qaudiosystem_p.h" + +#if QT_CONFIG(pulseaudio) +#include <private/qaudiointerface_pulse_p.h> +#elif QT_CONFIG(alsa) +#include <private/qalsainterface_p.h> +#endif QT_BEGIN_NAMESPACE @@ -371,6 +378,85 @@ QT_BEGIN_NAMESPACE */ +/*! + \class QAudioSystemInterface + \internal + \brief The QAudioSystemInterface class provides an abstract base for audio plugins. + + \ingroup multimedia + \ingroup multimedia_audio + \inmodule QtMultimedia + + Writing a audio plugin is achieved by subclassing this base class, + reimplementing the pure virtual functions availableDevices(), + createInput(), createOutput() and createDeviceInfo() then exporting + the class with the Q_PLUGIN_METADATA() macro. + + The json file containing the meta data should contain a list of keys + matching the plugin. Add "default" to your list of keys available + to override the default audio device to be provided by your plugin. + + \code + { "Keys": [ "default" ] } + \endcode + + Unit tests are available to help in debugging new plugins. + + \sa QAbstractAudioDeviceInfo, QAbstractAudioOutput, QAbstractAudioInput + + Qt comes with plugins for Windows (WinMM and WASAPI), Linux (ALSA and PulseAudio), \macos / iOS + (CoreAudio), Android (OpenSL ES) and QNX. + + If no audio plugins are available, a fallback dummy backend will be used. + This should print out warnings if this is the case when you try and use QAudioInput + or QAudioOutput. To fix this problem, make sure the dependencies for the Qt plugins are + installed on the system and reconfigure Qt (e.g. alsa-devel package on Linux), or create your + own plugin with a default key to always override the dummy fallback. The easiest way to + determine if you have only a dummy backend is to get a list of available audio devices. + + QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).size() = 0 (dummy backend) +*/ + +QAudioSystemInterface *QAudioSystemInterface::instance() +{ + static QAudioSystemInterface *system = nullptr; + if (!system) { +#if QT_CONFIG(pulseaudio) + system = new QPulseAudioInterface(); +#elif QT_CONFIG(alsa) + system = new QAlsaInterface(); +#endif + } + return system; +} + +QAudioSystemInterface::~QAudioSystemInterface() +{ + +} + +/*! + \fn QList<QByteArray> QAudioSystemInterface::availableDevices(QAudio::Mode mode) const + Returns a list of available audio devices for \a mode +*/ + +/*! + \fn QAbstractAudioInput* QAudioSystemInterface::createInput(const QByteArray& device) + Returns a pointer to a QAbstractAudioInput created using \a device identifier +*/ + +/*! + \fn QAbstractAudioOutput* QAudioSystemInterface::createOutput(const QByteArray& device) + Returns a pointer to a QAbstractAudioOutput created using \a device identifier + +*/ + +/*! + \fn QAbstractAudioDeviceInfo* QAudioSystemInterface::createDeviceInfo(const QByteArray& device, QAudio::Mode mode) + Returns a pointer to a QAbstractAudioDeviceInfo created using \a device and \a mode + +*/ + QT_END_NAMESPACE -#include "moc_qaudiosystem.cpp" +#include "moc_qaudiosystem_p.cpp" diff --git a/src/multimedia/audio/qaudiosystem.h b/src/multimedia/audio/qaudiosystem_p.h index c326460fe..3ac18143d 100644 --- a/src/multimedia/audio/qaudiosystem.h +++ b/src/multimedia/audio/qaudiosystem_p.h @@ -40,6 +40,17 @@ #ifndef QAUDIOSYSTEM_H #define QAUDIOSYSTEM_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtMultimedia/qtmultimediaglobal.h> #include <QtMultimedia/qmultimedia.h> @@ -133,6 +144,18 @@ Q_SIGNALS: void notify(); }; +struct QAudioSystemInterface +{ + static QAudioSystemInterface *instance(); + + virtual ~QAudioSystemInterface(); + virtual QList<QByteArray> availableDevices(QAudio::Mode) const = 0; + virtual QAbstractAudioInput* createInput(const QByteArray& device) = 0; + virtual QAbstractAudioOutput* createOutput(const QByteArray& device) = 0; + virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; + virtual QByteArray defaultDevice(QAudio::Mode) const = 0; +}; + QT_END_NAMESPACE #endif // QAUDIOSYSTEM_H diff --git a/src/multimedia/audio/qaudiosysteminterface.cpp b/src/multimedia/audio/qaudiosysteminterface.cpp deleted file mode 100644 index 90861535d..000000000 --- a/src/multimedia/audio/qaudiosysteminterface.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <private/qtmultimediaglobal_p.h> -#include "qaudiosysteminterface_p.h" - -#if QT_CONFIG(pulseaudio) -#include <private/qaudiointerface_pulse_p.h> -#elif QT_CONFIG(alsa) -#include <private/qalsainterface_p.h> -#endif - -QT_BEGIN_NAMESPACE - -/*! - \class QAudioSystemInterface - \internal - \brief The QAudioSystemInterface class provides an abstract base for audio plugins. - - \ingroup multimedia - \ingroup multimedia_audio - \inmodule QtMultimedia - - Writing a audio plugin is achieved by subclassing this base class, - reimplementing the pure virtual functions availableDevices(), - createInput(), createOutput() and createDeviceInfo() then exporting - the class with the Q_PLUGIN_METADATA() macro. - - The json file containing the meta data should contain a list of keys - matching the plugin. Add "default" to your list of keys available - to override the default audio device to be provided by your plugin. - - \code - { "Keys": [ "default" ] } - \endcode - - Unit tests are available to help in debugging new plugins. - - \sa QAbstractAudioDeviceInfo, QAbstractAudioOutput, QAbstractAudioInput - - Qt comes with plugins for Windows (WinMM and WASAPI), Linux (ALSA and PulseAudio), \macos / iOS - (CoreAudio), Android (OpenSL ES) and QNX. - - If no audio plugins are available, a fallback dummy backend will be used. - This should print out warnings if this is the case when you try and use QAudioInput - or QAudioOutput. To fix this problem, make sure the dependencies for the Qt plugins are - installed on the system and reconfigure Qt (e.g. alsa-devel package on Linux), or create your - own plugin with a default key to always override the dummy fallback. The easiest way to - determine if you have only a dummy backend is to get a list of available audio devices. - - QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).size() = 0 (dummy backend) -*/ - -QAudioSystemInterface *QAudioSystemInterface::instance() -{ - static QAudioSystemInterface *system = nullptr; - if (!system) { -#if QT_CONFIG(pulseaudio) - system = new QPulseAudioInterface(); -#elif QT_CONFIG(alsa) - system = new QAlsaInterface(); -#endif - } - return system; -} - -QAudioSystemInterface::~QAudioSystemInterface() -{ - -} - -/*! - \fn QList<QByteArray> QAudioSystemInterface::availableDevices(QAudio::Mode mode) const - Returns a list of available audio devices for \a mode -*/ - -/*! - \fn QAbstractAudioInput* QAudioSystemInterface::createInput(const QByteArray& device) - Returns a pointer to a QAbstractAudioInput created using \a device identifier -*/ - -/*! - \fn QAbstractAudioOutput* QAudioSystemInterface::createOutput(const QByteArray& device) - Returns a pointer to a QAbstractAudioOutput created using \a device identifier - -*/ - -/*! - \fn QAbstractAudioDeviceInfo* QAudioSystemInterface::createDeviceInfo(const QByteArray& device, QAudio::Mode mode) - Returns a pointer to a QAbstractAudioDeviceInfo created using \a device and \a mode - -*/ - - -QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiosysteminterface_p.h b/src/multimedia/audio/qaudiosysteminterface_p.h deleted file mode 100644 index bc15cda81..000000000 --- a/src/multimedia/audio/qaudiosysteminterface_p.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QAUDIOSYSTEMPLUGIN_H -#define QAUDIOSYSTEMPLUGIN_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qstring.h> -#include <QtCore/qplugin.h> - -#include <QtMultimedia/qtmultimediaglobal.h> -#include <QtMultimedia/qmultimedia.h> - -#include <QtMultimedia/qaudioformat.h> -#include <QtMultimedia/qaudiodeviceinfo.h> -#include <QtMultimedia/qaudiosystem.h> - -QT_BEGIN_NAMESPACE - -struct QAudioSystemInterface -{ - static QAudioSystemInterface *instance(); - - virtual ~QAudioSystemInterface(); - virtual QList<QByteArray> availableDevices(QAudio::Mode) const = 0; - virtual QAbstractAudioInput* createInput(const QByteArray& device) = 0; - virtual QAbstractAudioOutput* createOutput(const QByteArray& device) = 0; - virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; - virtual QByteArray defaultDevice(QAudio::Mode) const = 0; -}; - -QT_END_NAMESPACE - -#endif // QAUDIOSYSTEMPLUGIN_H |