[vlc-commits] spu: lock/unlock only once in spu_Attach()

Rémi Denis-Courmont git at videolan.org
Sun Dec 2 17:58:00 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Dec  2 18:04:50 2018 +0200| [87387fd6285a6c3ea0870b7816a2ba2bc1f12a0c] | committer: Rémi Denis-Courmont

spu: lock/unlock only once in spu_Attach()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=87387fd6285a6c3ea0870b7816a2ba2bc1f12a0c
---

 src/video_output/vout_subpictures.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index fefe77a154..5c459c5521 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -1175,15 +1175,13 @@ static void UpdateSPU(spu_t *spu, const vlc_spu_highlight_t *hl)
 {
     spu_private_t *sys = spu->p;
 
-    vlc_mutex_lock(&sys->lock);
+    vlc_mutex_assert(&sys->lock);
 
     sys->palette.i_entries = 0;
     sys->force_crop = false;
 
-    if (hl == NULL) {
-        vlc_mutex_unlock(&sys->lock);
+    if (hl == NULL)
         return;
-    }
 
     sys->force_crop = true;
     sys->crop.x      = hl->x_start;
@@ -1193,7 +1191,6 @@ static void UpdateSPU(spu_t *spu, const vlc_spu_highlight_t *hl)
 
     if (hl->palette.i_entries == 4) /* XXX: Only DVD palette for now */
         memcpy(&sys->palette, &hl->palette, sizeof(sys->palette));
-    vlc_mutex_unlock(&sys->lock);
 
     msg_Dbg(spu, "crop: %i,%i,%i,%i, palette forced: %i",
             sys->crop.x, sys->crop.y,
@@ -1399,9 +1396,10 @@ void spu_Destroy(spu_t *spu)
  */
 void spu_Attach(spu_t *spu, input_thread_t *input)
 {
+    vlc_mutex_lock(&spu->p->lock);
+
     UpdateSPU(spu, NULL);
 
-    vlc_mutex_lock(&spu->p->lock);
     spu->p->input = input;
 
     if (spu->p->text)
@@ -1725,5 +1723,7 @@ void spu_ChangeMargin(spu_t *spu, int margin)
 
 void spu_SetHighlight(spu_t *spu, const vlc_spu_highlight_t *hl)
 {
+    vlc_mutex_lock(&spu->p->lock);
     UpdateSPU(spu, hl);
+    vlc_mutex_unlock(&spu->p->lock);
 }



More information about the vlc-commits mailing list