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
qpulseaudiosource_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//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists for the convenience
9// of other Qt classes. This header file may change from version to
10// version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef QPULSEAUDIOSOURCE_P_H
16#define QPULSEAUDIOSOURCE_P_H
17
18#include <QtCore/qtclasshelpermacros.h>
19
20#include <QtMultimedia/qaudio.h>
21#include <QtMultimedia/qaudiodevice.h>
22#include <QtMultimedia/private/qaudio_platform_implementation_support_p.h>
23#include <QtMultimedia/private/qaudiosystem_p.h>
24#include <QtMultimedia/private/qpulsehelpers_p.h>
25
27
28namespace QPulseAudioInternal {
29
30class QPulseAudioSource;
31using namespace QtMultimediaPrivate;
32
34{
35 using SourceType = QPulseAudioSource;
36
37 QPulseAudioSourceStream(QAudioDevice, const QAudioFormat &,
38 std::optional<qsizetype> ringbufferSize, QPulseAudioSource *parent,
39 float volume, std::optional<int32_t> hardwareBufferSize);
42
48
49 bool start(QIODevice *device);
50 bool start(AudioCallback &&);
52 void stop(ShutdownPolicy);
53 void suspend();
54 void resume();
55 bool open() const;
56
57 void updateStreamIdle(bool idle) override;
58
59private:
60 enum class StreamType : uint8_t
61 {
62 Ringbuffer,
63 Callback,
64 };
65
66 bool startStream(StreamType);
67 void installCallbacks(StreamType);
68 void uninstallCallbacks();
69
70 QPulseAudioSource *m_parent;
71 PAStreamHandle m_stream;
72 std::optional<AudioCallback> m_audioCallback;
73
74 // PulseAudio callbacks
75 void readCallbackRingbuffer(size_t bytesToRead);
76 void readCallbackAudioCallback(size_t bytesToRead);
77};
78
79////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
80
81class QPulseAudioSource final
82 : public QPlatformAudioSourceImplementationWithCallback<QPulseAudioSourceStream,
83 QPulseAudioSource>
84{
85 using BaseClass = QPlatformAudioSourceImplementationWithCallback<QPulseAudioSourceStream,
86 QPulseAudioSource>;
87
88public:
89 QPulseAudioSource(QAudioDevice, const QAudioFormat &, QObject *parent);
91
92 void start(QIODevice *device) override;
93 void start(AudioCallback &&) override;
94 QIODevice *start() override;
95
96private:
97 bool validatePulseaudio();
98};
99
100} // namespace QPulseAudioInternal
101
102QT_END_NAMESPACE
103
104#endif // QPULSEAUDIOSOURCE_P_H
The QAudioFormat class stores audio stream parameter information.
QList< QAudioDevice > findAudioOutputs() const override
QList< QAudioDevice > findAudioInputs() const override
QLatin1String backendName() const override
QPlatformAudioSink * createAudioSink(const QAudioDevice &, const QAudioFormat &, QObject *parent) override
QPlatformAudioSource * createAudioSource(const QAudioDevice &, const QAudioFormat &, QObject *parent) override
void start(QIODevice *device) override
void start(AudioCallback &&) override
Combined button and popup list for selecting options.