From 7e41d5aa52fcdd6d7bc32c7fc8cfffebf54b7d85 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Mon, 7 Oct 2019 16:47:54 +0300 Subject: [PATCH] monitor: add a flag to activate alsa devices In current pw master the behavior has been changed to not activate the "On" profile on alsa devices by default, because of the DeviceReserve D-Bus API implementation in media-session. This is a hack here to get the previous behavior. In the future we should have a way to configure profiles, as well as to pick a sensible default by autodetection. --- lib/wp/monitor.c | 19 ++++++++++++++++++- lib/wp/monitor.h | 1 + src/wireplumber.conf | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/wp/monitor.c b/lib/wp/monitor.c index e62f2203..98e5358a 100644 --- a/lib/wp/monitor.c +++ b/lib/wp/monitor.c @@ -302,6 +302,18 @@ node_new (struct object *dev, uint32_t id, return node; } +static void +set_profile(struct spa_device * dev, int index) +{ + char buf[1024]; + struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf)); + spa_device_set_param (dev, + SPA_PARAM_Profile, 0, + spa_pod_builder_add_object(&b, + SPA_TYPE_OBJECT_ParamProfile, 0, + SPA_PARAM_PROFILE_index, SPA_POD_Int(index))); +} + static struct object * device_new (WpMonitor *self, uint32_t id, const gchar *factory_name, WpProperties *properties, GError **error) @@ -362,6 +374,10 @@ device_new (WpMonitor *self, uint32_t id, const gchar *factory_name, return NULL; } + /* HACK this is very specific to the current alsa pcm profiles */ + if (self->flags & WP_MONITOR_FLAG_ACTIVATE_DEVICES) + set_profile ((struct spa_device *) dev->spa_dev->interface, 1); + return dev; } @@ -555,7 +571,8 @@ wp_monitor_start (WpMonitor *self, GError **error) core = g_weak_ref_get (&self->core); - g_debug ("WpMonitor:%p:%s starting monitor", self, self->factory_name); + g_debug ("WpMonitor:%p:%s starting monitor, flags 0x%x", self, + self->factory_name, self->flags); self->device = device_new (self, -1, self->factory_name, self->properties, &err); diff --git a/lib/wp/monitor.h b/lib/wp/monitor.h index 8f905627..5f70b457 100644 --- a/lib/wp/monitor.h +++ b/lib/wp/monitor.h @@ -16,6 +16,7 @@ G_BEGIN_DECLS typedef enum { /*< flags, prefix=WP_MONITOR_FLAG_ >*/ WP_MONITOR_FLAG_LOCAL_NODES = (1 << 0), WP_MONITOR_FLAG_USE_ADAPTER = (1 << 1), + WP_MONITOR_FLAG_ACTIVATE_DEVICES = (1 << 2), } WpMonitorFlags; #define WP_MONITOR_KEY_OBJECT_ID "wp.monitor.object.id" diff --git a/src/wireplumber.conf b/src/wireplumber.conf index daa0519a..920b6d8d 100644 --- a/src/wireplumber.conf +++ b/src/wireplumber.conf @@ -25,7 +25,7 @@ load-module C libwireplumber-module-mixer { load-module C libwireplumber-module-monitor { "factory": <"api.alsa.enum.udev">, - "flags": <["use-adapter"]> + "flags": <["use-adapter", "activate-devices"]> } load-module C libwireplumber-module-monitor {