aboutsummaryrefslogtreecommitdiffhomepage
path: root/audio
diff options
context:
space:
mode:
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_alsa.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 1a2c6f5095..32f08bef59 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -939,15 +939,19 @@ static void drain(struct ao *ao)
static int get_space(struct ao *ao)
{
struct priv *p = ao->priv;
- int err;
- unsigned space = err = snd_pcm_avail(p->alsa);
- if (err == -EPIPE) // EOF
- return p->buffersize;
+ snd_pcm_sframes_t space = snd_pcm_avail(p->alsa);
+ if (space < 0) {
+ MP_ERR(ao, "Error received from snd_pcm_avail (%ld, %s)!\n",
+ space, snd_strerror(space));
+ if (space == -EPIPE) // EOF
+ return p->buffersize;
- if (!check_device_present(ao, err))
+ // request a reload of the AO if device is not present,
+ // then error out.
+ check_device_present(ao, space);
goto alsa_error;
- CHECK_ALSA_ERROR("cannot get pcm avail");
+ }
if (space > p->buffersize) // Buffer underrun?
space = p->buffersize;