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
qandroidaudiosink_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 QANDROIDAUDIOOUTPUT_H
5#define QANDROIDAUDIOOUTPUT_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 <private/qaudio_platform_implementation_support_p.h>
19
21
22#include <memory>
23
24QT_BEGIN_NAMESPACE
25
26namespace QtAAudio {
27
28class QAndroidAudioSink;
29
30class QAndroidAudioSinkStream final : public std::enable_shared_from_this<QAndroidAudioSinkStream>,
31 public QtMultimediaPrivate::QPlatformAudioSinkStream
32{
33 using QPlatformAudioSinkStream = QtMultimediaPrivate::QPlatformAudioSinkStream;
34 using AudioEndpointRole = QtMultimediaPrivate::AudioEndpointRole;
35
36public:
37 explicit QAndroidAudioSinkStream(QAudioDevice, const QAudioFormat &,
38 std::optional<qsizetype> ringbufferSize,
39 QAndroidAudioSink *parent, float volume,
40 std::optional<int32_t> hardwareBufferFrames,
42 Q_DISABLE_COPY_MOVE(QAndroidAudioSinkStream)
43
44 bool open();
45
46 bool start(QIODevice *device);
48 bool start(AudioCallback cb);
49
50 void suspend();
51 void resume();
52 void stop(ShutdownPolicy policy);
53
54 using QPlatformAudioSinkStream::bytesFree;
55 using QPlatformAudioSinkStream::processedDuration;
56 using QPlatformAudioSinkStream::ringbufferSizeInBytes;
57 using QPlatformAudioSinkStream::setVolume;
58
59private:
60 void stop();
61 void reset();
62
63 // QPlatformAudioSinkStream overrides
64 void updateStreamIdle(bool arg) override;
65
66 QSpan<std::byte> getHostSpan(void *audioData, int numFrames) const noexcept QT_MM_NONBLOCKING;
67 aaudio_data_callback_result_t processRingbuffer(QSpan<std::byte> audioSpan,
68 int numFrames) noexcept QT_MM_NONBLOCKING;
69 aaudio_data_callback_result_t processCallback(QSpan<std::byte> audioSpan) noexcept QT_MM_NONBLOCKING;
70 void handleError(aaudio_result_t error);
71
72 QAndroidAudioSink *m_parent{ nullptr };
73 std::shared_ptr<QAndroidAudioSinkStream> m_self;
74
75 std::optional<AudioCallback> m_audioCallback;
76
77 AudioEndpointRole m_role;
78
79 std::unique_ptr<QtAAudio::Stream> m_stream;
80
81 std::optional<QAudioFormat> m_hostFormat;
82};
83
84class QAndroidAudioSink final
85 : public QtMultimediaPrivate::QPlatformAudioSinkImplementation<QAndroidAudioSinkStream,
86 QAndroidAudioSink>
87{
88 using BaseClass = QtMultimediaPrivate::QPlatformAudioSinkImplementation<QAndroidAudioSinkStream,
89 QAndroidAudioSink>;
90
91public:
92 QAndroidAudioSink(QAudioDevice device, const QAudioFormat &format, QObject *parent);
94};
95
96}
97
98QT_END_NAMESPACE
99
100#endif // QANDROIDAUDIOOUTPUT_H
QAndroidAudioSinkStream(QAudioDevice, const QAudioFormat &, std::optional< qsizetype > ringbufferSize, QAndroidAudioSink *parent, float volume, std::optional< int32_t > hardwareBufferFrames, AudioEndpointRole)
void stop(ShutdownPolicy policy)
void updateStreamIdle(bool arg) override
QAndroidAudioSink(QAudioDevice device, const QAudioFormat &format, QObject *parent)
Combined button and popup list for selecting options.