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 | #ifndef QAUDIOSYSTEM_H |
5 | #define QAUDIOSYSTEM_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtMultimedia/qtmultimediaglobal.h> |
19 | |
20 | #include <QtMultimedia/qaudio.h> |
21 | #include <QtMultimedia/qaudioformat.h> |
22 | #include <QtMultimedia/qaudiodevice.h> |
23 | |
24 | #include <QtCore/qelapsedtimer.h> |
25 | #include <QtCore/private/qglobal_p.h> |
26 | |
27 | QT_BEGIN_NAMESPACE |
28 | |
29 | class QIODevice; |
30 | |
31 | class Q_MULTIMEDIA_EXPORT QAudioStateChangeNotifier : public QObject |
32 | { |
33 | Q_OBJECT |
34 | public: |
35 | QAudioStateChangeNotifier(QObject *parent = nullptr); |
36 | |
37 | signals: |
38 | void errorChanged(QAudio::Error error); |
39 | void stateChanged(QAudio::State state); |
40 | }; |
41 | |
42 | class Q_MULTIMEDIA_EXPORT QPlatformAudioSink : public QAudioStateChangeNotifier |
43 | { |
44 | Q_OBJECT |
45 | |
46 | public: |
47 | QPlatformAudioSink(QObject *parent); |
48 | virtual void start(QIODevice *device) = 0; |
49 | virtual QIODevice* start() = 0; |
50 | virtual void stop() = 0; |
51 | virtual void reset() = 0; |
52 | virtual void suspend() = 0; |
53 | virtual void resume() = 0; |
54 | virtual qsizetype bytesFree() const = 0; |
55 | virtual void setBufferSize(qsizetype value) = 0; |
56 | virtual qsizetype bufferSize() const = 0; |
57 | virtual qint64 processedUSecs() const = 0; |
58 | virtual QAudio::Error error() const = 0; |
59 | virtual QAudio::State state() const = 0; |
60 | virtual void setFormat(const QAudioFormat& fmt) = 0; |
61 | virtual QAudioFormat format() const = 0; |
62 | virtual void setVolume(qreal) {} |
63 | virtual qreal volume() const; |
64 | |
65 | QElapsedTimer elapsedTime; |
66 | }; |
67 | |
68 | class Q_MULTIMEDIA_EXPORT QPlatformAudioSource : public QAudioStateChangeNotifier |
69 | { |
70 | Q_OBJECT |
71 | |
72 | public: |
73 | QPlatformAudioSource(QObject *parent); |
74 | virtual void start(QIODevice *device) = 0; |
75 | virtual QIODevice* start() = 0; |
76 | virtual void stop() = 0; |
77 | virtual void reset() = 0; |
78 | virtual void suspend() = 0; |
79 | virtual void resume() = 0; |
80 | virtual qsizetype bytesReady() const = 0; |
81 | virtual void setBufferSize(qsizetype value) = 0; |
82 | virtual qsizetype bufferSize() const = 0; |
83 | virtual qint64 processedUSecs() const = 0; |
84 | virtual QAudio::Error error() const = 0; |
85 | virtual QAudio::State state() const = 0; |
86 | virtual void setFormat(const QAudioFormat& fmt) = 0; |
87 | virtual QAudioFormat format() const = 0; |
88 | virtual void setVolume(qreal) = 0; |
89 | virtual qreal volume() const = 0; |
90 | |
91 | QElapsedTimer elapsedTime; |
92 | }; |
93 | |
94 | QT_END_NAMESPACE |
95 | |
96 | #endif // QAUDIOSYSTEM_H |
97 | |