service/pipewire: add registry and node ready properties

This commit is contained in:
outfoxxed 2025-01-14 15:08:29 -08:00
parent 8b6aa624a2
commit 6d8022b709
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
8 changed files with 137 additions and 8 deletions

View file

@ -10,6 +10,7 @@
#include <qobject.h>
#include <qsocketnotifier.h>
#include <qtmetamacros.h>
#include <qtypes.h>
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
@ -19,6 +20,19 @@ namespace {
Q_LOGGING_CATEGORY(logLoop, "quickshell.service.pipewire.loop", QtWarningMsg);
}
const pw_core_events PwCore::EVENTS = {
.version = PW_VERSION_CORE_EVENTS,
.info = nullptr,
.done = &PwCore::onSync,
.ping = nullptr,
.error = nullptr,
.remove_id = nullptr,
.bound_id = nullptr,
.add_mem = nullptr,
.remove_mem = nullptr,
.bound_props = nullptr,
};
PwCore::PwCore(QObject* parent): QObject(parent), notifier(QSocketNotifier::Read) {
qCInfo(logLoop) << "Creating pipewire event loop.";
pw_init(nullptr, nullptr);
@ -42,6 +56,8 @@ PwCore::PwCore(QObject* parent): QObject(parent), notifier(QSocketNotifier::Read
return;
}
pw_core_add_listener(this->core, &this->listener.hook, &PwCore::EVENTS, this);
qCInfo(logLoop) << "Linking pipewire event loop.";
// Tie the pw event loop into qt.
auto fd = pw_loop_get_fd(this->loop);
@ -79,6 +95,16 @@ void PwCore::poll() {
emit this->polled();
}
qint32 PwCore::sync(quint32 id) const {
// Seq param doesn't seem to do anything. Seq is instead the returned value.
return pw_core_sync(this->core, id, 0);
}
void PwCore::onSync(void* data, quint32 id, qint32 seq) {
auto* self = static_cast<PwCore*>(data);
emit self->synced(id, seq);
}
SpaHook::SpaHook() { // NOLINT
spa_zero(this->hook);
}