output/alsa: non-blocking mode

Use SND_PCM_NONBLOCK, and perform all snd_pcm_writei() calls in the
IOThread.  Use a lockless queue to copy data from the OutputThread to
the IOThread.

This rather major change aims to improve MPD's internal latency.  All
waits are now under MPD's control, instead of blocking inside
libasound2.

As a side effect, an output's filter is now decoupled from the actual
device I/O, which solves a major latency problem with the conversion
filter on slow CPUs and small period buffers.  See:

 https://bugs.musicpd.org/view.php?id=3900
This commit is contained in:
Max Kellermann
2017-01-24 23:10:35 +01:00
parent 853740f1e2
commit b1c7649edb
3 changed files with 412 additions and 69 deletions

2
NEWS
View File

@@ -2,6 +2,8 @@ ver 0.21 (not yet released)
* protocol
- "tagtypes" can be used to hide tags
- "find" and "search" can sort
* output
- alsa: non-blocking mode
ver 0.20.5 (not yet released)
* tags