From ecffe3cbd653044537b759e5922ecf7d5436930b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Lebrun?= Date: Thu, 1 Feb 2024 12:05:55 +0100 Subject: [PATCH] pw-link: handle link proxy destruction If for some reason the proxy gets destroyed, we make sure to remove listeners and forget the proxy pointer. We do not however delete the target_link; we consider the proxy destruction as an error. If another definitive state occured on the link (got to paused state, got an error), then that event will be ignored. Else we consider it an error. --- src/tools/pw-link.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/tools/pw-link.c b/src/tools/pw-link.c index 8e3315557..78b1bfed0 100644 --- a/src/tools/pw-link.c +++ b/src/tools/pw-link.c @@ -104,6 +104,17 @@ static void link_event(struct target_link *tl, enum pw_link_state state, int res pw_main_loop_quit(tl->data->loop); } +static void link_proxy_destroy(void *data) +{ + struct target_link *tl = data; + + spa_hook_remove(&tl->listener); + spa_hook_remove(&tl->link_listener); + tl->proxy = NULL; + + link_event(tl, PW_LINK_STATE_ERROR, -EINVAL); +} + static void link_proxy_error(void *data, int seq, int res, const char *message) { struct target_link *tl = data; @@ -112,6 +123,7 @@ static void link_proxy_error(void *data, int seq, int res, const char *message) static const struct pw_proxy_events link_proxy_events = { PW_VERSION_PROXY_EVENTS, + .destroy = link_proxy_destroy, .error = link_proxy_error, };