alsa: limit the buffer-size to quantum-limit * 4

We don't actually need to allocate the largest possible buffer. A buffer
that is near 4 times the quantum-limit is more than enough.

See #1995
This commit is contained in:
Wim Taymans 2022-04-07 16:01:48 +02:00
parent 0c97008291
commit 1547e5fd2b

View file

@ -1476,6 +1476,10 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
state->buffer_frames = period_size * periods;
} 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);
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");
periods = state->buffer_frames / period_size;
}