From 08b198aab49f73829bb02a25bc46bd159b6f9c6e Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 2 Jun 2020 20:30:59 +0200 Subject: audio: further simplify internal audio API somewhat Instead of the relatively subtle underflow handling, simply signal whether the stream is in a playing state. Should make it more robust. Should affect ao_alsa and ao_pulse only (and ao_openal, but it's broken). For ao_pulse, I'm just guessing. How the hell do you query whether a stream is playing? Who knows. Seems to work, judging from very superficial testing. --- audio/out/ao_null.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'audio/out/ao_null.c') diff --git a/audio/out/ao_null.c b/audio/out/ao_null.c index 107dc7e35a..ac113ca186 100644 --- a/audio/out/ao_null.c +++ b/audio/out/ao_null.c @@ -43,7 +43,6 @@ struct priv { float buffered; // samples int buffersize; // samples bool playing; - bool underrun; int untimed; float bufferlen; // seconds @@ -77,10 +76,8 @@ static void drain(struct ao *ao) double now = mp_time_sec(); if (priv->buffered > 0) { priv->buffered -= (now - priv->last_time) * ao->samplerate * priv->speed; - if (priv->buffered < 0) { - priv->underrun = true; + if (priv->buffered < 0) priv->buffered = 0; - } } priv->last_time = now; } @@ -127,7 +124,6 @@ static void reset(struct ao *ao) { struct priv *priv = ao->priv; priv->buffered = 0; - priv->underrun = false; priv->playing = false; } @@ -200,8 +196,7 @@ static void get_state(struct ao *ao, struct mp_pcm_state *state) state->delay = (int)(state->delay / q) * q; } - state->underrun = priv->underrun; - priv->underrun = false; + state->playing = priv->playing && priv->buffered > 0; } #define OPT_BASE_STRUCT struct priv -- cgit v1.2.3