context: fix erroneous clamping of quantum for high sample rates

When calculating the adjusted max quantum based off of max_latency, the
first multiplication can overflow uint32_t, leading to the quantum being
wrongfully clamped down.

Signed-off-by: Martin Louazel <martin.louazel@streamunlimited.com>
This commit is contained in:
Martin Louazel 2024-12-06 15:24:55 +01:00 committed by Wim Taymans
parent 2bf48487cb
commit 8ee1b4b614

View file

@ -1791,7 +1791,7 @@ again:
/* calculate desired quantum. Don't limit to the max_latency when we are /* calculate desired quantum. Don't limit to the max_latency when we are
* going to force a quantum or rate and reconfigure the nodes. */ * going to force a quantum or rate and reconfigure the nodes. */
if (max_latency.denom != 0 && !force_quantum && !force_rate) { if (max_latency.denom != 0 && !force_quantum && !force_rate) {
uint32_t tmp = (max_latency.num * current_rate / max_latency.denom); uint32_t tmp = ((uint64_t)max_latency.num * current_rate / max_latency.denom);
if (tmp < node_max_quantum) if (tmp < node_max_quantum)
node_max_quantum = tmp; node_max_quantum = tmp;
} }