Qt 4.8
|
The QAudioDeviceInfo class provides an interface to query audio devices and their functionality. More...
#include <qaudiodeviceinfo.h>
Public Functions | |
QString | deviceName () const |
Returns human readable name of audio device. More... | |
bool | isFormatSupported (const QAudioFormat &format) const |
Returns true if settings are supported by the audio device of this QAudioDeviceInfo. More... | |
bool | isNull () const |
Returns whether this QAudioDeviceInfo object holds a device definition. More... | |
QAudioFormat | nearestFormat (const QAudioFormat &format) const |
Returns closest QAudioFormat to settings that system audio supports. More... | |
QAudioDeviceInfo & | operator= (const QAudioDeviceInfo &other) |
Sets the QAudioDeviceInfo object to be equal to other. More... | |
QAudioFormat | preferredFormat () const |
Returns QAudioFormat of default settings. More... | |
QAudioDeviceInfo () | |
Constructs an empty QAudioDeviceInfo object. More... | |
QAudioDeviceInfo (const QAudioDeviceInfo &other) | |
Constructs a copy of other. More... | |
QList< QAudioFormat::Endian > | supportedByteOrders () const |
Returns a list of supported byte orders. More... | |
QList< int > | supportedChannelCounts () const |
Returns a list of supported channel counts. More... | |
QList< int > | supportedChannels () const |
Use supportedChannelCount() instead. More... | |
QStringList | supportedCodecs () const |
Returns a list of supported codecs. More... | |
QList< int > | supportedFrequencies () const |
Use supportedSampleRates() instead. More... | |
QList< int > | supportedSampleRates () const |
Returns a list of supported sample rates. More... | |
QList< int > | supportedSampleSizes () const |
Returns a list of supported sample sizes. More... | |
QList< QAudioFormat::SampleType > | supportedSampleTypes () const |
Returns a list of supported sample types. More... | |
~QAudioDeviceInfo () | |
Destroy this audio device info. More... | |
Static Public Functions | |
static QList< QAudioDeviceInfo > | availableDevices (QAudio::Mode mode) |
Returns a list of audio devices that support mode. More... | |
static QAudioDeviceInfo | defaultInputDevice () |
Returns the name of the default input audio device. More... | |
static QAudioDeviceInfo | defaultOutputDevice () |
Returns the name of the default output audio device. More... | |
Private Functions | |
QByteArray | handle () const |
QAudio::Mode | mode () const |
QAudioDeviceInfo (const QString &realm, const QByteArray &handle, QAudio::Mode mode) | |
QString | realm () const |
Properties | |
QSharedDataPointer< QAudioDeviceInfoPrivate > | d |
Friends | |
class | QAudioDeviceFactory |
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 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:
... 8
A QAudioDeviceInfo is used by Qt 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().
Definition at line 66 of file qaudiodeviceinfo.h.
QAudioDeviceInfo::QAudioDeviceInfo | ( | ) |
Constructs an empty QAudioDeviceInfo object.
Definition at line 151 of file qaudiodeviceinfo.cpp.
QAudioDeviceInfo::QAudioDeviceInfo | ( | const QAudioDeviceInfo & | other | ) |
Constructs a copy of other.
Definition at line 160 of file qaudiodeviceinfo.cpp.
QAudioDeviceInfo::~QAudioDeviceInfo | ( | ) |
|
private |
Definition at line 435 of file qaudiodeviceinfo.cpp.
|
static |
Returns a list of audio devices that support mode.
Definition at line 425 of file qaudiodeviceinfo.cpp.
|
static |
Returns the name of the default input audio device.
All platform and audio plugin implementations provide a default audio device to use.
Definition at line 406 of file qaudiodeviceinfo.cpp.
|
static |
Returns the name of the default output audio device.
All platform and audio plugin implementations provide a default audio device to use.
Definition at line 416 of file qaudiodeviceinfo.cpp.
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.
eg. default, Intel, U0x46d0x9a4
Definition at line 202 of file qaudiodeviceinfo.cpp.
|
private |
Definition at line 453 of file qaudiodeviceinfo.cpp.
Referenced by QAudioDeviceFactory::createInputDevice(), and QAudioDeviceFactory::createOutputDevice().
bool QAudioDeviceInfo::isFormatSupported | ( | const QAudioFormat & | format | ) | const |
Returns true if settings are supported by the audio device of this QAudioDeviceInfo.
Definition at line 211 of file qaudiodeviceinfo.cpp.
Referenced by nearestFormat().
bool QAudioDeviceInfo::isNull | ( | ) | const |
Returns whether this QAudioDeviceInfo object holds a device definition.
Definition at line 187 of file qaudiodeviceinfo.cpp.
Referenced by QAudioDeviceFactory::createInputDevice(), QAudioDeviceFactory::createOutputDevice(), deviceName(), isFormatSupported(), preferredFormat(), supportedByteOrders(), supportedChannels(), supportedCodecs(), supportedFrequencies(), supportedSampleSizes(), and supportedSampleTypes().
|
private |
Definition at line 463 of file qaudiodeviceinfo.cpp.
QAudioFormat QAudioDeviceInfo::nearestFormat | ( | const QAudioFormat & | settings | ) | const |
Returns closest QAudioFormat to settings that system audio supports.
These settings are provided by the platform/audio plugin being used.
They also are dependent on the QAudio::Mode being used.
Definition at line 243 of file qaudiodeviceinfo.cpp.
QAudioDeviceInfo & QAudioDeviceInfo::operator= | ( | const QAudioDeviceInfo & | other | ) |
Sets the QAudioDeviceInfo object to be equal to other.
Definition at line 177 of file qaudiodeviceinfo.cpp.
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 would provide something like:
Definition at line 230 of file qaudiodeviceinfo.cpp.
Referenced by nearestFormat().
|
private |
Definition at line 444 of file qaudiodeviceinfo.cpp.
Referenced by QAudioDeviceFactory::createInputDevice(), and QAudioDeviceFactory::createOutputDevice().
QList< QAudioFormat::Endian > QAudioDeviceInfo::supportedByteOrders | ( | ) | const |
Returns a list of supported byte orders.
Definition at line 387 of file qaudiodeviceinfo.cpp.
QList< int > QAudioDeviceInfo::supportedChannelCounts | ( | ) | const |
Returns a list of supported channel counts.
Definition at line 355 of file qaudiodeviceinfo.cpp.
QList< int > QAudioDeviceInfo::supportedChannels | ( | ) | const |
Use supportedChannelCount() instead.
Definition at line 369 of file qaudiodeviceinfo.cpp.
Referenced by supportedChannelCounts().
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:
http://www.iana.org/assignments/media-types/audio/
Definition at line 319 of file qaudiodeviceinfo.cpp.
QList< int > QAudioDeviceInfo::supportedFrequencies | ( | ) | const |
Use supportedSampleRates() instead.
Definition at line 344 of file qaudiodeviceinfo.cpp.
Referenced by nearestFormat(), and supportedSampleRates().
QList< int > QAudioDeviceInfo::supportedSampleRates | ( | ) | const |
Returns a list of supported sample rates.
Definition at line 330 of file qaudiodeviceinfo.cpp.
QList< int > QAudioDeviceInfo::supportedSampleSizes | ( | ) | const |
Returns a list of supported sample sizes.
Definition at line 378 of file qaudiodeviceinfo.cpp.
Referenced by nearestFormat().
QList< QAudioFormat::SampleType > QAudioDeviceInfo::supportedSampleTypes | ( | ) | const |
Returns a list of supported sample types.
Definition at line 396 of file qaudiodeviceinfo.cpp.
|
friend |
Definition at line 68 of file qaudiodeviceinfo.h.
|
private |
Definition at line 105 of file qaudiodeviceinfo.h.
Referenced by deviceName(), handle(), isFormatSupported(), isNull(), mode(), operator=(), preferredFormat(), realm(), supportedByteOrders(), supportedChannels(), supportedCodecs(), supportedFrequencies(), supportedSampleSizes(), and supportedSampleTypes().