diff options
author | Jan Ekström <jeebjp@gmail.com> | 2018-05-19 01:05:28 +0300 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-06-04 00:03:11 +0300 |
commit | 36cc33ff5ab599f8e2e0d02161f7942cd7377dcb (patch) | |
tree | 73f46dffbd289df0682d8bf1fb961f7a9c632d7c /audio | |
parent | 945303a92ecac73ba430b9eac0f10279cd95a32a (diff) |
ao_alsa: simplify get_space()
Diffstat (limited to 'audio')
-rw-r--r-- | audio/out/ao_alsa.c | 16 |
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; |