From a5d684af8a4f6d389e433f48db22582d64bea8f4 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 15 Sep 2023 11:08:35 +0200 Subject: [PATCH] alsa: make sure we recalculate config when samplerate changes The threshold depends on the samplerate and even when the graph rate or quantum didn't change, the driver could be opened in a different samplerate, which would cause the timeouts to be wrong and cause xruns. --- spa/plugins/alsa/alsa-pcm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index a4e3597ad..4cf4d9ad9 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -1653,6 +1653,11 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_ else state->frame_size *= rchannels; + /* make sure we updates threshold in check_position_config() because they depend + * on the samplerate. */ + state->duration = 0; + state->rate_denom = 0; + state->have_format = true; if (state->card->format_ref++ == 0) state->card->rate = rrate;