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
This commit is contained in:
Wim Taymans 2023-11-30 13:28:16 +01:00
parent 4e1b10073a
commit 85a9e30908

View file

@ -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");