1 | // Copyright (C) 2022 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | |
5 | #ifndef QAUDIODEVICEINFO_P_H |
6 | #define QAUDIODEVICEINFO_P_H |
7 | |
8 | // |
9 | // W A R N I N G |
10 | // ------------- |
11 | // |
12 | // This file is not part of the Qt API. It exists purely as an |
13 | // implementation detail. This header file may change from version to |
14 | // version without notice, or even be removed. |
15 | // |
16 | // We mean it. |
17 | // |
18 | |
19 | #include <QtMultimedia/qaudiodevice.h> |
20 | #include <QtCore/private/qglobal_p.h> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | // Implementations should not include volatile members, such as values that can change between |
25 | // connection sessions. For example, CoreAudio AudioDeviceId on macOS. |
26 | class Q_MULTIMEDIA_EXPORT QAudioDevicePrivate : public QSharedData |
27 | { |
28 | public: |
29 | QAudioDevicePrivate(QByteArray i, QAudioDevice::Mode m, QString description) |
30 | : id(std::move(i)), mode(m), description(std::move(description)) |
31 | {} |
32 | virtual ~QAudioDevicePrivate(); |
33 | const QByteArray id; |
34 | const QAudioDevice::Mode mode = QAudioDevice::Output; |
35 | const QString description; |
36 | bool isDefault = false; |
37 | |
38 | QAudioFormat preferredFormat; |
39 | int minimumSampleRate = 0; |
40 | int maximumSampleRate = 0; |
41 | int minimumChannelCount = 0; |
42 | int maximumChannelCount = 0; |
43 | QList<QAudioFormat::SampleFormat> supportedSampleFormats; |
44 | QAudioFormat::ChannelConfig channelConfiguration = QAudioFormat::ChannelConfigUnknown; |
45 | |
46 | QAudioDevice create() { return QAudioDevice(this); } |
47 | }; |
48 | |
49 | inline const QList<QAudioFormat::SampleFormat> &qAllSupportedSampleFormats() |
50 | { |
51 | static const auto singleton = QList<QAudioFormat::SampleFormat>{ |
52 | QAudioFormat::UInt8, |
53 | QAudioFormat::Int16, |
54 | QAudioFormat::Int32, |
55 | QAudioFormat::Float, |
56 | }; |
57 | return singleton; |
58 | } |
59 | |
60 | struct QAudioDevicePrivateAllMembersEqual |
61 | { |
62 | bool operator()(const QAudioDevicePrivate &lhs, const QAudioDevicePrivate &rhs) |
63 | { |
64 | auto asTuple = [](const QAudioDevicePrivate &x) { |
65 | return std::tie(args: x.id, args: x.mode, args: x.isDefault, args: x.preferredFormat, args: x.description, |
66 | args: x.minimumSampleRate, args: x.maximumSampleRate, args: x.minimumChannelCount, |
67 | args: x.maximumChannelCount, args: x.supportedSampleFormats, |
68 | args: x.channelConfiguration); |
69 | }; |
70 | |
71 | return asTuple(lhs) == asTuple(rhs); |
72 | } |
73 | }; |
74 | |
75 | QT_END_NAMESPACE |
76 | |
77 | #endif // QAUDIODEVICEINFO_H |
78 | |