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.
This commit is contained in:
Wim Taymans 2022-04-06 13:03:30 +02:00
parent 7155913553
commit 0c97008291

View file

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