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 <QtCore/qglobal.h>
19#include <QtCore/qsemaphore.h>
20#include <QtCore/private/qexpected_p.h>
21
23
24#include <spa/utils/hook.h>
25
26#include <functional>
27
28QT_BEGIN_NAMESPACE
29
30namespace QtPipeWire {
31
33{
34 explicit SpaListenerBase();
36
37 int sequenceNumber() const { return m_sequenceNumber; }
38
39protected:
40 void removeHooks();
41
43 spa_hook m_listenerHook{};
44};
45
46struct NodeEventListener final : SpaListenerBase
47{
48 using InfoHandler = std::function<void(const struct pw_node_info *)>;
49 using ParamHandler = std::function<void(int /*seq*/, uint32_t /*id*/, uint32_t /*index*/,
50 uint32_t /*next*/, const struct spa_pod * /*param*/)>;
51
57
60
62
63private:
64 PwNodeHandle m_node;
65 NodeHandler m_handler;
66
67 static void onInfo(void *userData, const struct pw_node_info *);
68 static void onParam(void *userData, int seq, uint32_t id, uint32_t index, uint32_t next,
69 const struct spa_pod *);
70};
71
73{
74protected:
77
78 pw_core_events coreEvents{};
79};
80
82{
84 q23::expected<void, int> asyncWait(pw_core *coreConnection, std::function<void()> handler);
85
86private:
87 int m_seqnum = -1;
88 std::function<void()> m_handler;
89};
90
92{
94 q23::expected<bool, int> sync(pw_core *coreConnection,
95 std::optional<std::chrono::nanoseconds> timeout = {});
96
97private:
98 QSemaphore m_semaphore;
99};
100
101} // namespace QtPipeWire
102
103QT_END_NAMESPACE
104
105#endif // QPIPEWIRE_ASYNC_SUPPORT_P_H
static std::atomic_int s_sequenceNumberAllocator
std::error_code make_error_code(int errnoValue=errno)
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
std::function< void(int, uint32_t, uint32_t, uint32_t, const struct spa_pod *)> ParamHandler