QAudioSystemPlugin Class | Qt Multimedia 5.9

Qt 5.9 | Qt Multimedia | C++ Classes | QAudioSystemPlugin

Qt 5.9.3 Reference Documentation

# QAudioSystemPlugin Class

The QAudioSystemPlugin class provides an abstract base for audio plugins. More...

Header: | #include <QAudioSystemPlugin>
qmake: | QT += multimedia
Inherits: | QObject and QAudioSystemFactoryInterface

- List of all members, including inherited members

## Public Functions

| QAudioSystemPlugin(QObject *parent = Q_NULLPTR)
| ~QAudioSystemPlugin()

## Reimplemented Public Functions

virtual QList<QByteArray> | availableDevices(QAudio::Mode mode) const override = 0
virtual QAbstractAudioDeviceInfo * | createDeviceInfo(const QByteArray &device, QAudio::Mode mode) override = 0
virtual QAbstractAudioInput * | createInput(const QByteArray &device) override = 0
virtual QAbstractAudioOutput * | createOutput(const QByteArray &device) override = 0

- 32 public functions inherited from QObject
- 4 public functions inherited from QAudioSystemFactoryInterface

### Additional Inherited Members

- 1 property inherited from QObject
- 1 public slot inherited from QObject
- 2 signals inherited from QObject
- 1 public variable inherited from QObject
- 10 static public members inherited from QObject
- 9 protected functions inherited from QObject
- 2 protected variables inherited from QObject

## Detailed Description

The QAudioSystemPlugin class provides an abstract base for audio plugins.

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.

      { "Keys": [ "default" ] }

Unit tests are available to help in debugging new plugins.

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)

See also QAbstractAudioDeviceInfo, QAbstractAudioOutput, and QAbstractAudioInput.

## Member Function Documentation

### QAudioSystemPlugin::QAudioSystemPlugin(QObject *parent = Q_NULLPTR)

Construct a new audio plugin with parent. This is invoked automatically by the Q_PLUGIN_METADATA() macro.

### QAudioSystemPlugin::~QAudioSystemPlugin()

Destroy the audio plugin

You never have to call this explicitly. Qt destroys a plugin automatically when it is no longer used.

### `[override pure virtual]` QList<QByteArray> QAudioSystemPlugin::availableDevices(QAudio::Mode mode) const

Returns a list of available audio devices for mode

### `[override pure virtual]` QAbstractAudioDeviceInfo *QAudioSystemPlugin::createDeviceInfo(const QByteArray &device, QAudio::Mode mode)

Returns a pointer to a QAbstractAudioDeviceInfo created using device and mode

### `[override pure virtual]` QAbstractAudioInput *QAudioSystemPlugin::createInput(const QByteArray &device)

Returns a pointer to a QAbstractAudioInput created using device identifier

### `[override pure virtual]` QAbstractAudioOutput *QAudioSystemPlugin::createOutput(const QByteArray &device)

Returns a pointer to a QAbstractAudioOutput created using device identifier