summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_pulse.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_pulse.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_pulse.c')
-rw-r--r--audio/out/ao_pulse.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index 563848b523..c826a6c993 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -52,7 +52,7 @@ struct priv {
struct pa_sink_input_info pi;
int retval;
- bool underrun;
+ bool playing;
char *cfg_host;
int cfg_buffer;
@@ -134,7 +134,7 @@ static void underflow_cb(pa_stream *s, void *userdata)
{
struct ao *ao = userdata;
struct priv *priv = ao->priv;
- priv->underrun = true;
+ priv->playing = false;
ao_wakeup_playthread(ao);
pa_threaded_mainloop_signal(priv->mainloop, 0);
}
@@ -486,9 +486,15 @@ static void cork(struct ao *ao, bool pause)
struct priv *priv = ao->priv;
pa_threaded_mainloop_lock(priv->mainloop);
priv->retval = 0;
- if (!waitop(priv, pa_stream_cork(priv->stream, pause, success_cb, ao)) ||
- !priv->retval)
+ if (waitop_no_unlock(priv, pa_stream_cork(priv->stream, pause, success_cb, ao))
+ && priv->retval)
+ {
+ priv->playing = true;
+ } else {
GENERIC_ERR_MSG("pa_stream_cork() failed");
+ priv->playing = false;
+ }
+ pa_threaded_mainloop_unlock(priv->mainloop);
}
// Play the specified data to the pulseaudio server
@@ -614,14 +620,13 @@ static void audio_get_state(struct ao *ao, struct mp_pcm_state *state)
state->delay = get_delay_pulse(ao);
}
- state->underrun = priv->underrun;
- priv->underrun = false;
+ state->playing = priv->playing;
pa_threaded_mainloop_unlock(priv->mainloop);
// Otherwise, PA will keep hammering us for underruns (which it does instead
// of stopping the stream automatically).
- if (state->underrun)
+ if (!state->playing)
cork(ao, true);
}