output/alsa: don't generate silence if ALSA-PCM buffer has enough data

If our `ring_buffer` is smaller than the ALSA-PCM buffer (if the
latter has more than the 4 periods we allocate), it can happen that
the start threshold is crossed and ALSA switches to
`SND_PCM_STATE_RUNNING`, but the `ring_buffer` is empty.  In this
case, MPDD will generate silence, even though the ALSA-PCM buffer has
enough data.  This causes stuttering (#420).

This commit amends an older workaround for a similar problem (commit
e08598e7e2) by adding a snd_pcm_avail()
check, and only generate silence if there is less than one period of
data in the ALSA-PCM buffer.

Fixes #420
This commit is contained in:
Max Kellermann
2018-11-14 11:06:59 +01:00
parent 3830748de5
commit ccafe3f3cf
2 changed files with 19 additions and 1 deletions

1
NEWS
View File

@@ -1,6 +1,7 @@
ver 0.21.3 (not yet released)
* output
- alsa: fix crash bug
- alsa: fix stuttering at start of playback
ver 0.21.2 (2018/11/12)
* protocol