service/pipewire: set device node volumes with device object

Fixes discrepancies between pulse and qs volumes, and volumes not
persisting across reboot or vt switches.
This commit is contained in:
outfoxxed 2024-08-27 01:28:28 -07:00
parent b40d4147e0
commit c60871a7fb
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
9 changed files with 380 additions and 74 deletions

View file

@ -0,0 +1,50 @@
#pragma once
#include <functional>
#include <pipewire/core.h>
#include <pipewire/device.h>
#include <pipewire/type.h>
#include <qcontainerfwd.h>
#include <qhash.h>
#include <qtmetamacros.h>
#include <spa/pod/builder.h>
#include "core.hpp"
#include "registry.hpp"
namespace qs::service::pipewire {
class PwDevice;
constexpr const char TYPE_INTERFACE_Device[] = PW_TYPE_INTERFACE_Device; // NOLINT
class PwDevice: public PwBindable<pw_device, TYPE_INTERFACE_Device, PW_VERSION_DEVICE> {
Q_OBJECT;
public:
void bindHooks() override;
void unbindHooks() override;
bool setVolumes(qint32 routeDevice, const QVector<float>& volumes);
bool setMuted(qint32 routeDevice, bool muted);
private slots:
void polled();
private:
static const pw_device_events EVENTS;
static void onInfo(void* data, const pw_device_info* info);
static void
onParam(void* data, qint32 seq, quint32 id, quint32 index, quint32 next, const spa_pod* param);
QHash<qint32, qint32> routeDeviceIndexes;
QHash<qint32, qint32> stagingIndexes;
void addDeviceIndexPairs(const spa_pod* param);
bool
setRouteProps(qint32 routeDevice, const std::function<void*(spa_pod_builder*)>& propsCallback);
SpaHook listener;
};
} // namespace qs::service::pipewire