[vlc-commits] vout: set crop borders synchronously

Rémi Denis-Courmont git at videolan.org
Fri Jun 14 05:31:26 CEST 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jun 12 19:34:50 2019 +0300| [2213524ed4aeedda80989b16592edb2c296ed1aa] | committer: Rémi Denis-Courmont

vout: set crop borders synchronously

This fixes an ABBA race if two threads set crop settings simultaneously.

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

 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 */
 };
 
@@ -44,12 +43,6 @@ typedef struct {
         bool    boolean;
         char    *string;
         struct {
-            unsigned left;
-            unsigned top;
-            unsigned right;
-            unsigned bottom;
-        } border;
-        struct {
             unsigned x;
             unsigned y;
             unsigned width;
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 17556b854f..da8c5e2333 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);



More information about the vlc-commits mailing list