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.
This commit is contained in:
Wim Taymans 2021-03-08 15:36:58 +01:00
parent 1b6060ef5f
commit ffeb2e0f0e

View file

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