service/pipewire: add pipewire module

This commit is contained in:
outfoxxed 2024-05-19 02:23:11 -07:00
parent bba8cb8a7d
commit 3e80c4a4fd
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
21 changed files with 2476 additions and 4 deletions

View file

@ -0,0 +1,59 @@
#pragma once
#include <pipewire/context.h>
#include <pipewire/core.h>
#include <pipewire/loop.h>
#include <pipewire/proxy.h>
#include <qloggingcategory.h>
#include <qobject.h>
#include <qsocketnotifier.h>
#include <qtclasshelpermacros.h>
#include <qtmetamacros.h>
#include <qtypes.h>
#include <spa/utils/hook.h>
namespace qs::service::pipewire {
class PwCore: public QObject {
Q_OBJECT;
public:
explicit PwCore(QObject* parent = nullptr);
~PwCore() override;
Q_DISABLE_COPY_MOVE(PwCore);
[[nodiscard]] bool isValid() const;
pw_loop* loop = nullptr;
pw_context* context = nullptr;
pw_core* core = nullptr;
private slots:
void poll() const;
private:
QSocketNotifier notifier;
};
template <typename T>
class PwObject {
public:
explicit PwObject(T* object = nullptr): object(object) {}
~PwObject() {
pw_proxy_destroy(reinterpret_cast<pw_proxy*>(this->object)); // NOLINT
}
Q_DISABLE_COPY_MOVE(PwObject);
T* object;
};
class SpaHook {
public:
explicit SpaHook();
void remove();
spa_hook hook;
};
} // namespace qs::service::pipewire