mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
f3b29a680c
commit
7a7a0a78b5
|
@ -53,6 +53,7 @@ struct priv {
|
||||||
|
|
||||||
int retval;
|
int retval;
|
||||||
bool playing;
|
bool playing;
|
||||||
|
bool underrun_signalled;
|
||||||
|
|
||||||
char *cfg_host;
|
char *cfg_host;
|
||||||
int cfg_buffer;
|
int cfg_buffer;
|
||||||
|
@ -135,6 +136,7 @@ static void underflow_cb(pa_stream *s, void *userdata)
|
||||||
struct ao *ao = userdata;
|
struct ao *ao = userdata;
|
||||||
struct priv *priv = ao->priv;
|
struct priv *priv = ao->priv;
|
||||||
priv->playing = false;
|
priv->playing = false;
|
||||||
|
priv->underrun_signalled = true;
|
||||||
ao_wakeup_playthread(ao);
|
ao_wakeup_playthread(ao);
|
||||||
pa_threaded_mainloop_signal(priv->mainloop, 0);
|
pa_threaded_mainloop_signal(priv->mainloop, 0);
|
||||||
}
|
}
|
||||||
|
@ -497,6 +499,7 @@ static void cork(struct ao *ao, bool pause)
|
||||||
if (waitop_no_unlock(priv, pa_stream_cork(priv->stream, pause, success_cb, ao))
|
if (waitop_no_unlock(priv, pa_stream_cork(priv->stream, pause, success_cb, ao))
|
||||||
&& priv->retval)
|
&& priv->retval)
|
||||||
{
|
{
|
||||||
|
if (!pause)
|
||||||
priv->playing = true;
|
priv->playing = true;
|
||||||
} else {
|
} else {
|
||||||
GENERIC_ERR_MSG("pa_stream_cork() failed");
|
GENERIC_ERR_MSG("pa_stream_cork() failed");
|
||||||
|
@ -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
|
// Otherwise, PA will keep hammering us for underruns (which it does instead
|
||||||
// of stopping the stream automatically).
|
// of stopping the stream automatically).
|
||||||
if (!state->playing)
|
if (!state->playing && priv->underrun_signalled) {
|
||||||
reset(ao);
|
reset(ao);
|
||||||
|
priv->underrun_signalled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A callback function that is called when the
|
/* A callback function that is called when the
|
||||||
|
|
Loading…
Reference in New Issue