| 1 | // Copyright (C) 2021 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 | #ifndef QAUDIOOUTPUTDEVICE_H | 
|---|
| 5 | #define QAUDIOOUTPUTDEVICE_H | 
|---|
| 6 |  | 
|---|
| 7 | #include <QtCore/qobject.h> | 
|---|
| 8 | #include <QtMultimedia/qtmultimediaglobal.h> | 
|---|
| 9 | #include <QtMultimedia/qtaudio.h> | 
|---|
| 10 |  | 
|---|
| 11 | #include <functional> | 
|---|
| 12 |  | 
|---|
| 13 | QT_BEGIN_NAMESPACE | 
|---|
| 14 |  | 
|---|
| 15 | class QAudioDevice; | 
|---|
| 16 | class QPlatformAudioOutput; | 
|---|
| 17 |  | 
|---|
| 18 | class Q_MULTIMEDIA_EXPORT QAudioOutput : public QObject | 
|---|
| 19 | { | 
|---|
| 20 | Q_OBJECT | 
|---|
| 21 | Q_PROPERTY(QAudioDevice device READ device WRITE setDevice NOTIFY deviceChanged) | 
|---|
| 22 | Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged) | 
|---|
| 23 | Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) | 
|---|
| 24 |  | 
|---|
| 25 | public: | 
|---|
| 26 | explicit QAudioOutput(QObject *parent = nullptr); | 
|---|
| 27 | explicit QAudioOutput(const QAudioDevice &device, QObject *parent = nullptr); | 
|---|
| 28 | ~QAudioOutput() override; | 
|---|
| 29 |  | 
|---|
| 30 | QAudioDevice device() const; | 
|---|
| 31 | float volume() const; | 
|---|
| 32 | bool isMuted() const; | 
|---|
| 33 |  | 
|---|
| 34 | public Q_SLOTS: | 
|---|
| 35 | void setDevice(const QAudioDevice &device); | 
|---|
| 36 | void setVolume(float volume); | 
|---|
| 37 | void setMuted(bool muted); | 
|---|
| 38 |  | 
|---|
| 39 | Q_SIGNALS: | 
|---|
| 40 | void deviceChanged(); | 
|---|
| 41 | void volumeChanged(float volume); | 
|---|
| 42 | void mutedChanged(bool muted); | 
|---|
| 43 |  | 
|---|
| 44 | private: | 
|---|
| 45 | QPlatformAudioOutput *handle() const { return d; } | 
|---|
| 46 | void setDisconnectFunction(std::function<void()> disconnectFunction); | 
|---|
| 47 | friend class QMediaCaptureSession; | 
|---|
| 48 | friend class QMediaPlayer; | 
|---|
| 49 | Q_DISABLE_COPY(QAudioOutput) | 
|---|
| 50 | QPlatformAudioOutput *d = nullptr; | 
|---|
| 51 | }; | 
|---|
| 52 |  | 
|---|
| 53 | QT_END_NAMESPACE | 
|---|
| 54 |  | 
|---|
| 55 | #endif  // QAUDIOOUTPUTDEVICE_H | 
|---|
| 56 |  | 
|---|