summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qaudiodevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/audio/qaudiodevice.cpp')
-rw-r--r--src/multimedia/audio/qaudiodevice.cpp185
1 files changed, 128 insertions, 57 deletions
diff --git a/src/multimedia/audio/qaudiodevice.cpp b/src/multimedia/audio/qaudiodevice.cpp
index bc2bed906..4b1e182cb 100644
--- a/src/multimedia/audio/qaudiodevice.cpp
+++ b/src/multimedia/audio/qaudiodevice.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qaudiosystem_p.h"
#include "qaudiodevice_p.h"
@@ -52,12 +16,14 @@ QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QAudioDevicePrivate);
/*!
\class QAudioDevice
- \brief The QAudioDevice class provides an information about audio devices and their functionality.
+ \brief The QAudioDevice class provides an information about audio devices and their
+ functionality.
\inmodule QtMultimedia
\ingroup multimedia
\ingroup multimedia_audio
- QAudioDevice describes an audio device available in the system, either for input or for playback.
+ 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
@@ -73,10 +39,9 @@ QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QAudioDevicePrivate);
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(), or fetch a supported format that is as close as
- possible to the format with nearestFormat(). For instance:
+ isFormatSupported(). For instance:
- \snippet multimedia-snippets/audio.cpp Setting audio format
+ \snippet multimedia-snippets/audio.cpp Audio output setup
The set of available devices can be retrieved from the QMediaDevices class.
@@ -88,7 +53,36 @@ QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QAudioDevicePrivate);
sound, i.e., play an audio stream in a supported format. For each device we
find, we simply print the deviceName().
- \sa QAudioSink, QAudioSource
+ \sa QAudioSink, QAudioSource, QAudioFormat
+*/
+
+/*!
+ \qmlvaluetype audioDevice
+ \inqmlmodule QtMultimedia
+ \since 6.2
+ //! \instantiates QAudioDevice
+ \brief Describes an audio device.
+ \ingroup multimedia_qml
+ \ingroup multimedia_audio_qml
+ \ingroup qmlvaluetypes
+
+ The audioDevice value type describes the properties of an audio device that
+ is connected to the system.
+
+ 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
*/
/*!
@@ -99,14 +93,18 @@ QAudioDevice::QAudioDevice() = default;
/*!
Constructs a copy of \a other.
*/
-QAudioDevice::QAudioDevice(const QAudioDevice& other) = default;
+QAudioDevice::QAudioDevice(const QAudioDevice &other) = default;
/*!
\fn QAudioDevice::QAudioDevice(QAudioDevice &&other)
Move constructs from \a other.
*/
+/*!
+ \fn void QAudioDevice::swap(QAudioDevice &other) noexcept
+ Swaps the audio device with the \a other.
+*/
/*!
Destroy this audio device info.
*/
@@ -115,7 +113,7 @@ QAudioDevice::~QAudioDevice() = default;
/*!
Sets the QAudioDevice object to be equal to \a other.
*/
-QAudioDevice& QAudioDevice::operator=(const QAudioDevice &other) = default;
+QAudioDevice &QAudioDevice::operator=(const QAudioDevice &other) = default;
/*!
\fn QAudioDevice& QAudioDevice::operator=(QAudioDevice &&other)
@@ -127,13 +125,13 @@ QAudioDevice& QAudioDevice::operator=(const QAudioDevice &other) = default;
Returns true if this QAudioDevice class represents the
same audio device as \a other.
*/
-bool QAudioDevice::operator ==(const QAudioDevice &other) const
+bool QAudioDevice::operator==(const QAudioDevice &other) const
{
if (d == other.d)
return true;
if (!d || !other.d)
return false;
- if (d->mode == other.d->mode && d->id == other.d->id)
+ if (d->mode == other.d->mode && d->id == other.d->id && d->isDefault == other.d->isDefault)
return true;
return false;
}
@@ -142,7 +140,7 @@ bool QAudioDevice::operator ==(const QAudioDevice &other) const
Returns true if this QAudioDevice class represents a
different audio device than \a other
*/
-bool QAudioDevice::operator !=(const QAudioDevice &other) const
+bool QAudioDevice::operator!=(const QAudioDevice &other) const
{
return !operator==(other);
}
@@ -156,6 +154,18 @@ bool QAudioDevice::isNull() const
}
/*!
+ \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.
+*/
+
+/*!
+ \property QAudioDevice::id
+
Returns an identifier for the audio device.
Device names vary depending on the platform/audio plugin being used.
@@ -168,6 +178,16 @@ QByteArray QAudioDevice::id() const
}
/*!
+ \qmlproperty string QtMultimedia::audioDevice::description
+
+ Holds a human readable name of the audio device.
+
+ Use this string to present the device to the user.
+*/
+
+/*!
+ \property QAudioDevice::description
+
Returns a human readable name of the audio device.
Use this string to present the device to the user.
@@ -178,7 +198,15 @@ QString QAudioDevice::description() const
}
/*!
- Returns true if this is the default audio device for it's mode.
+ \qmlproperty bool QtMultimedia::audioDevice::isDefault
+
+ Is true if this is the default audio device.
+*/
+
+/*!
+ \property QAudioDevice::isDefault
+
+ Returns true if this is the default audio device.
*/
bool QAudioDevice::isDefault() const
{
@@ -193,9 +221,11 @@ bool QAudioDevice::isFormatSupported(const QAudioFormat &settings) const
{
if (isNull())
return false;
- if (settings.sampleRate() < d->minimumSampleRate || settings.sampleRate() > d->maximumSampleRate)
+ if (settings.sampleRate() < d->minimumSampleRate
+ || settings.sampleRate() > d->maximumSampleRate)
return false;
- if (settings.channelCount() < d->minimumChannelCount || settings.channelCount() > d->maximumChannelCount)
+ if (settings.channelCount() < d->minimumChannelCount
+ || settings.channelCount() > d->maximumChannelCount)
return false;
if (!d->supportedSampleFormats.contains(settings.sampleFormat()))
return false;
@@ -207,7 +237,7 @@ bool QAudioDevice::isFormatSupported(const QAudioFormat &settings) const
These settings are provided by the platform/audio plugin being used.
- They are also dependent on the \l {QAudio}::Mode being used.
+ They are also dependent on the \l {QtAudio}::Mode being used.
A typical audio system would provide something like:
\list
@@ -265,14 +295,53 @@ QList<QAudioFormat::SampleFormat> QAudioDevice::supportedSampleFormats() const
}
/*!
+ Returns the channel configuration of the device.
+*/
+QAudioFormat::ChannelConfig QAudioDevice::channelConfiguration() const
+{
+ return isNull() ? QAudioFormat::ChannelConfigUnknown : d->channelConfiguration;
+}
+
+/*!
+ \fn QAudioDevicePrivate QAudioDevice::handle() const
\internal
*/
-QAudioDevice::QAudioDevice(QAudioDevicePrivate *p)
- : d(p)
-{}
+/*!
+ \internal
+*/
+QAudioDevice::QAudioDevice(QAudioDevicePrivate *p) : d(p) { }
/*!
- returns whether this device is an input or output device.
+ \enum QAudioDevice::Mode
+
+ Describes the mode of this device.
+
+ \value Null
+ A null device.
+ \value Input
+ An input device.
+ \value Output
+ An output device.
+*/
+
+/*!
+ \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.
+
+*/
+
+/*!
+ \property QAudioDevice::mode
+
+ Returns whether this device is an input or output device.
*/
QAudioDevice::Mode QAudioDevice::mode() const
{
@@ -300,3 +369,5 @@ QDebug operator<<(QDebug dbg, QAudioDevice::Mode mode)
#endif
QT_END_NAMESPACE
+
+#include "moc_qaudiodevice.cpp"