Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qambientsound_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-3.0-only
3
4#ifndef QAMBIENTSOUND_P_H
5#define QAMBIENTSOUND_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
19#include <qmutex.h>
20#include <qurl.h>
21#include <qfile.h>
22#include <qaudiodecoder.h>
23#include <qaudiobuffer.h>
24
26
27class QAudioEngine;
28
30{
31public:
36
37 template<typename T>
38 static QAmbientSoundPrivate *get(T *soundSource) { return soundSource ? soundSource->d : nullptr; }
39
41 float volume = 1.;
42 int nchannels = 2;
43 std::unique_ptr<QAudioDecoder> decoder;
44 std::unique_ptr<QFile> sourceDeviceFile;
45 QAudioEngine *engine = nullptr;
46
49 int bufPos = 0;
51 QList<QAudioBuffer> buffers;
52 int sourceId = -1; // kInvalidSourceId
53
54 QAtomicInteger<bool> m_autoPlay = true;
55 QAtomicInteger<bool> m_playing = false;
57 bool m_loading = false;
58
59 void play() {
60 m_playing = true;
61 }
62 void pause() {
63 m_playing = false;
64 }
65 void stop() {
66 QMutexLocker locker(&mutex);
67 m_playing = false;
68 currentBuffer = 0;
69 bufPos = 0;
70 m_currentLoop = 0;
71 }
72
73 void load();
74 void getBuffer(float *buf, int frames, int channels);
75
76private Q_SLOTS:
77 void bufferReady();
78 void finished();
79
80};
81
83
84#endif // QAMBIENTSOUND_P_H
std::unique_ptr< QAudioDecoder > decoder
QAtomicInteger< bool > m_playing
QAudioEngine * engine
QAmbientSoundPrivate(QObject *parent, int nchannels=2)
QList< QAudioBuffer > buffers
static QAmbientSoundPrivate * get(T *soundSource)
QAtomicInteger< bool > m_autoPlay
void getBuffer(float *buf, int frames, int channels)
std::unique_ptr< QFile > sourceDeviceFile
\inmodule QtCore
Definition qatomic.h:112
\inmodule QtSpatialAudio
\inmodule QtCore
Definition qmutex.h:313
\inmodule QtCore
Definition qmutex.h:281
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
GLenum GLuint GLenum GLsizei const GLchar * buf
#define Q_SLOTS