[vlc-commits] vout: reset "pictures" at right time

Rémi Denis-Courmont git at videolan.org
Wed Dec 26 20:56:08 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Dec 26 16:36:03 2018 +0200| [42915026036c45cb4a46bf7bc379e8cbe8fb7fbd] | committer: Rémi Denis-Courmont

vout: reset "pictures" at right time

This sends the pictures reset control to display, and updates the
display conversion filters at the needed time. That is to say after the
display format control requests are processed.

This fixes a race whereby a picture is allocated and rendered with the
old format after the reset request is sent but before it is processed.

Fixes #21580.

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

 src/video_output/display.c | 48 +++++++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index 1438164e8c..6dd3ad21d8 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -458,12 +458,6 @@ static void VoutDisplayDestroyRender(vout_display_t *vd)
         filter_chain_Delete(osys->converters);
 }
 
-static int VoutDisplayResetRender(vout_display_t *vd)
-{
-    VoutDisplayDestroyRender(vd);
-    return VoutDisplayCreateRender(vd);
-}
-
 static void VoutDisplayEventMouse(vout_display_t *vd, int event, va_list args)
 {
     vout_display_owner_sys_t *osys = vd->owner.sys;
@@ -676,22 +670,6 @@ bool vout_ManageDisplay(vout_display_t *vd)
             msg_Err(vd, "Failed to set on top");
     }
 #endif
-
-    if (atomic_exchange(&osys->reset_pictures, false)) {
-        if (osys->pool != NULL) {
-            picture_pool_Release(osys->pool);
-            osys->pool = NULL;
-        }
-
-        if (vout_display_Control(vd, VOUT_DISPLAY_RESET_PICTURES, &osys->cfg,
-                                 &vd->fmt)) {
-            /* FIXME what to do here ? */
-            msg_Err(vd, "Failed to reset pictures (probably fatal)");
-        }
-        VoutDisplayResetRender(vd);
-        return true;
-    }
-
     return false;
 }
 
@@ -740,6 +718,26 @@ void vout_FilterFlush(vout_display_t *vd)
         filter_chain_VideoFlush(osys->converters);
 }
 
+static void vout_display_Reset(vout_display_t *vd)
+{
+    vout_display_owner_sys_t *osys = vd->owner.sys;
+
+    if (likely(!atomic_exchange(&osys->reset_pictures, false)))
+        return;
+
+    VoutDisplayDestroyRender(vd);
+
+    if (osys->pool != NULL) {
+        picture_pool_Release(osys->pool);
+        osys->pool = NULL;
+    }
+
+    if (vout_display_Control(vd, VOUT_DISPLAY_RESET_PICTURES, &osys->cfg,
+                             &vd->fmt)
+     || VoutDisplayCreateRender(vd))
+        msg_Err(vd, "Failed to adjust render format");
+}
+
 static void vout_UpdateSourceCrop(vout_display_t *vd)
 {
     vout_display_owner_sys_t *osys = vd->owner.sys;
@@ -843,6 +841,7 @@ void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t
          * over the new decoder crop settings. */
         vout_UpdateSourceCrop(vd);
     }
+    vout_display_Reset(vd);
 }
 
 void vout_SetDisplaySize(vout_display_t *vd, unsigned width, unsigned height)
@@ -852,6 +851,7 @@ void vout_SetDisplaySize(vout_display_t *vd, unsigned width, unsigned height)
     osys->cfg.display.width  = width;
     osys->cfg.display.height = height;
     vout_display_Control(vd, VOUT_DISPLAY_CHANGE_DISPLAY_SIZE, &osys->cfg);
+    vout_display_Reset(vd);
 }
 
 void vout_SetDisplayFilled(vout_display_t *vd, bool is_filled)
@@ -863,6 +863,7 @@ void vout_SetDisplayFilled(vout_display_t *vd, bool is_filled)
 
     osys->cfg.is_display_filled = is_filled;
     vout_display_Control(vd, VOUT_DISPLAY_CHANGE_DISPLAY_FILLED, &osys->cfg);
+    vout_display_Reset(vd);
 }
 
 void vout_SetDisplayZoom(vout_display_t *vd, unsigned num, unsigned den)
@@ -891,6 +892,7 @@ void vout_SetDisplayZoom(vout_display_t *vd, unsigned num, unsigned den)
     osys->cfg.zoom.num = num;
     osys->cfg.zoom.den = den;
     vout_display_Control(vd, VOUT_DISPLAY_CHANGE_ZOOM, &osys->cfg);
+    vout_display_Reset(vd);
 }
 
 void vout_SetDisplayAspect(vout_display_t *vd, unsigned dar_num, unsigned dar_den)
@@ -908,6 +910,7 @@ void vout_SetDisplayAspect(vout_display_t *vd, unsigned dar_num, unsigned dar_de
     }
 
     vout_SetSourceAspect(vd, sar_num, sar_den);
+    vout_display_Reset(vd);
 }
 
 void vout_SetDisplayCrop(vout_display_t *vd,
@@ -929,6 +932,7 @@ void vout_SetDisplayCrop(vout_display_t *vd,
         osys->crop.den    = crop_den;
 
         vout_UpdateSourceCrop(vd);
+        vout_display_Reset(vd);
     }
 }
 



More information about the vlc-commits mailing list