Commit 7e41d5aa authored by George Kiagiadakis's avatar George Kiagiadakis

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.
parent bbca2ca2
...@@ -302,6 +302,18 @@ node_new (struct object *dev, uint32_t id, ...@@ -302,6 +302,18 @@ node_new (struct object *dev, uint32_t id,
return node; 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 * static struct object *
device_new (WpMonitor *self, uint32_t id, const gchar *factory_name, device_new (WpMonitor *self, uint32_t id, const gchar *factory_name,
WpProperties *properties, GError **error) WpProperties *properties, GError **error)
...@@ -362,6 +374,10 @@ device_new (WpMonitor *self, uint32_t id, const gchar *factory_name, ...@@ -362,6 +374,10 @@ device_new (WpMonitor *self, uint32_t id, const gchar *factory_name,
return NULL; 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; return dev;
} }
...@@ -555,7 +571,8 @@ wp_monitor_start (WpMonitor *self, GError **error) ...@@ -555,7 +571,8 @@ wp_monitor_start (WpMonitor *self, GError **error)
core = g_weak_ref_get (&self->core); 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, self->device = device_new (self, -1, self->factory_name, self->properties,
&err); &err);
......
...@@ -16,6 +16,7 @@ G_BEGIN_DECLS ...@@ -16,6 +16,7 @@ G_BEGIN_DECLS
typedef enum { /*< flags, prefix=WP_MONITOR_FLAG_ >*/ typedef enum { /*< flags, prefix=WP_MONITOR_FLAG_ >*/
WP_MONITOR_FLAG_LOCAL_NODES = (1 << 0), WP_MONITOR_FLAG_LOCAL_NODES = (1 << 0),
WP_MONITOR_FLAG_USE_ADAPTER = (1 << 1), WP_MONITOR_FLAG_USE_ADAPTER = (1 << 1),
WP_MONITOR_FLAG_ACTIVATE_DEVICES = (1 << 2),
} WpMonitorFlags; } WpMonitorFlags;
#define WP_MONITOR_KEY_OBJECT_ID "wp.monitor.object.id" #define WP_MONITOR_KEY_OBJECT_ID "wp.monitor.object.id"
......
...@@ -25,7 +25,7 @@ load-module C libwireplumber-module-mixer { ...@@ -25,7 +25,7 @@ load-module C libwireplumber-module-mixer {
load-module C libwireplumber-module-monitor { load-module C libwireplumber-module-monitor {
"factory": <"api.alsa.enum.udev">, "factory": <"api.alsa.enum.udev">,
"flags": <["use-adapter"]> "flags": <["use-adapter", "activate-devices"]>
} }
load-module C libwireplumber-module-monitor { load-module C libwireplumber-module-monitor {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment