[vlc-commits] vout: set aspect ratio synchronously

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


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

vout: set aspect ratio synchronously

This fixes an ABBA race if two threads set the factor simultaneously.

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

 src/video_output/control.h      |  1 -
 src/video_output/video_output.c | 12 +++++-------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/video_output/control.h b/src/video_output/control.h
index 087c3f9820..a7568ceec5 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_ASPECT_RATIO,          /* pair */
     VOUT_CONTROL_CROP_BORDER,           /* border */
     VOUT_CONTROL_CROP_RATIO,            /* pair */
     VOUT_CONTROL_CROP_WINDOW,           /* window */
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index e722cf09d3..c97d549db1 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -487,10 +487,13 @@ void vout_ChangeDisplayAspectRatio(vout_thread_t *vout,
     sys->source.dar.den = dar_den;
 
     vout_UpdateWindowSizeLocked(vout);
+
+    vlc_mutex_lock(&sys->display_lock);
     vlc_mutex_unlock(&sys->window_lock);
 
-    vout_control_PushPair(&vout->p->control, VOUT_CONTROL_ASPECT_RATIO,
-                          dar_num, dar_den);
+    if (sys->display != NULL)
+        vout_SetDisplayAspect(sys->display, dar_num, dar_den);
+    vlc_mutex_unlock(&sys->display_lock);
 }
 
 void vout_ChangeCropRatio(vout_thread_t *vout, unsigned num, unsigned den)
@@ -1579,11 +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_ASPECT_RATIO:
-        vlc_mutex_lock(&vout->p->display_lock);
-        vout_SetDisplayAspect(vout->p->display, cmd.pair.a, cmd.pair.b);
-        vlc_mutex_unlock(&vout->p->display_lock);
-        break;
     case VOUT_CONTROL_CROP_RATIO:
         vlc_mutex_lock(&vout->p->display_lock);
         vout_SetDisplayCrop(vout->p->display, cmd.pair.a, cmd.pair.b,



More information about the vlc-commits mailing list