From 85a9e309089a654ae47009e071340c99aaa48d0a Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 30 Nov 2023 13:28:16 +0100 Subject: [PATCH] alsa: clamp buffer_frames correctly Don't try to multiple the max_buffer_size with the frame scale or else we might try to set a min_buffer_size larger than the max_buffer_size. Instead, use the frame_scale only to scale the quantum_limit and then clamp against the max_buffer size. See #3000 --- spa/plugins/alsa/alsa-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 2ba1fac68..a636472ec 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -2083,7 +2083,7 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_ } else { CHECK(snd_pcm_hw_params_get_buffer_size_max(params, &state->buffer_frames), "get_buffer_size_max"); - state->buffer_frames = SPA_MIN(state->buffer_frames, state->quantum_limit * 4)* state->frame_scale; + state->buffer_frames = SPA_MIN(state->buffer_frames, state->quantum_limit * 4 * state->frame_scale); CHECK(snd_pcm_hw_params_set_buffer_size_min(hndl, params, &state->buffer_frames), "set_buffer_size_min"); CHECK(snd_pcm_hw_params_set_buffer_size_near(hndl, params, &state->buffer_frames), "set_buffer_size_near");