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/qaudio.h>
13#include <QtMultimedia/qaudioformat.h>
14#include <QtMultimedia/qaudiodevice.h>
15
16
17QT_BEGIN_NAMESPACE
18
19
20
21class QPlatformAudioSink;
22
23class Q_MULTIMEDIA_EXPORT QAudioSink : public QObject
24{
25 Q_OBJECT
26
27public:
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 QAudio::Error error() const;
53 QAudio::State state() const;
54
55 void setVolume(qreal);
56 qreal volume() const;
57
58Q_SIGNALS:
59 void stateChanged(QAudio::State state);
60
61private:
62 Q_DISABLE_COPY(QAudioSink)
63
64 QPlatformAudioSink* d;
65};
66
67QT_END_NAMESPACE
68
69#endif // QAUDIOOUTPUT_H
70

source code of qtmultimedia/src/multimedia/audio/qaudiosink.h