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)