0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

ao_alsa: simplify get_space()

This commit is contained in:
Jan Ekström 2018-05-19 01:05:28 +03:00
parent 945303a92e
commit 36cc33ff5a

View File

@ -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;