• Max Kellermann's avatar
    output/alsa: don't call snd_pcm_drain() if nothing was written · 4cdcaa86
    Max Kellermann authored
    Works around a problem where MPD goes into a busy loop because
    snd_pcm_drain() always returns `-EAGAIN` without making any progress
    (fixes #425).
    
    This problem was triggered by snd_pcm_drain() after snd_pcm_cancel()
    and snd_pcm_prepare(), but without submitting any data with
    snd_pcm_writei().
    
    I believe this is a kernel bug: in non-blocking mode, the kernel's
    snd_pcm_drain() function returns early.  In this mode, it only checks
    whether snd_pcm_drain_done() has been called already, but
    snd_pcm_drain_done() is never called if no data was submitted.
    
    In blocking mode, the following `for` loop detects this condition, so
    snd_pcm_drain_done() is not necessary, but without this extra check,
    we get `-EAGAIN` forever.
    4cdcaa86
Name
Last commit
Last update
android Loading commit data...
build Loading commit data...
doc Loading commit data...
python/build Loading commit data...
scripts Loading commit data...
src Loading commit data...
systemd Loading commit data...
test Loading commit data...
win32 Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
AUTHORS Loading commit data...
COPYING Loading commit data...
NEWS Loading commit data...
README.md Loading commit data...
meson.build Loading commit data...
meson_options.txt Loading commit data...
mpd.svg Loading commit data...
valgrind.suppressions Loading commit data...