summaryrefslogtreecommitdiff
path: root/src/multimedia/audio/qaudiosystem.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-12-16 14:19:22 +0100
committerLars Knoll <lars.knoll@qt.io>2021-01-20 15:12:11 +0000
commit494c116bf1248fd74bf800785c50673aff2a47fc (patch)
tree95a2696804b64e9ba46f7d8943f13d867c232466 /src/multimedia/audio/qaudiosystem.cpp
parentf16dbe174cee73308cae2aae512fe837e07e0f55 (diff)
downloadqtmultimedia-494c116bf1248fd74bf800785c50673aff2a47fc.tar.gz
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/qaudiosystem.cpp')
-rw-r--r--src/multimedia/audio/qaudiosystem.cpp90
1 files changed, 88 insertions, 2 deletions
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"