From c0077ac936da31e959c7c5cda1a758dc545e9443 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 21 Jan 2015 19:38:18 +0100 Subject: 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. --- audio/out/ao_alsa.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'audio/out/ao_alsa.c') diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 014cd837af..dba6b19514 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -822,6 +822,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); -- cgit v1.2.3