From 158c23b2fd7704a660efbb625efa557912d7bec7 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 29 Jul 2021 16:33:00 +0200 Subject: [PATCH] impl-link: prepare link only between active nodes We only ever want to prepare a link between active nodes so add the check in the _prepare() functions instead. This also makes it skip the prepare step for inactive nodes when recalculating the graph. --- src/pipewire/impl-link.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/pipewire/impl-link.c b/src/pipewire/impl-link.c index c4b73c30f..90a137edb 100644 --- a/src/pipewire/impl-link.c +++ b/src/pipewire/impl-link.c @@ -673,7 +673,12 @@ int pw_impl_link_prepare(struct pw_impl_link *this) { struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this); - pw_log_debug(NAME" %p: prepare prepared:%d busy:%d", this, this->prepared, this->preparing); + pw_log_debug(NAME" %p: prepare prepared:%d busy:%d in_active:%d out_active:%d", + this, this->prepared, this->preparing, + impl->inode->active, impl->onode->active); + + if (!impl->inode->active || !impl->onode->active) + return 0; if (this->preparing || this->prepared) return 0; @@ -903,19 +908,10 @@ static void output_node_result(void *data, int seq, int res, uint32_t type, cons node_result(impl, port, seq, res, type, result); } -static void check_prepare(struct pw_impl_link *this) -{ - struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this); - pw_log_debug(NAME" %p: input active:%d output active:%d", impl, - impl->inode->active, impl->onode->active); - if (impl->inode->active && impl->onode->active) - pw_impl_link_prepare(this); -} - static void node_active_changed(void *data, bool active) { struct impl *impl = data; - check_prepare(&impl->this); + pw_impl_link_prepare(&impl->this); } static const struct pw_impl_node_events input_node_events = { @@ -1287,7 +1283,7 @@ int pw_impl_link_register(struct pw_impl_link *link, pw_global_add_listener(link->global, &link->global_listener, &global_events, link); pw_global_register(link->global); - check_prepare(link); + pw_impl_link_prepare(link); return 0;