From 0c970082915ecb5778ff0a1d7b5578fe06248bc5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 6 Apr 2022 13:03:30 +0200 Subject: [PATCH] impl-node: improve node_set_active for exported nodes Exported nodes (streams, filter) are not registered in the local context and notify the server when they change active state. When the node becomes inactive, this triggers a message to the server to make the node inactive, which then eventually results in a PAUSE request on the node, which then removes the node from the processing loop. Unfortunately, clients expect that after a node is set inactive, the process function will not be called anymore and they might free any resources immediately. Handle this by removing the node from the data-loop and waiting for completion. This should fix some crashes when streams are stopped. --- src/pipewire/impl-node.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index 1b5b245cd..2dbd05d3e 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -2213,7 +2213,9 @@ int pw_impl_node_set_active(struct pw_impl_node *node, bool active) bool old = node->active; if (old != active) { - pw_log_debug("%p: %s", node, active ? "activate" : "deactivate"); + pw_log_debug("%p: %s registered:%d", node, + active ? "activate" : "deactivate", + node->registered); node->active = active; pw_impl_node_emit_active_changed(node, active); @@ -2221,6 +2223,8 @@ int pw_impl_node_set_active(struct pw_impl_node *node, bool active) if (node->registered) pw_context_recalc_graph(node->context, active ? "node activate" : "node deactivate"); + else if (!active && node->exported) + pw_loop_invoke(node->data_loop, do_node_remove, 1, NULL, 0, true, node); } return 0; }