mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
7f625ea29b
commit
945303a92e
|
@ -939,17 +939,16 @@ static void drain(struct ao *ao)
|
||||||
static int get_space(struct ao *ao)
|
static int get_space(struct ao *ao)
|
||||||
{
|
{
|
||||||
struct priv *p = ao->priv;
|
struct priv *p = ao->priv;
|
||||||
snd_pcm_status_t *status;
|
|
||||||
int err;
|
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))
|
if (!check_device_present(ao, err))
|
||||||
goto alsa_error;
|
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?
|
if (space > p->buffersize) // Buffer underrun?
|
||||||
space = p->buffersize;
|
space = p->buffersize;
|
||||||
return space / p->outburst * p->outburst;
|
return space / p->outburst * p->outburst;
|
||||||
|
|
Loading…
Reference in New Issue