From 00d1b85eea041c7a665bf96f8e7bfbbb86f2d5ed Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 9 Dec 2023 12:33:26 +0200 Subject: [PATCH] pulse-server: update all params only after enumeration complete For params that don't emit change events, the param enumeration does not start core sync, and its enumeration may be incomplete if a previous core sync completes first. Fix by always starting a core sync if we are updating params. This fixes dev_info.active_port being sporadically SPA_ID_INVALID if there is event pressure, which causes do_set_volume randomly set the volume on the node instead of setting it on the device. This can be triggered e.g. by shaking the volume slider in Pavucontrol with mouse. --- src/modules/module-protocol-pulse/manager.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/modules/module-protocol-pulse/manager.c b/src/modules/module-protocol-pulse/manager.c index 35a8be14b..eb1c667ae 100644 --- a/src/modules/module-protocol-pulse/manager.c +++ b/src/modules/module-protocol-pulse/manager.c @@ -290,6 +290,7 @@ static void device_event_info(void *data, const struct pw_device_info *info) { struct object *o = data; uint32_t i, changed = 0; + bool enumerate = false; pw_log_debug("object %p: id:%d change-mask:%08"PRIx64, o, o->this.id, info->change_mask); @@ -321,6 +322,9 @@ static void device_event_info(void *data, const struct pw_device_info *info) default: break; } + + enumerate = true; + add_param(&o->pending_list, info->params[i].seq, id, NULL); if (!(info->params[i].flags & SPA_PARAM_INFO_READ)) continue; @@ -331,7 +335,7 @@ static void device_event_info(void *data, const struct pw_device_info *info) info->params[i].seq = res; } } - if (changed) { + if (changed || enumerate) { o->changed += changed; core_sync(o->manager); } @@ -410,6 +414,7 @@ static void node_event_info(void *data, const struct pw_node_info *info) { struct object *o = data; uint32_t i, changed = 0; + bool enumerate = false; pw_log_debug("object %p: id:%d change-mask:%08"PRIx64, o, o->this.id, info->change_mask); @@ -449,6 +454,9 @@ static void node_event_info(void *data, const struct pw_node_info *info) default: break; } + + enumerate = true; + add_param(&o->pending_list, info->params[i].seq, id, NULL); if (!(info->params[i].flags & SPA_PARAM_INFO_READ)) continue; @@ -459,7 +467,7 @@ static void node_event_info(void *data, const struct pw_node_info *info) info->params[i].seq = res; } } - if (changed) { + if (changed || enumerate) { o->changed += changed; core_sync(o->manager); }