From d5de79d10f895aaa8f65340adf949d28bc09b2d7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 9 Jun 2020 16:49:05 +0200 Subject: 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. --- audio/out/ao.c | 2 +- audio/out/ao_null.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'audio') diff --git a/audio/out/ao.c b/audio/out/ao.c index 9ac42806e4..32ffc3d82d 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -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; } diff --git a/audio/out/ao_null.c b/audio/out/ao_null.c index ac113ca186..2f58ea22c3 100644 --- a/audio/out/ao_null.c +++ b/audio/out/ao_null.c @@ -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; -- cgit v1.2.3