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 QAUDIOINPUT_H
6#define QAUDIOINPUT_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
19class QPlatformAudioSource;
20
21class Q_MULTIMEDIA_EXPORT QAudioSource : public QObject
22{
23 Q_OBJECT
24
25public:
26 explicit QAudioSource(const QAudioFormat &format = QAudioFormat(), QObject *parent = nullptr);
27 explicit QAudioSource(const QAudioDevice &audioDeviceInfo, const QAudioFormat &format = QAudioFormat(), QObject *parent = nullptr);
28 ~QAudioSource();
29
30 bool isNull() const { return !d; }
31
32 QAudioFormat format() const;
33
34 void start(QIODevice *device);
35 QIODevice* start();
36
37 void stop();
38 void reset();
39 void suspend();
40 void resume();
41
42 void setBufferSize(qsizetype bytes);
43 qsizetype bufferSize() const;
44
45 qsizetype bytesAvailable() const;
46
47 void setVolume(qreal volume);
48 qreal volume() const;
49
50 qint64 processedUSecs() const;
51 qint64 elapsedUSecs() const;
52
53 QAudio::Error error() const;
54 QAudio::State state() const;
55
56Q_SIGNALS:
57 void stateChanged(QAudio::State state);
58
59private:
60 Q_DISABLE_COPY(QAudioSource)
61
62 QPlatformAudioSource *d;
63};
64
65QT_END_NAMESPACE
66
67#endif // QAUDIOINPUT_H
68

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