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
qdrawavaudiodecoder_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 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 QDRAWAVAUDIODECODER_P_H
5#define QDRAWAVAUDIODECODER_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 <QtMultimedia/private/qplatformaudiodecoder_p.h>
19#include <QtCore/qspan.h>
20#include <QtCore/qurl.h>
21#include <QtCore/private/qexpected_p.h>
22
23#include <atomic>
24#include <memory>
25
26QT_BEGIN_NAMESPACE
27
28class QAudioDecoder;
29class QIODevice;
30
31namespace QtMultimediaPrivate {
32
35 const QAudioFormat &requestedFormat);
36
37} // namespace QtMultimediaPrivate
38
39class QDrWavAudioDecoder final : public QPlatformAudioDecoder
40{
41public:
42 explicit QDrWavAudioDecoder(QAudioDecoder *parent);
44
45 // Source management
46 QUrl source() const override { return m_source; }
47 void setSource(const QUrl &) override;
48
49 QIODevice *sourceDevice() const override { return m_sourceDevice; }
50 void setSourceDevice(QIODevice *) override;
51
52 // Lifecycle
53 void start() override;
54 void stop() override;
55
56 // Format
57 QAudioFormat audioFormat() const override { return m_audioFormat; }
58 void setAudioFormat(const QAudioFormat &) override;
59
60 // Buffer pull model
61 QAudioBuffer read() override;
62
63 // Metadata
64 bool canReadQrc() const override { return true; }
65
66private:
67 using QDrWavDecodeResult = QtMultimediaPrivate::QDrWavDecodeResult;
68
69 QDrWavDecodeResult loadAndDecodeFile(const QUrl &, QIODevice *, const QAudioFormat &,
70 std::shared_ptr<std::atomic_bool> decodingStopped);
71
72 // Handle decode completion
73 void onDecodeFinished(QDrWavDecodeResult, const std::atomic_bool &decodingStopped);
74
75 QUrl m_source;
76 QIODevice *m_sourceDevice = nullptr;
77 QAudioFormat m_audioFormat;
78
79 // Decoded result
80 QAudioBuffer m_buffer;
81
82 std::shared_ptr<std::atomic_bool> m_decodingStopped;
83};
84
85QT_END_NAMESPACE
86
87#endif // QDRAWAVAUDIODECODER_P_H
bool canReadQrc() const override
QAudioFormat audioFormat() const override
void setSource(const QUrl &) override
void setAudioFormat(const QAudioFormat &) override
QAudioBuffer read() override
QIODevice * sourceDevice() const override
QUrl source() const override
void setSourceDevice(QIODevice *) override
QDrWavAudioDecoder(QAudioDecoder *parent)
Combined button and popup list for selecting options.
static QDrWavDecodeResult makeResourceError(const QString &message)
static QDrWavDecodeResult makeFormatError(const QString &message)
QDrWavDecodeResult loadWaveAndDecodeData(QSpan< const std::byte > data, const QAudioFormat &requestedFormat)