[vlc-devel] [PATCH 10/13] vout: set crop window synchronously

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


This fixes an ABBA race if two threads set crop settings simultaneously.
---
 src/video_output/control.h      |  1 -
 src/video_output/video_output.c | 19 +++++--------------
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/src/video_output/control.h b/src/video_output/control.h
index 5eaf766bbb..b733e8ce2b 100644
--- a/src/video_output/control.h
+++ b/src/video_output/control.h
@@ -34,7 +34,6 @@ enum {
     VOUT_CONTROL_DISPLAY_SIZE,          /* window */
 
     VOUT_CONTROL_CROP_BORDER,           /* border */
-    VOUT_CONTROL_CROP_WINDOW,           /* window */
     VOUT_CONTROL_VIEWPOINT,             /* viewpoint */
 };
 
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 5c10f9ba76..00518e7236 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -524,7 +524,6 @@ void vout_ChangeCropWindow(vout_thread_t *vout,
 {
     vout_thread_sys_t *sys = vout->p;
     assert(!sys->dummy);
-    vout_control_cmd_t cmd;
 
     if (x < 0)
         x = 0;
@@ -543,14 +542,13 @@ void vout_ChangeCropWindow(vout_thread_t *vout,
     sys->source.crop.window.height = height;
 
     vout_UpdateWindowSizeLocked(vout);
+
+    vlc_mutex_lock(&sys->display_lock);
     vlc_mutex_unlock(&sys->window_lock);
 
-    vout_control_cmd_Init(&cmd, VOUT_CONTROL_CROP_WINDOW);
-    cmd.window.x = x;
-    cmd.window.y = y;
-    cmd.window.width = width;
-    cmd.window.height = height;
-    vout_control_Push(&vout->p->control, &cmd);
+    if (sys->display != NULL)
+        vout_SetDisplayCrop(vout->p->display, 0, 0, x, y, width, height);
+    vlc_mutex_unlock(&vout->p->display_lock);
 }
 
 void vout_ChangeCropBorder(vout_thread_t *vout,
@@ -1585,13 +1583,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_WINDOW:
-        vlc_mutex_lock(&vout->p->display_lock);
-        vout_SetDisplayCrop(vout->p->display, 0, 0,
-                            cmd.window.x, cmd.window.y,
-                            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,
-- 
2.20.1



More information about the vlc-devel mailing list