Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwasmaudiosink_p.h
Go to the documentation of this file.
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 QWASMAUDIOSINK_H
5#define QWASMAUDIOSINK_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 <private/qaudiosystem_p.h>
19#include <QTimer>
20#include <QElapsedTimer>
21
22class ALData;
23class QIODevice;
24
25QT_BEGIN_NAMESPACE
26
27class QWasmAudioSink : public QPlatformAudioSink
28{
29 Q_OBJECT
30
31 ALData *aldata = nullptr;
32 QTimer *m_timer = nullptr;
33 QIODevice *m_device = nullptr;
34 bool m_running = false;
35 QAudio::State m_state = QAudio::StoppedState;
36 QAudio::State m_suspendedInState = QAudio::SuspendedState;
37 int m_bufferSize = 0;
38 quint64 m_processed = 0;
39 QElapsedTimer m_elapsedTimer;
40 int m_bufferFragmentsCount = 10;
41 int m_notifyInterval = 0;
42 char *m_tmpData = nullptr;
43 int m_bufferFragmentSize = 0;
44 int m_lastNotified = 0;
45 int m_tmpDataOffset = 0;
46 int m_bufferFragmentsBusyCount = 0;
47 bool m_pullMode;
48
49 void loadALBuffers();
50 void unloadALBuffers();
51 void nextALBuffers();
52
53private slots:
54 void updateState();
55
56public:
57 QWasmAudioSink(QAudioDevice, const QAudioFormat &, QObject *parent);
58 ~QWasmAudioSink();
59
60public:
61 void start(QIODevice *device) override;
62 QIODevice *start() override;
63 void start(bool mode);
64 void stop() override;
65 void reset() override;
66 void suspend() override;
67 void resume() override;
68 qsizetype bytesFree() const override;
69 void setBufferSize(qsizetype value) override;
70 qsizetype bufferSize() const override;
71 qint64 processedUSecs() const override;
72 QAudio::State state() const override;
73 void setVolume(float volume) override;
74 void setError(QAudio::Error) override;
75
76 friend class QWasmAudioSinkDevice;
77};
78
79QT_END_NAMESPACE
80
81#endif // QWASMAUDIOSINK_H
ALenum format
ALCcontext * context
ALCdevice * device
ALuint * buffer
ALuint source
ALuint * buffers
#define AL_FORMAT_STEREO_FLOAT32
#define AL_FORMAT_MONO_FLOAT32
constexpr unsigned int DEFAULT_BUFFER_DURATION