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
qpipewire_audiostream_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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 QPIPEWIRE_AUDIOSTREAM_P_H
5#define QPIPEWIRE_AUDIOSTREAM_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/qaudiosystem_p.h>
19#include <QtMultimedia/private/qpipewire_audiodevicemonitor_p.h>
20#include <QtMultimedia/private/qpipewire_support_p.h>
21#include <QtMultimedia/qaudioformat.h>
22#include <QtCore/qglobal.h>
23
24#include <pipewire/stream.h>
25
26QT_BEGIN_NAMESPACE
27
28namespace QtPipeWire {
29
31
33{
34protected:
35 explicit QPipewireAudioStream(const QAudioFormat &);
37
39
41
42 enum class StreamType : uint8_t
43 {
46 };
47
48 // stream control
49 void createStream(QSpan<spa_dict_item> extraProperties,
50 std::optional<NativePeriodFrames> nativePeriodFrames, const char *streamName,
52 bool connectStream(ObjectSerial target, spa_direction);
53 void disconnectStream();
54
55 void resetStream();
56
57public:
58 void suspend();
59 void resume();
60 bool hasStream() const;
61
62protected:
63 // stream callbacks
64 virtual void processRingbuffer() = 0;
65 virtual void processCallback() = 0;
66 virtual void stateChanged(pw_stream_state oldState, pw_stream_state state,
67 const char *error) = 0;
68
69 // stream members
70 pw_stream_events stream_events{};
72
73 // device observer
74 [[nodiscard]] bool registerDeviceObserver(ObjectSerial);
76 virtual void handleDeviceRemoved() = 0;
78
79 // xrun detector
80 // CAVEAT: has to be called at the beginning of a render callback
81 // streams will have to increment m_totalNumberOfFrames internally
82 void performXRunDetection(uint64_t framesPerBuffer) noexcept Q_DECL_NONBLOCKING_FUNCTION;
83 virtual void xrunOccurred(int xrunCount) = 0;
87
88 // total samples delivered from/sent to the backend
89 void addFramesHandled(uint64_t);
91
92 friend class QAudioContextManager; // to access m_self
94
95 virtual void finalizeStream() = 0;
96};
97
98} // namespace QtPipeWire
99
100QT_END_NAMESPACE
101
102#endif
#define __has_include(x)
#define PW_KEY_NODE_FORCE_QUANTUM
void createStream(QSpan< spa_dict_item > extraProperties, std::optional< NativePeriodFrames > nativePeriodFrames, const char *streamName, StreamType=StreamType::Ringbuffer)
SharedObjectRemoveObserver m_deviceRemovalObserver
void performXRunDetection(uint64_t framesPerBuffer) noexcept Q_DECL_NONBLOCKING_FUNCTION
virtual void stateChanged(pw_stream_state oldState, pw_stream_state state, const char *error)=0
virtual void processRingbuffer()=0
std::shared_ptr< QPipewireAudioStream > m_self
virtual void xrunOccurred(int xrunCount)=0
bool connectStream(ObjectSerial target, spa_direction)
virtual void handleDeviceRemoved()=0