1 | // Copyright (C) 2016 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 QAUDIOOUTPUT_H |
6 | #define QAUDIOOUTPUT_H |
7 | |
8 | #include <QtCore/qiodevice.h> |
9 | |
10 | #include <QtMultimedia/qtmultimediaglobal.h> |
11 | |
12 | #include <QtMultimedia/qtaudio.h> |
13 | #include <QtMultimedia/qaudioformat.h> |
14 | #include <QtMultimedia/qaudiodevice.h> |
15 | |
16 | |
17 | QT_BEGIN_NAMESPACE |
18 | |
19 | |
20 | |
21 | class QPlatformAudioSink; |
22 | |
23 | class Q_MULTIMEDIA_EXPORT QAudioSink : public QObject |
24 | { |
25 | Q_OBJECT |
26 | |
27 | public: |
28 | explicit QAudioSink(const QAudioFormat &format = QAudioFormat(), QObject *parent = nullptr); |
29 | explicit QAudioSink(const QAudioDevice &audioDeviceInfo, const QAudioFormat &format = QAudioFormat(), QObject *parent = nullptr); |
30 | ~QAudioSink(); |
31 | |
32 | bool isNull() const { return !d; } |
33 | |
34 | QAudioFormat format() const; |
35 | |
36 | void start(QIODevice *device); |
37 | QIODevice* start(); |
38 | |
39 | void stop(); |
40 | void reset(); |
41 | void suspend(); |
42 | void resume(); |
43 | |
44 | void setBufferSize(qsizetype bytes); |
45 | qsizetype bufferSize() const; |
46 | |
47 | qsizetype bytesFree() const; |
48 | |
49 | qint64 processedUSecs() const; |
50 | qint64 elapsedUSecs() const; |
51 | |
52 | QtAudio::Error error() const; |
53 | QtAudio::State state() const; |
54 | |
55 | void setVolume(qreal); |
56 | qreal volume() const; |
57 | |
58 | Q_SIGNALS: |
59 | #if defined(Q_QDOC) |
60 | void stateChanged(QtAudio::State state); |
61 | #else |
62 | // use QAudio here to keep string-based connections working |
63 | void stateChanged(QAudio::State state); |
64 | #endif |
65 | |
66 | private: |
67 | Q_DISABLE_COPY(QAudioSink) |
68 | |
69 | QPlatformAudioSink* d; |
70 | }; |
71 | |
72 | QT_END_NAMESPACE |
73 | |
74 | #endif // QAUDIOOUTPUT_H |
75 |