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
qaudioengine_threaded_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-3.0-only
3
4#ifndef QAUDIOENGINE_THREADED_P_H
5#define QAUDIOENGINE_THREADED_P_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 for the convenience
12// of other Qt classes. 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/qaudiodevice.h>
19#include <QtSpatialAudio/private/qtspatialaudioglobal_p.h>
20#include <QtSpatialAudio/private/qaudioengine_p.h>
21#include <QtCore/qmutex.h>
22#include <QtCore/qthread.h>
23
24#include <map>
25
26namespace vraudio {
27class ResonanceAudio;
28} // namespace vraudio
29
30QT_BEGIN_NAMESPACE
31
32class QAudioOutputStream;
33class QAudioRoom;
34class QAudioListener;
35
36namespace QSpatialAudioPrivate {
38} // namespace QSpatialAudioPrivate
39
41{
42public:
43 explicit QAudioEngineThreaded(int sampleRate);
46
47 void start() override;
48 void stop() override;
49 void setPaused(bool paused) override;
50 bool isPaused() const override;
51 void setOutputDevice(const QAudioDevice &device) override;
52 QAudioDevice outputDevice() const override { return m_device; }
53
54 void addSound(QAmbientSoundPrivate *) override;
55 void removeSound(QAmbientSoundPrivate *) override;
56
58 void setSoundPlaybackData(QAmbientSoundPrivate *, SharedPlaybackState) override;
59
61
62private:
63 friend class QAudioOutputStream;
64
65 QMutex mutex;
66 QAudioDevice m_device;
67 QAtomicInteger<bool> m_paused = false;
68
69 QThread audioThread;
70 std::unique_ptr<QAudioOutputStream> outputStream;
71
72 std::map<QAmbientSoundPrivate *, SharedPlaybackState> playbackStates;
73};
74
75QT_END_NAMESPACE
76
77#endif
QAudioDevice outputDevice() const override
void setSoundPlaybackData(QAmbientSoundPrivate *, SharedPlaybackState) override
std::shared_ptr< QSpatialAudioPrivate::QSpatialAudioPlaybackState > SharedPlaybackState
void setPaused(bool paused) override
void setOutputDevice(const QAudioDevice &device) override
bool isPaused() const override
void addSound(QAmbientSoundPrivate *) override
void removeSound(QAmbientSoundPrivate *) override
qint64 readData(char *data, qint64 len) override
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
bool atEnd() const override
Returns true if the current read and write position is at the end of the device (i....
~QAudioOutputStream() override
qint64 pos() const override
For random-access devices, this function returns the position that data is written to or read from.
QAudioOutputStream(QAudioEngineThreaded *d)
bool isSequential() const override
Returns true if this device is sequential; otherwise returns false.
qint64 bytesAvailable() const override
Returns the number of bytes that are available for reading.
qint64 writeData(const char *, qint64) override
Writes up to maxSize bytes from data to the device.
qint64 size() const override
For open random-access devices, this function returns the size of the device.
Combined button and popup list for selecting options.
static constexpr std::array< float, 2 *QAudioEngineThreaded::framesPerBuffer > nullBuffer
QT_BEGIN_NAMESPACE const int bufferTimeMs