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
qsoundeffectsynchronous_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSOUNDEFFECTSYNCHRONOUS_P_H
5#define QSOUNDEFFECTSYNCHRONOUS_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 purely as an
12// implementation detail. 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 <QtCore/qiodevice.h>
19#include <QtMultimedia/qaudiobuffer.h>
20#include <QtMultimedia/qaudiosink.h>
21#include <QtMultimedia/private/qsoundeffect_p.h>
22
24
26 public QSoundEffectPrivate
27{
28 struct AudioSinkDeleter
29 {
30 void operator()(QAudioSink *sink) const;
31 };
32
33public:
34 QSoundEffectPrivateSynchronous(QSoundEffect *q, const QAudioDevice &audioDevice);
35 ~QSoundEffectPrivateSynchronous() override;
36
37 qint64 readData(char *data, qint64 len) override;
38 qint64 writeData(const char *data, qint64 len) override;
39 qint64 size() const override;
40 qint64 bytesAvailable() const override;
41 bool isSequential() const override;
42 bool atEnd() const override;
43
44 void setLoopsRemaining(int loopsRemaining);
45 void setStatus(QSoundEffect::Status status);
46 void setPlaying(bool playing);
47 bool updateAudioOutput();
48
49 void decoderError();
50 void sampleReady(SharedSamplePtr);
51
52 int loopCount() const override;
53 bool setLoopCount(int loopCount) override;
54
55 int loopsRemaining() const override;
56 float volume() const override;
57 bool setVolume(float volume) override;
58
59 bool muted() const override;
60 bool setMuted(bool muted) override;
61
62 void play() override;
63
64 void stop() override;
65 bool playing() const override;
66
67 bool setAudioDevice(QAudioDevice device) override;
68
69 bool setSource(const QUrl &url, QSampleCache &sampleCache) override;
70
71 QSoundEffect::Status status() const override;
72 QUrl url() const override;
73 QAudioDevice audioDevice() const override;
74
75private:
76 void stateChanged(QAudio::State);
77
78 QSoundEffect *q_ptr;
79 QAudioDevice m_audioDevice;
80
81 int m_loopCount = 1;
82 int m_runningCount = 0;
83 bool m_playing = false;
84 std::unique_ptr<QAudioSink, AudioSinkDeleter> m_audioSink;
85 SharedSamplePtr m_sample;
86 QAudioBuffer m_audioBuffer;
87 bool m_muted = false;
88 float m_volume = 1.0;
89 qint64 m_offset = 0;
90
91 QFuture<void> m_sampleLoadFuture;
92 QUrl m_url;
93 QSoundEffect::Status m_status = QSoundEffect::Null;
94 bool m_sampleReady = false;
95};
96
97QT_END_NAMESPACE
98
99#endif // QSOUNDEFFECTSYNCHRONOUS_P_H