From bc04acf3a76eb579ad0012286ac3bfeadaa07cc0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 14 Mar 2017 15:43:36 +0100 Subject: ao_alsa: POLLERR can be set even if the device is not lost Apparently POLLERR can be set if poll is called while the device is in the SND_PCM_STATE_PREPARED state. So assume that we can simply call snd_pcm_status() to check whether the error is because the device went away (i.e. we expect it to return ENODEV if this happened). This avoids sporadic device lost warnings and AO reloads. The actual device lost case is untested. --- audio/out/ao_alsa.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'audio') diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index ced2ed2325..f9d8f9a335 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -1125,7 +1125,11 @@ static int audio_wait(struct ao *ao, pthread_mutex_t *lock) CHECK_ALSA_ERROR("cannot read poll events"); if (revents & POLLERR) { - check_device_present(ao, -ENODEV); + snd_pcm_status_t *status; + snd_pcm_status_alloca(&status); + + err = snd_pcm_status(p->alsa, status); + check_device_present(ao, err); return -1; } if (revents & POLLOUT) -- cgit v1.2.3