lib: spa-device: emit object-removed & create-object in sequence when an object is updated

In some cases the monitors emit the object_info callback with the same id
and non-NULL info multiple times. For example, when an ACP profile changes from
output:analog-stereo+input:analog-stereo to just output:analog-stereo, it emits
object_info() with NULL info for the input node and object_info() with updated
properties and the same id as before for the output node.

This causes the spa-device here to emit create-object multiple times for the
same object and this breaks the name deduplication logic. To solve this, make
sure we emit object-removed before calling create-object a second time.

Fixes #500
This commit is contained in:
George Kiagiadakis 2024-05-31 17:04:18 +03:00
parent e6eed2dfb0
commit 9847ca129a

View file

@ -361,10 +361,21 @@ spa_device_event_object_info (void *data, uint32_t id,
type = spa_debug_type_short_name (info->type);
props = wp_properties_new_wrap_dict (info->props);
wp_debug_object (self, "object info: id:%u type:%s factory:%s",
id, type, info->factory_name);
if (id < self->managed_objs->len &&
g_ptr_array_index (self->managed_objs, id) != NULL) {
wp_debug_object (self, "object already exists, removing");
g_signal_emit (self, spa_device_signals[SIGNAL_OBJECT_REMOVED], 0, id);
wp_spa_device_store_managed_object (self, id, NULL);
}
g_signal_emit (self, spa_device_signals[SIGNAL_CREATE_OBJECT], 0,
id, type, info->factory_name, props);
}
else {
wp_debug_object (self, "object removed: id:%u", id);
g_signal_emit (self, spa_device_signals[SIGNAL_OBJECT_REMOVED], 0, id);
wp_spa_device_store_managed_object (self, id, NULL);
}