The QAudioDeviceInfo 类提供查询音频设备及其功能的接口。 更多...
头: | #include <QAudioDeviceInfo> |
qmake: | QT += multimedia |
QAudioDeviceInfo () | |
QAudioDeviceInfo (const QAudioDeviceInfo & other ) | |
~QAudioDeviceInfo () | |
QString | deviceName () const |
bool | isFormatSupported (const QAudioFormat & settings ) const |
bool | isNull () const |
QAudioFormat | nearestFormat (const QAudioFormat & settings ) 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 |
bool | operator!= (const QAudioDeviceInfo & other ) const |
QAudioDeviceInfo & | operator= (const QAudioDeviceInfo & other ) |
bool | operator== (const QAudioDeviceInfo & other ) const |
QList<QAudioDeviceInfo> | availableDevices (QAudio::Mode mode ) |
QAudioDeviceInfo | defaultInputDevice () |
QAudioDeviceInfo | defaultOutputDevice () |
The QAudioDeviceInfo 类提供查询音频设备及其功能的接口。
QAudioDeviceInfo 允许查询系统中当前可用的音频设备 (譬如:声卡和 USB 耳机)。可用的音频设备从属所安装的平台或音频插件。
A QAudioDeviceInfo 用于 Qt 以构造与设备通信的类,譬如 QAudioInput ,和 QAudioOutput .
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 类。
The values supported by the device for each of these parameters can be fetched with supportedByteOrders (), supportedChannelCounts (), supportedCodecs (), supportedSampleRates (), supportedSampleSizes (),和 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:
QAudioFormat format; format.setSampleRate(44100); // ... other format parameters format.setSampleType(QAudioFormat::SignedInt); QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); if (!info.isFormatSupported(format)) format = info.nearestFormat(format);
静态函数 defaultInputDevice (), defaultOutputDevice (),和 availableDevices () let you get a list of all available devices. Devices are fetched according to the value of mode this is specified by the QAudio ::Mode enum. The QAudioDeviceInfo returned are only valid for the QAudio ::Mode.
例如:
foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) qDebug() << "Device name: " << deviceInfo.deviceName();
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 ().
另请参阅 QAudioOutput and QAudioInput .
构造空的 QAudioDeviceInfo 对象。
构造副本为 other .
销毁此音频设备信息。
[static]
QList
<
QAudioDeviceInfo
> QAudioDeviceInfo::
availableDevices
(
QAudio::Mode
mode
)
返回的音频设备列表支持 mode .
[static]
QAudioDeviceInfo
QAudioDeviceInfo::
defaultInputDevice
()
返回默认输入音频设备的信息。所有平台和音频插件实现均提供要使用的默认音频设备。
[static]
QAudioDeviceInfo
QAudioDeviceInfo::
defaultOutputDevice
()
返回默认输出音频设备的信息。所有平台和音频插件实现均提供要使用的默认音频设备。
返回音频设备的人类可读名称。
设备名称从属所使用的平台/音频插件。
它们是音频设备的唯一字符串标识符。
如 default, Intel, U0x46d0x9a4
返回 true 若供给 settings are supported by the audio device described by this QAudioDeviceInfo .
Returns whether this QAudioDeviceInfo object holds a valid device definition.
Returns the closest QAudioFormat to the supplied settings that the system supports.
These settings are provided by the platform/audio plugin being used.
They are also dependent on the QAudio ::Mode being used.
Returns the default audio format settings for this device.
These settings are provided by the platform/audio plugin being used.
They are also dependent on the QAudio ::Mode being used.
A typical audio system would provide something like:
返回支持的字节序列表。
Returns a list of supported channel counts.
This is typically 1 for mono sound, or 2 for stereo sound.
返回支持的编解码器列表。
所有平台和插件实现都应提供支持:
audio/pcm - 线性 PCM
编写插件以支持额外编解码器,参考:
http://www.iana.org/assignments/media-types/audio/
返回支持的采样率的列表 (以赫兹为单位)。
返回支持的采样大小的列表 (以位为单位)。
通常这将包括 8 位和 16 位的采样大小。
Returns a list of supported sample types.
返回 true,若此 QAudioDeviceInfo class represents a different audio device than other
设置 QAudioDeviceInfo 对象等于 other .
返回 true,若此 QAudioDeviceInfo class represents the same audio device as other .