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_async_support_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_ASYNC_SUPPORT_P_H
5#define QPIPEWIRE_ASYNC_SUPPORT_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/qpipewire_support_p.h>
19#include <QtCore/private/qexpected_p.h>
20#include <QtCore/qglobal.h>
21#include <QtCore/qsemaphore.h>
22
23#include <spa/utils/hook.h>
24
25#include <functional>
26
27QT_BEGIN_NAMESPACE
28
29namespace QtPipeWire {
30
32{
33 explicit SpaListenerBase();
35
36 int sequenceNumber() const { return m_sequenceNumber; }
37
38protected:
39 void removeHooks();
40
42 spa_hook m_listenerHook{};
43};
44
46{
47 using InfoHandler = std::function<void(const struct pw_node_info *)>;
48 using ParamHandler = std::function<void(int /*seq*/, uint32_t /*id*/, uint32_t /*index*/,
49 uint32_t /*next*/, const struct spa_pod * /*param*/)>;
50
52 {
53 InfoHandler infoHandler;
54 ParamHandler paramHandler;
55 };
56
59
61
62private:
63 PwNodeHandle m_node;
64 NodeHandler m_handler;
65
66 static void onInfo(void *userData, const struct pw_node_info *);
67 static void onParam(void *userData, int seq, uint32_t id, uint32_t index, uint32_t next,
68 const struct spa_pod *);
69};
70
79
81{
83 q23::expected<void, int> asyncWait(pw_core *coreConnection, std::function<void()> handler);
84
85private:
86 int m_seqnum = -1;
87 std::function<void()> m_handler;
88};
89
91{
93 q23::expected<bool, int> sync(pw_core *coreConnection,
94 std::optional<std::chrono::nanoseconds> timeout = {});
95
96private:
97 QSemaphore m_semaphore;
98};
99
100} // namespace QtPipeWire
101
102QT_END_NAMESPACE
103
104#endif // QPIPEWIRE_ASYNC_SUPPORT_P_H
Combined button and popup list for selecting options.
static std::atomic_int s_sequenceNumberAllocator
q23::expected< void, int > asyncWait(pw_core *coreConnection, std::function< void()> handler)
q23::expected< bool, int > sync(pw_core *coreConnection, std::optional< std::chrono::nanoseconds > timeout={})
NodeEventListener(PwNodeHandle, NodeHandler)
std::function< void(const struct pw_node_info *)> InfoHandler