summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_null.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-06-02 20:30:59 +0200
committerwm4 <wm4@nowhere>2020-06-02 20:43:49 +0200
commit08b198aab49f73829bb02a25bc46bd159b6f9c6e (patch)
tree7b59350dd20518867f2a4e3c0a826bd25f96b203 /audio/out/ao_null.c
parent0d3474c6c0d3bea20bfd50614ffaa3b21d4538cf (diff)
downloadmpv-08b198aab49f73829bb02a25bc46bd159b6f9c6e.tar.bz2
mpv-08b198aab49f73829bb02a25bc46bd159b6f9c6e.tar.xz
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.
Diffstat (limited to 'audio/out/ao_null.c')
-rw-r--r--audio/out/ao_null.c9
1 files changed, 2 insertions, 7 deletions
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