From 9485b2819a0422b8386e6264003d55adbad5ea13 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 31 Mar 2023 10:27:06 +0200 Subject: [PATCH] impl-node: add support for node.force-rate=0 If you set node.force-rate=0, the rate will be forced to the node.rate denominator. This makes it possible to autiomatically make the graph switch to the native rate of the stream by setting this as the default property on streams. See #3026 --- src/pipewire/impl-node.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index 74f71338a..3e73c88f4 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -1024,13 +1024,16 @@ static void check_properties(struct pw_impl_node *node) node->lock_rate = pw_properties_get_bool(node->properties, PW_KEY_NODE_LOCK_RATE, false); if ((str = pw_properties_get(node->properties, PW_KEY_NODE_FORCE_RATE))) { - if (spa_atou32(str, &value, 0) && - node->force_rate != value) { - pw_log_info("(%s-%u) force-rate:%u -> %u", node->name, - node->info.id, node->force_rate, value); - node->force_rate = value; - node->stamp = ++context->stamp; - recalc_reason = "force rate changed"; + if (spa_atou32(str, &value, 0)) { + if (value == 0) + value = node->rate.denom; + if (node->force_rate != value) { + pw_log_info("(%s-%u) force-rate:%u -> %u", node->name, + node->info.id, node->force_rate, value); + node->force_rate = value; + node->stamp = ++context->stamp; + recalc_reason = "force rate changed"; + } } }