mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
proxy: fix cleanup
Keep track if the proxy is still in the core object map or not and make sure to only delete it once. In _remove, just remove the item from the object map if the proxy is destroyed. There is no need to call _proxy_destroy again (and do the extra unref)
This commit is contained in:
parent
2c13b3ecd2
commit
3712ebc434
2 changed files with 16 additions and 8 deletions
|
|
@ -807,6 +807,7 @@ struct pw_proxy {
|
||||||
* be removed from server */
|
* be removed from server */
|
||||||
unsigned int removed:1; /**< proxy was removed from server */
|
unsigned int removed:1; /**< proxy was removed from server */
|
||||||
unsigned int destroyed:1; /**< proxy was destroyed by client */
|
unsigned int destroyed:1; /**< proxy was destroyed by client */
|
||||||
|
unsigned int in_map:1; /**< proxy is in core object map */
|
||||||
|
|
||||||
struct spa_hook_list listener_list;
|
struct spa_hook_list listener_list;
|
||||||
struct spa_hook_list object_listener_list;
|
struct spa_hook_list object_listener_list;
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ int pw_proxy_init(struct pw_proxy *proxy, const char *type, uint32_t version)
|
||||||
type, version);
|
type, version);
|
||||||
goto error_clean;
|
goto error_clean;
|
||||||
}
|
}
|
||||||
|
proxy->in_map = true;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_clean:
|
error_clean:
|
||||||
|
|
@ -209,6 +210,15 @@ void pw_proxy_add_object_listener(struct pw_proxy *proxy,
|
||||||
spa_hook_list_append(&proxy->object_listener_list, listener, funcs, data);
|
spa_hook_list_append(&proxy->object_listener_list, listener, funcs, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void remove_from_map(struct pw_proxy *proxy)
|
||||||
|
{
|
||||||
|
if (proxy->in_map) {
|
||||||
|
if (proxy->core)
|
||||||
|
pw_map_remove(&proxy->core->objects, proxy->id);
|
||||||
|
proxy->in_map = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Destroy a proxy object
|
/** Destroy a proxy object
|
||||||
*
|
*
|
||||||
* \param proxy Proxy object to destroy
|
* \param proxy Proxy object to destroy
|
||||||
|
|
@ -236,10 +246,8 @@ void pw_proxy_destroy(struct pw_proxy *proxy)
|
||||||
proxy->removed = true;
|
proxy->removed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (proxy->removed) {
|
if (proxy->removed)
|
||||||
if (proxy->core)
|
remove_from_map(proxy);
|
||||||
pw_map_remove(&proxy->core->objects, proxy->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!proxy->zombie) {
|
if (!proxy->zombie) {
|
||||||
/* mark zombie and emit destroyed. No more
|
/* mark zombie and emit destroyed. No more
|
||||||
|
|
@ -267,10 +275,9 @@ void pw_proxy_remove(struct pw_proxy *proxy)
|
||||||
if (!proxy->destroyed)
|
if (!proxy->destroyed)
|
||||||
pw_proxy_emit_removed(proxy);
|
pw_proxy_emit_removed(proxy);
|
||||||
}
|
}
|
||||||
if (proxy->destroyed) {
|
if (proxy->destroyed)
|
||||||
proxy->destroyed = false;
|
remove_from_map(proxy);
|
||||||
pw_proxy_destroy(proxy);
|
|
||||||
}
|
|
||||||
pw_proxy_unref(proxy);
|
pw_proxy_unref(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue