From 3fe31862efd514b9a535ae536e7f1264324ab7e9 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 5 Nov 2020 20:19:04 +0100 Subject: [PATCH] proxy: remove hooks in _destroy Callers of _destroy should be able to reply on the fact that no more events will be emited on the proxy whitout being required to remove the hooks themselves. Because of the refcount in the proxy, it can stay alive after the _destroy and being used to emit events, like emit an error in protocol-native. Fixes #366 --- src/pipewire/proxy.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pipewire/proxy.c b/src/pipewire/proxy.c index fc47577c4..7b761a6e2 100644 --- a/src/pipewire/proxy.c +++ b/src/pipewire/proxy.c @@ -231,6 +231,8 @@ static inline void remove_from_map(struct pw_proxy *proxy) SPA_EXPORT void pw_proxy_destroy(struct pw_proxy *proxy) { + struct spa_hook *h; + pw_log_debug(NAME" %p: destroy id:%u removed:%u zombie:%u ref:%d", proxy, proxy->id, proxy->removed, proxy->zombie, proxy->refcount); @@ -256,6 +258,10 @@ void pw_proxy_destroy(struct pw_proxy *proxy) proxy->zombie = true; pw_proxy_emit_destroy(proxy); } + + spa_list_consume(h, &proxy->listener_list.list, link) + spa_hook_remove(h); + pw_proxy_unref(proxy); }