summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-21 19:38:18 +0100
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-01-25 17:00:21 +0900
commit2a2dc4d73ce00f408ef217d78ee8d80fd6b8511f (patch)
tree4a6271a54bdc134c7bc39154a389b02afcc65d01
parentd855be5ec1615e77a48ee56f987147890459de45 (diff)
downloadmpv-2a2dc4d73ce00f408ef217d78ee8d80fd6b8511f.tar.bz2
mpv-2a2dc4d73ce00f408ef217d78ee8d80fd6b8511f.tar.xz
ao_alsa: reinitialize if device got broken
Apparently, physically disconnecting the audio device (consider USB audio) breaks the ALSA device handle forever. It will signal ENODEV. Fortunately, it's easy for us to handle this, and we can just use existing mechanisms that will make the playback core close and reopen the AO. Whether the immediate reopening will actually succeeds really is ALSA's problem, though.
-rw-r--r--audio/out/ao_alsa.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index ab27039d23..6bc2fe03d0 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -846,6 +846,9 @@ static int play(struct ao *ao, void **data, int samples, int flags)
if (res == -EINTR || res == -EAGAIN) { /* retry */
res = 0;
+ } else if (res == -ENODEV) {
+ MP_WARN(ao, "Device lost, trying to recover...\n");
+ ao_request_reload(ao);
} else if (res < 0) {
if (res == -ESTRPIPE) { /* suspend */
resume_device(ao);