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_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 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_P_H
5#define QAUDIOENGINE_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 <QtSpatialAudio/qaudioengine.h>
19#include <QtSpatialAudio/private/qtspatialaudioglobal_p.h>
20#include <QtMultimedia/qaudiodevice.h>
21#include <QtCore/qthread.h>
22#include <QtCore/qtclasshelpermacros.h>
23#include <QtCore/qmutex.h>
24
25namespace vraudio {
26class ResonanceAudio;
27} // namespace vraudio
28
29QT_BEGIN_NAMESPACE
30
31class QSpatialSound;
32class QAmbientSound;
34class QAudioRoom;
35class QAudioListener;
36class QAudioEngine;
37
39{
40public:
41 static QAudioEnginePrivate *get(QAudioEngine *engine) { return engine ? engine->d : nullptr; }
42
43 static constexpr int bufferSize = 128;
44
45 explicit QAudioEnginePrivate(QAudioEngine *);
48
50 int sampleRate = 44100;
51 float masterVolume = 1.;
53 bool roomEffectsEnabled = true;
54
55 void start();
56 void stop();
57 void setPaused(bool paused);
58 void setOutputDevice(const QAudioDevice &device);
60
61 // Resonance Audio uses meters internally, while Qt Quick 3D and our API uses cm by
62 // default. To make things independent from the scale setting, we store all distances in
63 // meters internally and convert in the setters and getters.
64 float distanceScale = 0.01f;
65
68 QAtomicInteger<bool> paused = false;
69
72
73 QAudioListener *listener = nullptr;
77 mutable bool listenerPositionDirty = true;
78 QAudioRoom *currentRoom = nullptr;
79
80 void addSpatialSound(QSpatialSound *sound);
81 void removeSpatialSound(QSpatialSound *sound);
82 void addStereoSound(QAmbientSound *sound);
83 void removeStereoSound(QAmbientSound *sound);
84
85 void addRoom(QAudioRoom *room);
86 void removeRoom(QAudioRoom *room);
87 void updateRooms();
88
90 QAudioEngine *q;
91};
92
93QT_END_NAMESPACE
94
95#endif
void setPaused(bool paused)
std::unique_ptr< QAudioOutputStream > outputStream
void addRoom(QAudioRoom *room)
std::unique_ptr< vraudio::ResonanceAudio > resonanceAudio
void addStereoSound(QAmbientSound *sound)
QAtomicInteger< bool > paused
QAudioRoom * currentRoom
QVector3D listenerPosition() const
void removeRoom(QAudioRoom *room)
void addSpatialSound(QSpatialSound *sound)
void setOutputMode(QAudioEngine::OutputMode)
QAudioEngine::OutputMode outputMode
static QAudioEnginePrivate * get(QAudioEngine *engine)
QList< QAmbientSound * > stereoSources
QList< QSpatialSound * > sources
void removeStereoSound(QAmbientSound *sound)
void removeSpatialSound(QSpatialSound *sound)
QList< QAudioRoom * > rooms
QAudioEnginePrivate(QAudioEngine *)
QAudioListener * listener
static constexpr int bufferSize
void setOutputDevice(const QAudioDevice &device)
void setPaused(bool paused)
QAudioOutputStream(QAudioEnginePrivate *d)
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.
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.
QT_BEGIN_NAMESPACE const int bufferTimeMs