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 <QtCore/qglobal.h>
19#include <QtMultimedia/qaudioformat.h>
20#include <QtMultimedia/private/qaudio_rtsan_support_p.h>
21
24
25#include <pipewire/stream.h>
26
28
29namespace QtPipeWire {
30
32{
33protected:
34 explicit QPipewireAudioStream(const QAudioFormat &);
36
38
40
41 enum class StreamType : uint8_t
42 {
45 };
46
47 // stream control
48 void createStream(QSpan<spa_dict_item> extraProperties,
49 std::optional<int32_t> hardwareBufferFrames, const char *streamName,
51 bool connectStream(ObjectSerial target, spa_direction);
52 void disconnectStream();
53
54 void resetStream();
55
56public:
57 void suspend();
58 void resume();
59 bool hasStream() const;
60
61protected:
62 // stream callbacks
63 virtual void processRingbuffer() = 0;
64 virtual void processCallback() = 0;
65 virtual void stateChanged(pw_stream_state oldState, pw_stream_state state,
66 const char *error) = 0;
67
68 // stream members
69 pw_stream_events stream_events{};
71
72 // device observer
75 virtual void handleDeviceRemoved() = 0;
77
78 // xrun detector
79 // CAVEAT: has to be called at the beginning of a render callback
80 // streams will have to increment m_totalNumberOfFrames internally
81 void performXRunDetection(uint64_t framesPerBuffer) noexcept QT_MM_NONBLOCKING;
82 virtual void xrunOccurred(int xrunCount) = 0;
86
87 // total samples delivered from/sent to the backend
88 void addFramesHandled(uint64_t);
90
91 friend class QAudioContextManager; // to access m_self
93};
94
95} // namespace QtPipeWire
96
97QT_END_NAMESPACE
98
99#endif
void registerStreamReference(std::shared_ptr< QPipewireAudioStream >)
void unregisterStreamReference(const std::shared_ptr< QPipewireAudioStream > &)
const PwCoreConnectionHandle & coreConnection() const
Q_STATIC_LOGGING_CATEGORY(lcPipewireRegistry, "qt.multimedia.pipewire.registry")
Q_GLOBAL_STATIC(QAudioContextManager, s_audioContextInstance)
std::unique_ptr< pw_core, PwCoreConnectionDeleter > PwCoreConnectionHandle
StrongIdType< uint32_t, ObjectIdTag > ObjectId
StrongIdType< uint64_t, ObjectSerialTag > ObjectSerial
std::shared_ptr< ObjectRemoveObserver > SharedObjectRemoveObserver
std::error_code make_error_code(int errnoValue=errno)
#define __has_include(x)
bool pw_check_library_version(int major, int minor, int micro)
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