[vlc-commits] pulse: fix race in TimeGet()
Rémi Denis-Courmont
git at videolan.org
Sat Aug 22 11:22:16 CEST 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Aug 22 12:16:45 2015 +0300| [88655e00d0d90459b37ad1684dd7686c743ee4a7] | committer: Rémi Denis-Courmont
pulse: fix race in TimeGet()
Cork state could change asynchronously without the PA lock.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=88655e00d0d90459b37ad1684dd7686c743ee4a7
---
modules/audio_output/pulse.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index a0060c8..29170b2 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -441,16 +441,20 @@ static int TimeGet(audio_output_t *aout, mtime_t *restrict delay)
{
aout_sys_t *sys = aout->sys;
pa_stream *s = sys->stream;
+ int ret = -1;
- if (pa_stream_is_corked(s) > 0)
- return -1; /* latency is irrelevant if corked */
-
- mtime_t delta = vlc_pa_get_latency(aout, sys->context, s);
- if (delta == VLC_TS_INVALID)
- return -1;
-
- *delay = delta;
- return 0;
+ pa_threaded_mainloop_lock(sys->mainloop);
+ 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);
+ if (delta != VLC_TS_INVALID)
+ {
+ *delay = delta;
+ ret = 0;
+ }
+ }
+ pa_threaded_mainloop_unlock(sys->mainloop);
+ return ret;
}
/* Memory free callback. The block_t address is in front of the data. */
More information about the vlc-commits
mailing list