4#ifndef QPIPEWIRE_AUDIOCONTEXTMANAGER_P_H
5#define QPIPEWIRE_AUDIOCONTEXTMANAGER_P_H
18#include <QtCore/qglobal.h>
24#include <pipewire/pipewire.h>
44 template <
typename Closure>
49 pw_thread_loop_lock(self->m_eventLoop.get());
50 auto unlock = qScopeGuard([&] {
51 pw_thread_loop_unlock(self->m_eventLoop.get());
76 PwThreadLoopHandle m_eventLoop;
77 void prepareEventLoop();
78 void startEventLoop();
82 PwContextHandle m_context;
83 void prepareContext();
87 void connectToPipewireInstance();
90 PwRegistryHandle m_registry;
91 struct spa_hook m_registryListener{};
92 std::unique_ptr<QAudioDeviceMonitor> m_deviceMonitor;
94 void startDeviceMonitor();
95 static void objectAddedCb(
void *data, uint32_t id, uint32_t permissions,
const char *type,
96 uint32_t version,
const struct spa_dict *props);
97 static void objectRemovedCb(
void *data, uint32_t id);
99 const spa_dict &props);
103 void startListenDefaultMetadataObject(
ObjectId, uint32_t version);
104 struct MetadataRecord
111 int handleDefaultMetadataObjectEvent(
const MetadataRecord &record);
113 PwMetadataHandle m_defaultMetadataObject;
114 struct spa_hook m_defaultMetadataObjectListener{};
116 QMutex m_activeStreamMutex;
117 std::set<std::shared_ptr<QPipewireAudioStream>> m_activeStreams;
118 void stopActiveStreams();
static bool minimumRequirementMet()
PwNodeHandle bindNode(ObjectId)
static QAudioDeviceMonitor & deviceMonitor()
static QAudioContextManager * instance()
void registerStreamReference(std::shared_ptr< QPipewireAudioStream >)
void unregisterStreamReference(const std::shared_ptr< QPipewireAudioStream > &)
PwMetadataHandle bindMetadata(ObjectId)
static auto withEventLoopLock(Closure &&c)
static bool isInPwThreadLoop()
static pw_loop * getEventLoop()
const PwCoreConnectionHandle & coreConnection() const
static std::atomic_int s_sequenceNumberAllocator
std::unique_ptr< pw_core, PwCoreConnectionDeleter > PwCoreConnectionHandle
StrongIdType< uint32_t, ObjectIdTag > ObjectId
StrongIdType< uint64_t, ObjectSerialTag > ObjectSerial
std::error_code make_error_code(int errnoValue=errno)
bool pw_check_library_version(int major, int minor, int micro)
QDebug operator<<(QDebug dbg, const pw_time &state)
QDebug operator<<(QDebug dbg, const spa_dict &dict)
QDebug operator<<(QDebug dbg, enum pw_stream_state)
QDebug operator<<(QDebug dbg, const spa_pod &pod)
q23::expected< void, int > asyncWait(pw_core *coreConnection, std::function< void()> handler)
pw_core_events coreEvents
q23::expected< bool, int > sync(pw_core *coreConnection, std::optional< std::chrono::nanoseconds > timeout={})
void operator()(Type *handle) const
ParamHandler paramHandler
NodeEventListener(PwNodeHandle, NodeHandler)
std::function< void(const struct pw_node_info *)> InfoHandler
void enumParams(spa_param_type)
std::function< void(int, uint32_t, uint32_t, uint32_t, const struct spa_pod *)> ParamHandler
void operator()(pw_core *handle) const
friend QDebug operator<<(QDebug dbg, const StrongIdType &self)
friend bool comparesEqual(const StrongIdType &lhs, const StrongIdType &rhs) noexcept
friend Qt::strong_ordering compareThreeWay(const StrongIdType &lhs, const StrongIdType &rhs) noexcept