From 945303a92ecac73ba430b9eac0f10279cd95a32a Mon Sep 17 00:00:00 2001 From: Muhammad Faiz Date: Fri, 11 May 2018 22:35:10 +0700 Subject: ao_alsa: replace snd_pcm_status() with snd_pcm_avail() in get_space() Fixes a bug with alsa dmix on Fedora 29. After several minutes, audio suddenly becomes bad and muted. Actually, I don't know what causes this. Probably this is a bug in alsa. In any case, as snd_pcm_status() returns not only 'avail', but also other fields such as tstamp, htstamp, etc, this could be considered a good simplification, as only avail is required for this function. --- audio/out/ao_alsa.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'audio/out') diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index d8a1ec5cae..1a2c6f5095 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -939,17 +939,16 @@ static void drain(struct ao *ao) static int get_space(struct ao *ao) { struct priv *p = ao->priv; - snd_pcm_status_t *status; int err; - snd_pcm_status_alloca(&status); + unsigned space = err = snd_pcm_avail(p->alsa); + if (err == -EPIPE) // EOF + return p->buffersize; - err = snd_pcm_status(p->alsa, status); if (!check_device_present(ao, err)) goto alsa_error; - CHECK_ALSA_ERROR("cannot get pcm status"); + CHECK_ALSA_ERROR("cannot get pcm avail"); - unsigned space = snd_pcm_status_get_avail(status); if (space > p->buffersize) // Buffer underrun? space = p->buffersize; return space / p->outburst * p->outburst; -- cgit v1.2.3