From 7a629fa378162bd8953012be08060322d22aa1ab Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 21 Jun 2023 10:25:30 +0200 Subject: [PATCH] impl-link: block some actions when destroyed When we destroy a port, make sure we don't start to reactivate it again. --- src/pipewire/impl-link.c | 11 +++++++---- src/pipewire/private.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pipewire/impl-link.c b/src/pipewire/impl-link.c index 8e83ca939..01707cd8d 100644 --- a/src/pipewire/impl-link.c +++ b/src/pipewire/impl-link.c @@ -655,7 +655,7 @@ int pw_impl_link_activate(struct pw_impl_link *this) pw_log_debug("%p: activate activated:%d state:%s", this, impl->activated, pw_link_state_as_string(this->info.state)); - if (impl->activated || !this->prepared || + if (this->destroyed || impl->activated || !this->prepared || !impl->inode->runnable || !impl->onode->runnable) return 0; @@ -820,7 +820,7 @@ int pw_impl_link_prepare(struct pw_impl_link *this) if (!impl->inode->active || !impl->onode->active) return 0; - if (this->preparing || this->prepared) + if (this->destroyed || this->preparing || this->prepared) return 0; this->preparing = true; @@ -861,8 +861,9 @@ int pw_impl_link_deactivate(struct pw_impl_link *this) impl->activated = false; pw_log_info("(%s) deactivated", this->name); - link_update_state(this, PW_LINK_STATE_PAUSED, 0, NULL); - + link_update_state(this, this->destroyed ? + PW_LINK_STATE_INIT : PW_LINK_STATE_PAUSED, + 0, NULL); return 0; } @@ -1433,6 +1434,8 @@ void pw_impl_link_destroy(struct pw_impl_link *link) pw_log_debug("%p: destroy", impl); pw_log_info("(%s) destroy", link->name); + + link->destroyed = true; pw_impl_link_emit_destroy(link); pw_impl_link_deactivate(link); diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 82dd2cd48..f1b79c7ab 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -990,6 +990,7 @@ struct pw_impl_link { unsigned int preparing:1; unsigned int prepared:1; unsigned int passive:1; + unsigned int destroyed:1; }; #define pw_resource_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_resource_events, m, v, ##__VA_ARGS__)