From 40f43d4715061ccf54763aa0df9b113e7750bc89 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 8 Mar 2023 15:28:52 +0100 Subject: [PATCH] impl-link: handle passive nodes Parse the NODE_PASSIVE flag on nodes. When a node is marked passive, make a passive link unless explicitly set with a link property. This removes the need for the session manager to set the passive flag and it also makes things work better when using tools like pw-link. --- src/pipewire/impl-link.c | 6 +++++- src/pipewire/impl-node.c | 1 + src/pipewire/private.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pipewire/impl-link.c b/src/pipewire/impl-link.c index b476bccfb..11a79d87b 100644 --- a/src/pipewire/impl-link.c +++ b/src/pipewire/impl-link.c @@ -1152,6 +1152,7 @@ struct pw_impl_link *pw_context_create_link(struct pw_context *context, struct impl *impl; struct pw_impl_link *this; struct pw_impl_node *input_node, *output_node; + const char *str; int res; if (output == input) @@ -1201,7 +1202,10 @@ struct pw_impl_link *pw_context_create_link(struct pw_context *context, this->input = input; /* passive means that this link does not make the nodes active */ - this->passive = pw_properties_get_bool(properties, PW_KEY_LINK_PASSIVE, false); + str = pw_properties_get(properties, PW_KEY_LINK_PASSIVE); + this->passive = str ? spa_atob(str) : output_node->passive | input_node->passive; + if (this->passive && str == NULL) + pw_properties_set(properties, PW_KEY_LINK_PASSIVE, "true"); spa_hook_list_init(&this->listener_list); diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index 2f8aa3b09..9301d250a 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -947,6 +947,7 @@ static void check_properties(struct pw_impl_node *node) recalc_reason = "link group changed"; } + node->passive = pw_properties_get_bool(node->properties, PW_KEY_NODE_PASSIVE, false); node->want_driver = pw_properties_get_bool(node->properties, PW_KEY_NODE_WANT_DRIVER, false); node->always_process = pw_properties_get_bool(node->properties, PW_KEY_NODE_ALWAYS_PROCESS, false); diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 8fcae46da..a7b84f0a6 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -686,6 +686,7 @@ struct pw_impl_node { * is selected to drive the graph */ unsigned int visited:1; /**< for sorting */ unsigned int want_driver:1; /**< this node wants to be assigned to a driver */ + unsigned int passive:1; /**< node links should be passive */ unsigned int runnable:1; /**< node is runnable */ unsigned int freewheel:1; /**< if this is the freewheel driver */ unsigned int loopchecked:1; /**< for feedback loop checking */