From fda565864cd3cae46528d8afeabec6b290f250c0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 29 Mar 2021 13:17:01 +0200 Subject: [PATCH] alsa: limit headroom to buffer-size We can never have more headroom that the total buffer-size so better clamp this here. --- spa/plugins/alsa/alsa-pcm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 00d554070..f927c85f0 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -627,6 +627,8 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_ if (is_batch) state->headroom += period_size; + state->headroom = SPA_MIN(state->headroom, state->buffer_frames); + state->period_frames = period_size; periods = state->buffer_frames / state->period_frames;