CopperSpice API
1.9.2
|
The QAudioDeviceInfo class provides an interface to query audio devices and their functionality. More...
Public Methods | |
QAudioDeviceInfo () | |
QAudioDeviceInfo (const QAudioDeviceInfo &other) | |
~QAudioDeviceInfo () | |
QString | deviceName () const |
bool | isFormatSupported (const QAudioFormat &format) const |
bool | isNull () const |
QAudioFormat | nearestFormat (const QAudioFormat &format) const |
bool | operator!= (const QAudioDeviceInfo &other) const |
QAudioDeviceInfo & | operator= (const QAudioDeviceInfo &other) |
bool | operator== (const QAudioDeviceInfo &other) const |
QAudioFormat | preferredFormat () const |
QList< QAudioFormat::Endian > | supportedByteOrders () const |
QList< int > | supportedChannelCounts () const |
QStringList | supportedCodecs () const |
QList< int > | supportedSampleRates () const |
QList< int > | supportedSampleSizes () const |
QList< QAudioFormat::SampleType > | supportedSampleTypes () const |
Static Public Methods | |
static QList< QAudioDeviceInfo > | availableDevices (QAudio::Mode mode) |
static QAudioDeviceInfo | defaultInputDevice () |
static QAudioDeviceInfo | defaultOutputDevice () |
The QAudioDeviceInfo class provides an interface to query audio devices and their functionality.
QAudioDeviceInfo lets you query for audio devices such as sound cards and USB headsets that are currently available on the system. The audio devices available are dependent on the platform or audio plugins installed.
You can also query each device for the formats it supports. A format in this context is a set consisting of a specific byte order, channel, codec, frequency, sample rate, and sample type. A format is represented by the QAudioFormat class.
The values supported by the device for each of these parameters can be fetched with supportedByteOrders(), supportedChannelCounts(), supportedCodecs(), supportedSampleRates(), supportedSampleSizes(), and supportedSampleTypes(). The combinations supported are dependent on the platform, audio plugins installed and the audio device capabilities. If you need a specific format, you can check if the device supports it with isFormatSupported(), or fetch a supported format that is as close as possible to the format with nearestFormat(). For instance:
A QAudioDeviceInfo is used by CopperSpice to construct classes that communicate with the device–such as QAudioInput, and QAudioOutput. The static functions defaultInputDevice(), defaultOutputDevice(), and availableDevices() 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:
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().
QAudioDeviceInfo::QAudioDeviceInfo | ( | ) |
Constructs an empty QAudioDeviceInfo object.
QAudioDeviceInfo::QAudioDeviceInfo | ( | const QAudioDeviceInfo & | other | ) |
Constructs a copy of other.
QAudioDeviceInfo::~QAudioDeviceInfo | ( | ) |
Destroy this audio device info.
|
static |
Returns a list of audio devices that support mode.
|
static |
Returns the name of the default input audio device. All platform and audio plugin implementations provide a default audio device to use.
|
static |
Returns the name of the default output audio device. All platform and audio plugin implementations provide a default audio device to use.
QString QAudioDeviceInfo::deviceName | ( | ) | const |
Returns human readable name of audio device. Device names vary depending on platform/audio plugin being used. They are a unique string identifiers for the audio device.
For example, default, Intel, or U0x46d0x9a4.
bool QAudioDeviceInfo::isFormatSupported | ( | const QAudioFormat & | format | ) | const |
Returns true if the given format is supported by the current QAudioDeviceInfo.
bool QAudioDeviceInfo::isNull | ( | ) | const |
Returns whether this QAudioDeviceInfo object holds a device definition.
QAudioFormat QAudioDeviceInfo::nearestFormat | ( | const QAudioFormat & | format | ) | const |
Returns the closest QAudioFormat to the given format which the operating system supports. The format is provided by the platform/audio plugin and QAudio::Mode being used.
bool QAudioDeviceInfo::operator!= | ( | const QAudioDeviceInfo & | other | ) | const |
Returns true if the current QAudioDeviceInfo is not equal to other.
QAudioDeviceInfo & QAudioDeviceInfo::operator= | ( | const QAudioDeviceInfo & | other | ) |
Sets the QAudioDeviceInfo object to be equal to other.
bool QAudioDeviceInfo::operator== | ( | const QAudioDeviceInfo & | other | ) | const |
Returns true if the current QAudioDeviceInfo is equal to other.
QAudioFormat QAudioDeviceInfo::preferredFormat | ( | ) | const |
Returns QAudioFormat of default settings. These settings are provided by the platform/audio plugin being used. They also are dependent on the QAudio::Mode being used.
A typical audio system provides formats like the following.
QList< QAudioFormat::Endian > QAudioDeviceInfo::supportedByteOrders | ( | ) | const |
Returns a list of supported byte orders.
QList< int > QAudioDeviceInfo::supportedChannelCounts | ( | ) | const |
Returns a list of supported channel counts.
QStringList QAudioDeviceInfo::supportedCodecs | ( | ) | const |
Returns a list of supported codecs. All platform and plugin implementations should provide support for:
"audio/pcm" - Linear PCM
For writing plugins to support additional codecs refer to the following:
Refer to the IANA media types for more information.
QList< int > QAudioDeviceInfo::supportedSampleRates | ( | ) | const |
Returns a list of supported sample rates.
QList< int > QAudioDeviceInfo::supportedSampleSizes | ( | ) | const |
Returns a list of supported sample sizes.
QList< QAudioFormat::SampleType > QAudioDeviceInfo::supportedSampleTypes | ( | ) | const |
Returns a list of supported sample types.