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
27QT_BEGIN_NAMESPACE
28
29class QAudioEngine;
30
32{
33 Q_DECLARE_PUBLIC(QAmbientSound)
34
35public:
37
38 template <typename T>
40 {
41 return soundSource ? soundSource->d_func() : nullptr;
42 }
43
45 float volume = 1.;
46 int nchannels = 2;
49 QAudioEngine *engine = nullptr;
50
53 int bufPos = 0;
56 int sourceId = -1; // kInvalidSourceId
57
61 bool m_loading = false;
62
63 void play() {
64 m_playing = true;
65 }
66 void pause() {
67 m_playing = false;
68 }
69 void stop() {
70 QMutexLocker locker(&mutex);
71 m_playing = false;
72 currentBuffer = 0;
73 bufPos = 0;
74 m_currentLoop = 0;
75 }
76
77 void load();
78 void getBuffer(float *buf, int frames, int channels);
79};
80
81QT_END_NAMESPACE
82
83#endif // QAMBIENTSOUND_P_H
std::unique_ptr< QAudioDecoder > decoder
QAtomicInteger< bool > m_playing
QAudioEngine * engine
QList< QAudioBuffer > buffers
QAtomicInteger< bool > m_autoPlay
void getBuffer(float *buf, int frames, int channels)
std::unique_ptr< QFile > sourceDeviceFile