mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
destroy proxies when global is removed
When a global is removed, also remove the proxies. We can have multiple proxies to a global otherwise when a client has a sequence of events queued from the server like this: Global 1 added Global 1 removed Global 1 added The proxy we added in the firt event would not be destroyed because the server did not know about it when global 1 was removed and then a second one would be made.
This commit is contained in:
parent
2329a4d323
commit
5ed4977b38
3 changed files with 31 additions and 8 deletions
|
|
@ -1165,8 +1165,10 @@ static void registry_event_global_remove(void *data, uint32_t id)
|
||||||
struct global *g;
|
struct global *g;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
if ((g = find_global(ctl, id, NULL, PW_TYPE_INTERFACE_Node)) == NULL)
|
if ((g = find_global(ctl, id, NULL, NULL)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (spa_streq(g->ginfo->type, PW_TYPE_INTERFACE_Node)) {
|
||||||
if ((name = pw_properties_get(g->props, PW_KEY_NODE_NAME)) == NULL)
|
if ((name = pw_properties_get(g->props, PW_KEY_NODE_NAME)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -1174,6 +1176,8 @@ static void registry_event_global_remove(void *data, uint32_t id)
|
||||||
ctl->default_sink[0] = '\0';
|
ctl->default_sink[0] = '\0';
|
||||||
if (spa_streq(name, ctl->default_source))
|
if (spa_streq(name, ctl->default_source))
|
||||||
ctl->default_source[0] = '\0';
|
ctl->default_source[0] = '\0';
|
||||||
|
}
|
||||||
|
pw_proxy_destroy(g->proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pw_registry_events registry_events = {
|
static const struct pw_registry_events registry_events = {
|
||||||
|
|
|
||||||
|
|
@ -633,8 +633,25 @@ static void registry_event_global(void *data, uint32_t id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void registry_event_global_remove(void *object, uint32_t id)
|
static struct global *find_global(struct file *file, uint32_t id)
|
||||||
{
|
{
|
||||||
|
struct global *g;
|
||||||
|
spa_list_for_each(g, &file->globals, link) {
|
||||||
|
if (g->id == id)
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void registry_event_global_remove(void *data, uint32_t id)
|
||||||
|
{
|
||||||
|
struct file *file = data;
|
||||||
|
struct global *g;
|
||||||
|
|
||||||
|
if ((g = find_global(file, id)) == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pw_proxy_destroy(g->proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pw_registry_events registry_events = {
|
static const struct pw_registry_events registry_events = {
|
||||||
|
|
|
||||||
|
|
@ -369,6 +369,8 @@ static int destroy_global(void *obj, void *data)
|
||||||
if (global == NULL)
|
if (global == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (global->proxy)
|
||||||
|
pw_proxy_destroy(global->proxy);
|
||||||
pw_map_insert_at(&global->rd->globals, global->id, NULL);
|
pw_map_insert_at(&global->rd->globals, global->id, NULL);
|
||||||
pw_properties_free(global->properties);
|
pw_properties_free(global->properties);
|
||||||
free(global->type);
|
free(global->type);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue