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/qaudiosystem_p.h>
20#include <QtMultimedia/private/qpipewire_audiodevicemonitor_p.h>
21#include <QtMultimedia/private/qpipewire_support_p.h>
22#include <QtMultimedia/qaudioformat.h>
23#include <QtCore/qglobal.h>
24
25#include <pipewire/stream.h>
26
27QT_BEGIN_NAMESPACE
28
29namespace QtPipeWire {
30
32
34{
35protected:
36 explicit QPipewireAudioStream(const QAudioFormat &);
38
40
42
43 enum class StreamType : uint8_t
44 {
47 };
48
49 // stream control
50 void createStream(QSpan<spa_dict_item> extraProperties,
51 std::optional<NativePeriodFrames> nativePeriodFrames, const char *streamName,
53 bool connectStream(ObjectSerial target, spa_direction);
54 void disconnectStream();
55
56 void resetStream();
57
58public:
59 void suspend();
60 void resume();
61 bool hasStream() const;
62
63protected:
64 // stream callbacks
65 virtual void processRingbuffer() = 0;
66 virtual void processCallback() = 0;
67 virtual void stateChanged(pw_stream_state oldState, pw_stream_state state,
68 const char *error) = 0;
69
70 // stream members
71 pw_stream_events stream_events{};
73
74 // device observer
75 [[nodiscard]] bool registerDeviceObserver(ObjectSerial);
77 virtual void handleDeviceRemoved() = 0;
79
80 // xrun detector
81 // CAVEAT: has to be called at the beginning of a render callback
82 // streams will have to increment m_totalNumberOfFrames internally
83 void performXRunDetection(uint64_t framesPerBuffer) noexcept QT_MM_NONBLOCKING;
84 virtual void xrunOccurred(int xrunCount) = 0;
88
89 // total samples delivered from/sent to the backend
90 void addFramesHandled(uint64_t);
92
93 friend class QAudioContextManager; // to access m_self
95
96 virtual void finalizeStream() = 0;
97};
98
99} // namespace QtPipeWire
100
101QT_END_NAMESPACE
102
103#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)
void performXRunDetection(uint64_t framesPerBuffer) noexcept QT_MM_NONBLOCKING
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