[vlc-devel] [PATCH] vout: spu: fix data-race

Thomas Guillem thomas at gllm.fr
Tue May 7 14:17:44 CEST 2019


The clock pointer, used by the vout thread was already protected by this lock.
---
 src/video_output/vout_subpictures.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index 6b106534d3..ae242dda11 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -1489,19 +1489,25 @@ void spu_Detach(spu_t *spu)
 
 void spu_clock_Set(spu_t *spu, vlc_clock_t *clock)
 {
+    vlc_mutex_lock(&spu->p->lock);
     spu->p->clock = clock;
+    vlc_mutex_unlock(&spu->p->lock);
 }
 
 void spu_clock_Reset(spu_t *spu)
 {
+    vlc_mutex_lock(&spu->p->lock);
     if (spu->p->clock)
         vlc_clock_Reset(spu->p->clock);
+    vlc_mutex_unlock(&spu->p->lock);
 }
 
 void spu_clock_SetDelay(spu_t *spu, vlc_tick_t delay)
 {
+    vlc_mutex_lock(&spu->p->lock);
     if (spu->p->clock)
         vlc_clock_SetDelay(spu->p->clock, delay);
+    vlc_mutex_unlock(&spu->p->lock);
 }
 
 /**
-- 
2.20.1



More information about the vlc-devel mailing list