mirror of https://github.com/mpv-player/mpv
audio: require certain AOs to set device_buffer
AOs which use the "push" API must set this field now. Actually, this was sort of always required, but happened to work anyway. The future intention is to use device_buffer as the pre-buffer amount, which has to be available right before audio playback is started. "Pull" AOs really need this too conceptually, just that the API is underspecified. From what I can see, only ao_null did not do this yet.
This commit is contained in:
parent
0fb02f181f
commit
d5de79d10f
|
@ -236,7 +236,7 @@ static struct ao *ao_init(bool probing, struct mpv_global *global,
|
|||
}
|
||||
ao->bps = ao->samplerate * ao->sstride;
|
||||
|
||||
if (ao->device_buffer < 0 && ao->driver->write) {
|
||||
if (ao->device_buffer <= 0 && ao->driver->write) {
|
||||
MP_ERR(ao, "Device buffer size not set.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ static int init(struct ao *ao)
|
|||
|
||||
// A "buffer" for this many seconds of audio
|
||||
int bursts = (int)(ao->samplerate * priv->bufferlen + 1) / priv->outburst;
|
||||
priv->buffersize = priv->outburst * bursts + priv->latency;
|
||||
ao->device_buffer = priv->outburst * bursts + priv->latency;
|
||||
|
||||
priv->last_time = mp_time_sec();
|
||||
|
||||
|
@ -175,7 +175,7 @@ static void get_state(struct ao *ao, struct mp_pcm_state *state)
|
|||
|
||||
drain(ao);
|
||||
|
||||
state->free_samples = priv->buffersize - priv->latency - priv->buffered;
|
||||
state->free_samples = ao->device_buffer - priv->latency - priv->buffered;
|
||||
state->free_samples = state->free_samples / priv->outburst * priv->outburst;
|
||||
state->queued_samples = priv->buffered;
|
||||
|
||||
|
|
Loading…
Reference in New Issue