Commit 88655e00 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

pulse: fix race in TimeGet()

Cork state could change asynchronously without the PA lock.
parent 18da36de
...@@ -441,16 +441,20 @@ static int TimeGet(audio_output_t *aout, mtime_t *restrict delay) ...@@ -441,16 +441,20 @@ static int TimeGet(audio_output_t *aout, mtime_t *restrict delay)
{ {
aout_sys_t *sys = aout->sys; aout_sys_t *sys = aout->sys;
pa_stream *s = sys->stream; pa_stream *s = sys->stream;
int ret = -1;
if (pa_stream_is_corked(s) > 0) pa_threaded_mainloop_lock(sys->mainloop);
return -1; /* latency is irrelevant if corked */ if (pa_stream_is_corked(s) <= 0)
{ /* latency is relevant only if not corked */
mtime_t delta = vlc_pa_get_latency(aout, sys->context, s); mtime_t delta = vlc_pa_get_latency(aout, sys->context, s);
if (delta == VLC_TS_INVALID) if (delta != VLC_TS_INVALID)
return -1; {
*delay = delta; *delay = delta;
return 0; ret = 0;
}
}
pa_threaded_mainloop_unlock(sys->mainloop);
return ret;
} }
/* Memory free callback. The block_t address is in front of the data. */ /* Memory free callback. The block_t address is in front of the data. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment