mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-28 14:29:25 +08:00
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.
This commit is contained in:
committed by
Diogo Franco (Kovensky)
parent
d855be5ec1
commit
2a2dc4d73c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user