aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Muhammad Faiz <mfcc64@gmail.com>2018-05-11 22:35:10 +0700
committerGravatar Jan Ekström <jeebjp@gmail.com>2018-06-04 00:00:57 +0300
commit945303a92ecac73ba430b9eac0f10279cd95a32a (patch)
tree87a1b7d027b538616b7018319dfdce144e3b5cdf
parent7f625ea29b1082248bcd17d6f1ee1a8b150e2bc7 (diff)
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.
-rw-r--r--audio/out/ao_alsa.c9
1 files changed, 4 insertions, 5 deletions
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;