From 9bfe24d62f093b582831a132d95a970a0140afc8 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 20 Sep 2023 15:46:41 +0200 Subject: [PATCH] context: also reconfigure when quantum was forced This makes the clock.force-quantum setting and node.force-quantum suspend all drivers and resume them in the new quantum. This is essential in order to change the quantum on an IRQ based driver because it will otherwise refuse to change the graph quantum. --- src/pipewire/context.c | 25 +++++++++++++++---------- src/pipewire/private.h | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/pipewire/context.c b/src/pipewire/context.c index ab137aa35..9e108be5a 100644 --- a/src/pipewire/context.c +++ b/src/pipewire/context.c @@ -1309,6 +1309,7 @@ again: uint32_t quantum, target_rate, current_rate; uint64_t quantum_stamp = 0, rate_stamp = 0; bool force_rate, force_quantum, restore_rate = false; + bool do_reconfigure = false, was_target_pending; const uint32_t *node_rates; uint32_t node_n_rates, node_def_rate; uint32_t node_max_quantum, node_min_quantum, node_def_quantum, node_rate_quantum; @@ -1416,8 +1417,9 @@ again: rate.denom, target_rate); } + was_target_pending = n->target_pending; + if (target_rate != current_rate) { - bool do_reconfigure = false; /* we doing a rate switch */ pw_log_info("(%s-%u) state:%s new rate:%u/(%u)->%u", n->name, n->info.id, @@ -1427,23 +1429,17 @@ again: if (force_rate) { if (settings->clock_rate_update_mode == CLOCK_RATE_UPDATE_MODE_HARD) - do_reconfigure = !n->target_pending; + do_reconfigure |= !was_target_pending; } else { if (n->info.state >= PW_NODE_STATE_SUSPENDED) - do_reconfigure = !n->target_pending; + do_reconfigure |= !was_target_pending; } - if (do_reconfigure) - reconfigure_driver(context, n); - /* we're setting the pending rate. This will become the new * current rate in the next iteration of the graph. */ n->target_rate = SPA_FRACTION(1, target_rate); - n->target_pending = true; n->forced_rate = force_rate; + n->target_pending = true; current_rate = target_rate; - /* we might be suspended now and the links need to be prepared again */ - if (do_reconfigure) - goto again; } if (node_rate_quantum != 0 && current_rate != node_rate_quantum) { @@ -1476,10 +1472,19 @@ again: quantum); /* this is the new pending quantum */ n->target_quantum = quantum; + n->forced_quantum = force_quantum; n->target_pending = true; + + if (force_quantum) + do_reconfigure |= !was_target_pending; } if (n->target_pending) { + if (do_reconfigure) { + reconfigure_driver(context, n); + /* we might be suspended now and the links need to be prepared again */ + goto again; + } /* we have a pending change. We place the new values in the * pending fields so that they are picked up by the driver in * the next cycle */ diff --git a/src/pipewire/private.h b/src/pipewire/private.h index e841162c7..4c225e36a 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -673,6 +673,7 @@ struct pw_impl_node { unsigned int suspend_on_idle:1; unsigned int reconfigure:1; unsigned int forced_rate:1; + unsigned int forced_quantum:1; unsigned int trigger:1; /**< has the TRIGGER property and needs an extra * trigger to start processing. */ unsigned int can_suspend:1;