diff options
author | sfan5 <sfan5@live.de> | 2020-07-12 23:25:56 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2020-07-12 23:44:41 +0200 |
commit | 7a7a0a78b518180bfb48a42e23acac6c801ed5cf (patch) | |
tree | a68442bf532a21349bc7e1bfaeab3773b2e8fa3c | |
parent | f3b29a680c7ded759e5304dce0c73d172eac7dae (diff) | |
download | mpv-7a7a0a78b518180bfb48a42e23acac6c801ed5cf.tar.bz2 mpv-7a7a0a78b518180bfb48a42e23acac6c801ed5cf.tar.xz |
ao/pulse: fix reporting of playing state
When get_state() corks the stream after an underrun happens
priv->playing is incorrectly reset to true, which can cause the
player to miss the underrun entirely. Stop resetting priv->playing
during corking (but not uncorking) to fix this.
-rw-r--r-- | audio/out/ao_pulse.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c index 31c84e06ff..6cea79103b 100644 --- a/audio/out/ao_pulse.c +++ b/audio/out/ao_pulse.c @@ -53,6 +53,7 @@ struct priv { int retval; bool playing; + bool underrun_signalled; char *cfg_host; int cfg_buffer; @@ -135,6 +136,7 @@ static void underflow_cb(pa_stream *s, void *userdata) struct ao *ao = userdata; struct priv *priv = ao->priv; priv->playing = false; + priv->underrun_signalled = true; ao_wakeup_playthread(ao); pa_threaded_mainloop_signal(priv->mainloop, 0); } @@ -497,7 +499,8 @@ static void cork(struct ao *ao, bool pause) if (waitop_no_unlock(priv, pa_stream_cork(priv->stream, pause, success_cb, ao)) && priv->retval) { - priv->playing = true; + if (!pause) + priv->playing = true; } else { GENERIC_ERR_MSG("pa_stream_cork() failed"); priv->playing = false; @@ -634,8 +637,10 @@ static void audio_get_state(struct ao *ao, struct mp_pcm_state *state) // Otherwise, PA will keep hammering us for underruns (which it does instead // of stopping the stream automatically). - if (!state->playing) + if (!state->playing && priv->underrun_signalled) { reset(ao); + priv->underrun_signalled = false; + } } /* A callback function that is called when the |