From 5cc7e583e2bb145c9f51cd493a582a8c3a057b95 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 30 Jul 2024 14:17:58 +0200 Subject: [PATCH] impl-node: reset pending state when moving driving node Commit d04a28daef46ea157e544411d37eeffc6f3b40cc moved the configuration of the IO_Position after we removed the node from the old driver but forgot to move the code that updates the pending_state. See #4094 --- src/pipewire/impl-node.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index b04f6bd1a..08d9a67f2 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -1015,17 +1015,7 @@ int pw_impl_node_set_driver(struct pw_impl_node *node, struct pw_impl_node *driv remove_segment_owner(old, node->info.id); - was_driving = node->driving; - - /* When a node was driver (and is waiting for all nodes to complete - * the Start command) cancel the pending state and let the new driver - * calculate a new state so that the Start command is sent to the - * node */ - if (was_driving && !node->driving) - impl->pending_state = node->info.state; - - pw_log_debug("%p: driver %p driving:%u", node, - driver, node->driving); + pw_log_debug("%p: driver %p driving:%u", node, driver, node->driving); pw_log_info("(%s-%u) -> change driver (%s-%d -> %s-%d)", node->name, node->info.id, old->name, old->info.id, driver->name, driver->info.id); @@ -1042,11 +1032,20 @@ int pw_impl_node_set_driver(struct pw_impl_node *node, struct pw_impl_node *driv * scheduled so it won't trigger yet */ node->to_driver_peer = pw_node_peer_ref(node, driver); + was_driving = node->driving; + /* then set the new driver node activation */ pw_impl_node_set_io(node, SPA_IO_Position, &driver->rt.target.activation->position, sizeof(struct spa_io_position)); + /* When a node was driver (and is waiting for all nodes to complete + * the Start command) cancel the pending state and let the new driver + * calculate a new state so that the Start command is sent to the + * node */ + if (was_driving && !node->driving) + impl->pending_state = node->info.state; + /* and then make the driver trigger the node */ node->from_driver_peer = pw_node_peer_ref(driver, node);