From 4152c5d292640971828d573ba9ddfd469c614329 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 1 Dec 2025 12:51:20 +0100 Subject: [PATCH] alsa: add firewire latency before we scale with rate We first add all the latency in the rate of the pcm device and then convert it to the rate of the graph. See #4977 --- spa/plugins/alsa/alsa-pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 4f2fde8b6..f919a9eb1 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -2063,8 +2063,6 @@ static void recalc_headroom(struct state *state) state->headroom = 0; latency = SPA_MAX(state->min_delay, SPA_MIN(state->max_delay, state->headroom)); - if (rate != 0 && state->rate != 0) - latency = SPA_SCALE32_UP(latency, rate, state->rate); if (state->is_firewire) { /* XXX: For ALSA FireWire drivers, unlike for other ALSA drivers, buffer size @@ -2072,6 +2070,8 @@ static void recalc_headroom(struct state *state) */ latency += state->buffer_frames; } + if (rate != 0 && state->rate != 0) + latency = SPA_SCALE32_UP(latency, rate, state->rate); state->latency[state->port_direction].min_rate = state->latency[state->port_direction].max_rate = latency;