mirror of https://github.com/mpv-player/mpv
audio/out: always round get_space on period size
Round get_space() results in the same way play() rounds the input size. Some audio APIs do this for various reasons. This affects only "push" based AOs. Some of these need no change, because they either do it already right (like ao_openal), or they seem not to have any such requirements (like ao_pulse). Needed for the following commit.
This commit is contained in:
parent
d9941e01cc
commit
769ac6fb7b
|
@ -675,7 +675,7 @@ static int get_space(struct ao *ao)
|
|||
unsigned space = snd_pcm_status_get_avail(status);
|
||||
if (space > p->buffersize) // Buffer underrun?
|
||||
space = p->buffersize;
|
||||
return space;
|
||||
return space / p->outburst * p->outburst;
|
||||
|
||||
alsa_error:
|
||||
return 0;
|
||||
|
|
|
@ -585,7 +585,7 @@ static int get_space(struct ao *ao)
|
|||
int space = check_free_buffer_size(ao);
|
||||
if (space < p->min_free_space)
|
||||
return 0;
|
||||
return (space - p->min_free_space) / ao->sstride;
|
||||
return (space - p->min_free_space) / p->outburst * p->outburst / ao->sstride;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -148,7 +148,8 @@ static int get_space(struct ao *ao)
|
|||
struct priv *priv = ao->priv;
|
||||
|
||||
drain(ao);
|
||||
return priv->buffersize - priv->latency - priv->buffered;
|
||||
int samples = priv->buffersize - priv->latency - priv->buffered;
|
||||
return samples / priv->outburst * priv->outburst;
|
||||
}
|
||||
|
||||
static int play(struct ao *ao, void **data, int samples, int flags)
|
||||
|
|
|
@ -273,7 +273,8 @@ static int get_space(struct ao *ao)
|
|||
; /* nothing */
|
||||
sio_revents(p->hdl, p->pfd);
|
||||
|
||||
return (p->par.bufsz * p->par.pchan * p->par.bps - p->delay) / ao->sstride;
|
||||
int samples = (p->par.bufsz * p->par.pchan * p->par.bps - p->delay) / ao->sstride;
|
||||
return samples / p->par.round * p->par.round;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue