From 5485db09dcd7cb9bdcb39f89deb29f3f5ddf1bd7 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 9 May 2023 11:28:49 +0200 Subject: [PATCH] jack: Assign unique name to client_name First try to make a unique node name and then assign this as the client_name. This ensures we can detect a client name change because of a name conflict and we properly handle the JackNameNotUnique and JackUseExactName client open options. Also emit a new client event when the client name existed but was from another client and we made a unique name. Fixes #2833 --- pipewire-jack/src/pipewire-jack.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index 4053bd66a..59336a6bf 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -2925,7 +2925,7 @@ static void registry_event_global(void *data, uint32_t id, struct client *c = (struct client *) data; struct object *o, *ot, *op; const char *str; - bool is_first = false; + bool is_first = true; uint32_t serial; if (props == NULL) @@ -2950,12 +2950,6 @@ static void registry_event_global(void *data, uint32_t id, node_name = spa_dict_lookup(props, PW_KEY_NODE_NAME); - if (id == c->node_id) { - pw_log_debug("%p: add our node %d", c, id); - if (node_name != NULL) - snprintf(c->name, sizeof(c->name), "%s", node_name); - c->serial = serial; - } snprintf(o->node.node_name, sizeof(o->node.node_name), "%s", node_name); @@ -2991,6 +2985,11 @@ static void registry_event_global(void *data, uint32_t id, is_first = ot == NULL; snprintf(o->node.name, sizeof(o->node.name), "%s", tmp); } + if (id == c->node_id) { + pw_log_debug("%p: add our node %d", c, id); + snprintf(c->name, sizeof(c->name), "%s", o->node.name); + c->serial = serial; + } if ((str = spa_dict_lookup(props, PW_KEY_PRIORITY_SESSION)) != NULL) o->node.priority = pw_properties_parse_int(str);