From c6f9cfa220bc90bbdb44b3c1422fb9712316fe3b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 15 Sep 2023 15:33:00 +0200 Subject: [PATCH] alsa: IRQ based scheduling wakes up after finishing 1 period So we need to keep 2 periods of silence to keep 1 period of data inside the ringbuffer when starting the graph. --- spa/plugins/alsa/alsa-pcm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 8ea096ab4..ad05cdfd2 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -2903,8 +2903,12 @@ int spa_alsa_prepare(struct state *state) state->name, snd_strerror(err)); return err; } - if (state->stream == SND_PCM_STREAM_PLAYBACK) - spa_alsa_silence(state, state->start_delay + state->threshold + state->headroom); + if (state->stream == SND_PCM_STREAM_PLAYBACK) { + snd_pcm_uframes_t silence = state->start_delay + state->threshold + state->headroom; + if (state->disable_tsched) + silence += state->threshold; + spa_alsa_silence(state, silence); + } reset_buffers(state); state->alsa_sync = true;