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/qaudio_rtsan_support_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{
32protected:
33 explicit QPipewireAudioStream(const QAudioFormat &);
35
37
39
40 enum class StreamType : uint8_t
41 {
44 };
45
46 // stream control
47 void createStream(QSpan<spa_dict_item> extraProperties,
48 std::optional<int32_t> hardwareBufferFrames, const char *streamName,
50 bool connectStream(ObjectSerial target, spa_direction);
51 void disconnectStream();
52
53 void resetStream();
54
55public:
56 void suspend();
57 void resume();
58 bool hasStream() const;
59
60protected:
61 // stream callbacks
62 virtual void processRingbuffer() = 0;
63 virtual void processCallback() = 0;
64 virtual void stateChanged(pw_stream_state oldState, pw_stream_state state,
65 const char *error) = 0;
66
67 // stream members
68 pw_stream_events stream_events{};
70
71 // device observer
72 [[nodiscard]] bool registerDeviceObserver(ObjectSerial);
74 virtual void handleDeviceRemoved() = 0;
76
77 // xrun detector
78 // CAVEAT: has to be called at the beginning of a render callback
79 // streams will have to increment m_totalNumberOfFrames internally
80 void performXRunDetection(uint64_t framesPerBuffer) noexcept QT_MM_NONBLOCKING;
81 virtual void xrunOccurred(int xrunCount) = 0;
85
86 // total samples delivered from/sent to the backend
87 void addFramesHandled(uint64_t);
89
90 friend class QAudioContextManager; // to access m_self
92
93 virtual void finalizeStream() = 0;
94};
95
96} // namespace QtPipeWire
97
98QT_END_NAMESPACE
99
100#endif
#define __has_include(x)
#define PW_KEY_NODE_FORCE_QUANTUM
void performXRunDetection(uint64_t framesPerBuffer) noexcept QT_MM_NONBLOCKING
void createStream(QSpan< spa_dict_item > extraProperties, std::optional< int32_t > hardwareBufferFrames, const char *streamName, StreamType=StreamType::Ringbuffer)
SharedObjectRemoveObserver m_deviceRemovalObserver
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