QAudioSystemPlugin Class

QAudioSystemPlugin class provides an abstract base for audio plugins. 更多...

头: #include <QAudioSystemPlugin>
qmake: QT += multimedia
继承: QObject and QAudioSystemFactoryInterface

公共函数

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

重实现公共函数

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

额外继承成员

详细描述

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 () 和 createDeviceInfo () then exporting the class with the Q_PLUGIN_METADATA () 宏。

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)

另请参阅 QAbstractAudioDeviceInfo , QAbstractAudioOutput ,和 QAbstractAudioInput .

成员函数文档编制

QAudioSystemPlugin:: QAudioSystemPlugin ( QObject * parent = Q_NULLPTR)

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

QAudioSystemPlugin:: ~QAudioSystemPlugin ()

Destroy the audio plugin

从不需要明确调用这。Qt 自动销毁插件当不再使用时。

[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 )

返回指针指向 QAbstractAudioDeviceInfo created using device and mode

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

返回指针指向 QAbstractAudioInput created using device identifier

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

返回指针指向 QAbstractAudioOutput created using device identifier