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
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
18#include <QtSpatialAudio/qambientsound.h>
19#include <QtSpatialAudio/private/qtspatialaudioglobal_p.h>
20#include <QtCore/qmutex.h>
21#include <QtCore/qurl.h>
22#include <QtCore/qfile.h>
23#include <QtCore/private/qobject_p.h>
24#include <QtMultimedia/qaudiodecoder.h>
25#include <QtMultimedia/qaudiobuffer.h>
26
27#include <atomic>
28#include <memory>
29
30QT_BEGIN_NAMESPACE
31
32class QAudioEngine;
33
35{
36 Q_DECLARE_PUBLIC(QAmbientSound)
37
38public:
40
41 template <typename T>
43 {
44 return soundSource ? soundSource->d_func() : nullptr;
45 }
46
48 float volume = 1.;
49 int nchannels = 2;
52 QAudioEngine *engine = nullptr;
53
56 int bufPos = 0;
59 int sourceId = -1; // kInvalidSourceId
60
61 std::atomic_bool m_autoPlay = true;
62 std::atomic_bool m_playing = false;
63 std::atomic_int m_loops = 1;
64 std::atomic_bool m_loading = false;
65
66 void play() {
67 m_playing = true;
68 }
69 void pause() {
70 m_playing = false;
71 }
72 void stop() {
73 QMutexLocker locker(&mutex);
74 m_playing = false;
75 currentBuffer = 0;
76 bufPos = 0;
77 m_currentLoop = 0;
78 }
79
80 void load();
81 void getBuffer(float *buf, int frames, int channels);
82};
83
84QT_END_NAMESPACE
85
86#endif // QAMBIENTSOUND_P_H
std::unique_ptr< QAudioDecoder > decoder
QAudioEngine * engine
std::atomic_int m_loops
QList< QAudioBuffer > buffers
std::atomic_bool m_playing
std::atomic_bool m_loading
void getBuffer(float *buf, int frames, int channels)
std::unique_ptr< QFile > sourceDeviceFile
std::atomic_bool m_autoPlay