From 03e3abcb0c4cc9032f2843e469a76f67d4d33b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= Date: Thu, 27 Sep 2018 20:39:49 +0300 Subject: ao_alsa: handle XRUNs separately from other errors According to ALSA doxy, EPIPE is a synonym to SND_PCM_STATE_XRUN, and that is a state that we should attempt to automatically recover from. In case recovery fails, log an error and return zero. A warning message will still be output for each XRUN since those are not something we should generally be receiving. (cherry picked from commit fdc952486a8c0d6446783e424953fdb6097ed987) --- audio/out/ao_alsa.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 6b93b854c0..5894a1bcaa 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -947,10 +947,15 @@ static int get_space(struct ao *ao) snd_pcm_sframes_t space = snd_pcm_avail(p->alsa); if (space < 0) { + if (space == -EPIPE) { + MP_WARN(ao, "ALSA XRUN hit, attempting to recover...\n"); + int err = snd_pcm_prepare(p->alsa); + CHECK_ALSA_ERROR("Unable to recover from under/overrun!"); + return p->buffersize; + } + MP_ERR(ao, "Error received from snd_pcm_avail (%ld, %s)!\n", space, snd_strerror(space)); - if (space == -EPIPE) // EOF - return p->buffersize; // request a reload of the AO if device is not present, // then error out. -- cgit v1.2.3