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 void setSource(QUrl, QSampleCache &) override;
70
71 QSoundEffect::Status status() const override;
72 QAudioDevice audioDevice() const override;
73
74private:
75 void stateChanged(QAudio::State);
76
77 QSoundEffect *q_ptr;
78 QAudioDevice m_audioDevice;
79
80 int m_loopCount = 1;
81 int m_runningCount = 0;
82 bool m_playing = false;
83 std::unique_ptr<QAudioSink, AudioSinkDeleter> m_audioSink;
84 SharedSamplePtr m_sample;
85 QAudioBuffer m_audioBuffer;
86 bool m_muted = false;
87 float m_volume = 1.0;
88 qint64 m_offset = 0;
89
90 QFuture<void> m_sampleLoadFuture;
91 QUrl m_url; // unresolved url
92 QSoundEffect::Status m_status = QSoundEffect::Null;
93 bool m_sampleReady = false;
94};
95
96QT_END_NAMESPACE
97
98#endif // QSOUNDEFFECTSYNCHRONOUS_P_H
Combined button and popup list for selecting options.