[vlc-devel] [PATCH 11/13] vout: set crop borders synchronously

RĂ©mi Denis-Courmont remi at remlab.net
Wed Jun 12 19:48:35 CEST 2019


This fixes an ABBA race if two threads set crop settings simultaneously.
---
 src/video_output/control.h      |  7 -------
 src/video_output/video_output.c | 20 ++++++--------------
 2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/src/video_output/control.h b/src/video_output/control.h
index b733e8ce2b..5c4448a6c0 100644
--- a/src/video_output/control.h
+++ b/src/video_output/control.h
@@ -33,7 +33,6 @@ enum {
     VOUT_CONTROL_MOUSE_STATE,           /* vlc_mouse_t */
     VOUT_CONTROL_DISPLAY_SIZE,          /* window */
 
-    VOUT_CONTROL_CROP_BORDER,           /* border */
     VOUT_CONTROL_VIEWPOINT,             /* viewpoint */
 };
 
@@ -43,12 +42,6 @@ typedef struct {
     union {
         bool    boolean;
         char    *string;
-        struct {
-            unsigned left;
-            unsigned top;
-            unsigned right;
-            unsigned bottom;
-        } border;
         struct {
             unsigned x;
             unsigned y;
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 00518e7236..af5ba49430 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -556,7 +556,6 @@ void vout_ChangeCropBorder(vout_thread_t *vout,
 {
     vout_thread_sys_t *sys = vout->p;
     assert(!sys->dummy);
-    vout_control_cmd_t cmd;
 
     if (left < 0)
         left = 0;
@@ -575,14 +574,14 @@ void vout_ChangeCropBorder(vout_thread_t *vout,
     sys->source.crop.border.bottom = bottom;
 
     vout_UpdateWindowSizeLocked(vout);
+
+    vlc_mutex_lock(&sys->display_lock);
     vlc_mutex_unlock(&sys->window_lock);
 
-    vout_control_cmd_Init(&cmd, VOUT_CONTROL_CROP_BORDER);
-    cmd.border.left = left;
-    cmd.border.top = top;
-    cmd.border.right = right;
-    cmd.border.bottom = bottom;
-    vout_control_Push(&vout->p->control, &cmd);
+    if (sys->display != NULL)
+        vout_SetDisplayCrop(vout->p->display, 0, 0,
+                            left, top, -right, -bottom);
+    vlc_mutex_unlock(&sys->display_lock);
 }
 
 void vout_ControlChangeFilters(vout_thread_t *vout, const char *filters)
@@ -1583,13 +1582,6 @@ static void ThreadControl(vout_thread_t *vout, vout_control_cmd_t cmd)
                              cmd.window.width, cmd.window.height);
         vlc_mutex_unlock(&vout->p->display_lock);
         break;
-    case VOUT_CONTROL_CROP_BORDER:
-        vlc_mutex_lock(&vout->p->display_lock);
-        vout_SetDisplayCrop(vout->p->display, 0, 0,
-                            cmd.border.left, cmd.border.top,
-                            -(int)cmd.border.right, -(int)cmd.border.bottom);
-        vlc_mutex_unlock(&vout->p->display_lock);
-        break;
     case VOUT_CONTROL_VIEWPOINT:
         vlc_mutex_lock(&vout->p->display_lock);
         vout_SetDisplayViewpoint(vout->p->display, &cmd.viewpoint);
-- 
2.20.1



More information about the vlc-devel mailing list