From 8e6b276d51428db0c80ee798f7f06388d3eced55 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 6 Jul 2020 17:26:01 +0200 Subject: [PATCH] alsa-monitor: parse device events Parse the device events and set the Props from the ObjectConfig as the Props param on the node. This propagates the software volume from the device to the node. --- src/examples/media-session/alsa-monitor.c | 32 ++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/examples/media-session/alsa-monitor.c b/src/examples/media-session/alsa-monitor.c index 41a77774f..1dce4d653 100644 --- a/src/examples/media-session/alsa-monitor.c +++ b/src/examples/media-session/alsa-monitor.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -41,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -351,10 +353,38 @@ static void alsa_device_object_info(void *data, uint32_t id, } } +static void alsa_device_event(void *data, const struct spa_event *event) +{ + struct device *device = data; + struct node *node; + uint32_t id, type; + struct spa_pod *props = NULL; + + if (spa_pod_parse_object(&event->pod, + SPA_TYPE_EVENT_Device, &type, + SPA_EVENT_DEVICE_Object, SPA_POD_Int(&id), + SPA_EVENT_DEVICE_Props, SPA_POD_OPT_Pod(&props)) < 0) + return; + + if ((node = alsa_find_node(device, id)) == NULL) + return; + + switch (type) { + case SPA_DEVICE_EVENT_ObjectConfig: + if (props) + pw_node_set_param((struct pw_node*)node->snode->obj.proxy, + SPA_PARAM_Props, 0, props); + break; + default: + break; + } +} + static const struct spa_device_events alsa_device_events = { SPA_VERSION_DEVICE_EVENTS, .info = alsa_device_info, - .object_info = alsa_device_object_info + .object_info = alsa_device_object_info, + .event = alsa_device_event, }; static struct device *alsa_find_device(struct impl *impl, uint32_t id)