From ffeb2e0f0e511e36aede1706adae210428b411db Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 8 Mar 2021 15:36:58 +0100 Subject: [PATCH] alsa: fill with right amount of silence when starting When we start or after an xrun, we need fill the buffer with one period + headroom of samples, not period*2. This is because after start we set our timeout immediately and expect there to be period + headroom samples in the buffer. With period*2 we take one period longer to start and we also feed one period of error in the dll, which causes it to wobble for no good reason. --- spa/plugins/alsa/alsa-pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 7aea58231..7bb842ac0 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -803,7 +803,7 @@ recover: state->alsa_started = false; if (state->stream == SND_PCM_STREAM_PLAYBACK) - spa_alsa_silence(state, state->threshold * 2 + state->headroom); + spa_alsa_silence(state, state->threshold + state->headroom); return do_start(state); } @@ -1478,7 +1478,7 @@ int spa_alsa_start(struct state *state) state->alsa_started = false; if (state->stream == SND_PCM_STREAM_PLAYBACK) - spa_alsa_silence(state, state->threshold * 2 + state->headroom); + spa_alsa_silence(state, state->threshold + state->headroom); if ((err = do_start(state)) < 0) return err;