![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QAudioDevice class provides an information about audio devices and their functionality. More...
#include <qaudiodevice.h>
Public Types | |
enum | Mode { Null , Input , Output } |
Describes the mode of this device. More... | |
Public Member Functions | |
QAudioDevice () | |
Describes an audio device. | |
QAudioDevice (const QAudioDevice &other) | |
Constructs a copy of other. | |
~QAudioDevice () | |
Destroy this audio device info. | |
QAudioDevice (QAudioDevice &&other) noexcept=default | |
Move constructs from other. | |
void | swap (QAudioDevice &other) noexcept |
Swaps the audio device with the other. | |
QAudioDevice & | operator= (const QAudioDevice &other) |
Sets the QAudioDevice object to be equal to other. | |
bool | operator== (const QAudioDevice &other) const |
Returns true if this QAudioDevice class represents the same audio device as other. | |
bool | operator!= (const QAudioDevice &other) const |
Returns true if this QAudioDevice class represents a different audio device than other. | |
bool | isNull () const |
Returns whether this QAudioDevice object holds a valid device definition. | |
QByteArray | id () const |
QString | description () const |
bool | isDefault () const |
QAudioDevice::Mode | mode () const |
bool | isFormatSupported (const QAudioFormat &format) const |
Returns true if the supplied settings are supported by the audio device described by this QAudioDevice. | |
QAudioFormat | preferredFormat () const |
Returns the default audio format settings for this device. | |
int | minimumSampleRate () const |
Returns the minimum supported sample rate (in Hertz). | |
int | maximumSampleRate () const |
Returns the maximum supported sample rate (in Hertz). | |
int | minimumChannelCount () const |
Returns the minimum number of supported channel counts. | |
int | maximumChannelCount () const |
Returns the maximum number of supported channel counts. | |
QList< QAudioFormat::SampleFormat > | supportedSampleFormats () const |
Returns a list of supported sample types. | |
QAudioFormat::ChannelConfig | channelConfiguration () const |
Returns the channel configuration of the device. | |
const QAudioDevicePrivate * | handle () const |
Properties | |
QByteArray | id |
\qmlproperty string QtMultimedia::audioDevice::id | |
QString | description |
\qmlproperty string QtMultimedia::audioDevice::description | |
bool | isDefault |
\qmlproperty bool QtMultimedia::audioDevice::isDefault | |
Mode | mode |
\qmlproperty enumeration QtMultimedia::audioDevice::mode | |
Friends | |
class | QAudioDevicePrivate |
The QAudioDevice class provides an information about audio devices and their functionality.
\inmodule QtMultimedia
QAudioDevice describes an audio device available in the system, either for input or for playback.
A QAudioDevice is used by Qt to construct classes that communicate with the device – such as QAudioSource, and QAudioSink. It is also used to determine the input or output device to use in a capture session or during media playback.
The QAudioDevice instance retains its properties throughout its lifetime, even if the corresponding physical device is disconnected or its settings are modified. To keep track of updated properties, the user should load new instances of QAudioDevice from \l{QMediaDevices} when the relevant signals are fired.
You can also query each device for the formats it supports. A format in this context is a set consisting of a channel count, 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 minimumChannelCount(), maximumChannelCount(), minimumSampleRate(), maximumSampleRate() and supportedSampleFormats(). The combinations supported are dependent on the audio device capabilities. If you need a specific format, you can check if the device supports it with isFormatSupported(). For instance:
The set of available devices can be retrieved from the QMediaDevices class.
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 24 of file qaudiodevice.h.
enum QAudioDevice::Mode |
Describes the mode of this device.
\value Null A null device. \value Input An input device. \value Output An output device.
Enumerator | |
---|---|
Null | |
Input | |
Output |
Definition at line 32 of file qaudiodevice.h.
|
default |
Describes an audio device.
\qmlvaluetype audioDevice \inqmlmodule QtMultimedia \since 6.2
! \nativetype QAudioDevice
The audioDevice value type describes the properties of an audio device that is connected to the system.
The audioDevice instance retains its properties throughout its lifetime, even if the corresponding physical device is disconnected or its settings are modified. To keep track of updated properties, the user should load new instances of audioDevice from \l{MediaDevices} when the relevant signals are fired.
The list of audio input or output devices can be queried from the \l{MediaDevices} type. To select a certain audio device for input or output set it as the device on \l{AudioInput} or \l{AudioOutput}.
\qml MediaPlayer { audioOutput: AudioOutput { device: mediaDevices.defaultAudioOutput } } MediaDevices { id: mediaDevices } \endqml
Constructs a null QAudioDevice object.
|
default |
Constructs a copy of other.
|
default |
Destroy this audio device info.
|
defaultnoexcept |
Move constructs from other.
QAudioFormat::ChannelConfig QAudioDevice::channelConfiguration | ( | ) | const |
Returns the channel configuration of the device.
Definition at line 304 of file qaudiodevice.cpp.
QString QAudioDevice::description | ( | ) | const |
Definition at line 199 of file qaudiodevice.cpp.
|
inline |
Definition at line 71 of file qaudiodevice.h.
QByteArray QAudioDevice::id | ( | ) | const |
Definition at line 179 of file qaudiodevice.cpp.
bool QAudioDevice::isDefault | ( | ) | const |
Definition at line 215 of file qaudiodevice.cpp.
bool QAudioDevice::isFormatSupported | ( | const QAudioFormat & | format | ) | const |
Returns true if the supplied settings are supported by the audio device described by this QAudioDevice.
Definition at line 224 of file qaudiodevice.cpp.
bool QAudioDevice::isNull | ( | ) | const |
Returns whether this QAudioDevice object holds a valid device definition.
Definition at line 155 of file qaudiodevice.cpp.
int QAudioDevice::maximumChannelCount | ( | ) | const |
Returns the maximum number of supported channel counts.
This is typically 1 for mono sound, or 2 for stereo sound.
Definition at line 288 of file qaudiodevice.cpp.
int QAudioDevice::maximumSampleRate | ( | ) | const |
Returns the maximum supported sample rate (in Hertz).
Definition at line 268 of file qaudiodevice.cpp.
int QAudioDevice::minimumChannelCount | ( | ) | const |
Returns the minimum number of supported channel counts.
This is typically 1 for mono sound, or 2 for stereo sound.
Definition at line 278 of file qaudiodevice.cpp.
int QAudioDevice::minimumSampleRate | ( | ) | const |
Returns the minimum supported sample rate (in Hertz).
Definition at line 260 of file qaudiodevice.cpp.
QAudioDevice::Mode QAudioDevice::mode | ( | ) | const |
Definition at line 350 of file qaudiodevice.cpp.
bool QAudioDevice::operator!= | ( | const QAudioDevice & | other | ) | const |
Returns true if this QAudioDevice class represents a different audio device than other.
Definition at line 147 of file qaudiodevice.cpp.
|
default |
Sets the QAudioDevice object to be equal to other.
Moves other into this QAudioDevice object.
bool QAudioDevice::operator== | ( | const QAudioDevice & | other | ) | const |
Returns true if this QAudioDevice class represents the same audio device as other.
Definition at line 138 of file qaudiodevice.cpp.
QAudioFormat QAudioDevice::preferredFormat | ( | ) | const |
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 \l {QtAudio}Mode being used.
A typical audio system would provide something like: \list
Definition at line 252 of file qaudiodevice.cpp.
QList< QAudioFormat::SampleFormat > QAudioDevice::supportedSampleFormats | ( | ) | const |
Returns a list of supported sample types.
Definition at line 296 of file qaudiodevice.cpp.
|
inlinenoexcept |
Swaps the audio device with the other.
Definition at line 45 of file qaudiodevice.h.
|
friend |
Definition at line 73 of file qaudiodevice.h.
|
read |
\qmlproperty string QtMultimedia::audioDevice::description
Holds a human readable name of the audio device.
Use this string to present the device to the user.
Returns a human readable name of the audio device.
Use this string to present the device to the user.
Definition at line 28 of file qaudiodevice.h.
|
read |
\qmlproperty string QtMultimedia::audioDevice::id
Holds an identifier for the audio device.
Device names vary depending on the platform/audio plugin being used.
They are a unique identifier for the audio device.
Returns an identifier for the audio device.
Device names vary depending on the platform/audio plugin being used.
They are a unique identifier for the audio device.
Definition at line 27 of file qaudiodevice.h.
|
read |
\qmlproperty bool QtMultimedia::audioDevice::isDefault
Is true if this is the default audio device.
Returns true if this is the default audio device.
Definition at line 29 of file qaudiodevice.h.
|
read |
\qmlproperty enumeration QtMultimedia::audioDevice::mode
Holds whether this device is an input or output device.
The returned value can be one of the following:
\value audioDevice.Null A null device. \value audioDevice.Input input device. \value audioDevice.Output An output device.
Returns whether this device is an input or output device.
Definition at line 30 of file qaudiodevice.h.