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.
This commit is contained in:
Théo Lebrun 2024-02-01 12:05:55 +01:00
parent 7ebc1b05d2
commit ecffe3cbd6

View file

@ -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,
};