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 underflowCallback() { }
76 void overflowCallback() { }
77 void stateCallback() { }
78 void readCallbackRingbuffer(size_t bytesToRead);
79 void readCallbackAudioCallback(size_t bytesToRead);
80 void latencyUpdateCallback() { }
81};
82
83////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
84
85class QPulseAudioSource final
86 : public QPlatformAudioSourceImplementationWithCallback<QPulseAudioSourceStream,
87 QPulseAudioSource>
88{
89 using BaseClass = QPlatformAudioSourceImplementationWithCallback<QPulseAudioSourceStream,
90 QPulseAudioSource>;
91
92public:
93 QPulseAudioSource(QAudioDevice, const QAudioFormat &, QObject *parent);
94
95 void start(QIODevice *device) override;
96 void start(AudioCallback &&) override;
97 QIODevice *start() override;
98
99private:
100 bool validatePulseaudio();
101};
102
103} // namespace QPulseAudioInternal
104
105QT_END_NAMESPACE
106
107#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