[vlc-devel] [PATCH] display: separate the check to tell if we need to reset pictures from the call

Steve Lhomme robux4 at ycbcr.xyz
Thu Oct 24 13:49:26 CEST 2019


No need to call Reset twice if the module (d3d9) requested a reset.

---
replaces "display: only call CheckReset if Reset wasn't called"
---
 src/video_output/display.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index 556406f7c6d..aab77171a27 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -479,7 +479,7 @@ static void vout_display_Reset(vout_display_t *vd)
         msg_Err(vd, "Failed to adjust render format");
 }
 
-static void vout_display_CheckReset(vout_display_t *vd)
+static bool vout_display_CheckReset(vout_display_t *vd)
 {
 #ifdef _WIN32
     vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
@@ -487,11 +487,10 @@ static void vout_display_CheckReset(vout_display_t *vd)
     if (unlikely(atomic_exchange_explicit(&osys->reset_pictures, false,
                                           memory_order_relaxed))) {
         atomic_thread_fence(memory_order_acquire);
-        vout_display_Reset(vd);
+        return true;
     }
-#else
-    (void) vd;
 #endif
+    return false;
 }
 
 static int vout_UpdateSourceCrop(vout_display_t *vd)
@@ -617,10 +616,8 @@ void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t
         err2 = vout_UpdateSourceCrop(vd);
     }
 
-    if (err1 || err2)
+    if (err1 || err2 || vout_display_CheckReset(vd))
         vout_display_Reset(vd);
-
-    vout_display_CheckReset(vd);
 }
 
 void vout_display_SetSize(vout_display_t *vd, unsigned width, unsigned height)
@@ -629,9 +626,9 @@ void vout_display_SetSize(vout_display_t *vd, unsigned width, unsigned height)
 
     osys->cfg.display.width  = width;
     osys->cfg.display.height = height;
-    if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_DISPLAY_SIZE, &osys->cfg))
+    if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_DISPLAY_SIZE, &osys->cfg)
+        || vout_display_CheckReset(vd))
         vout_display_Reset(vd);
-    vout_display_CheckReset(vd);
 }
 
 void vout_SetDisplayFilled(vout_display_t *vd, bool is_filled)
@@ -643,9 +640,8 @@ void vout_SetDisplayFilled(vout_display_t *vd, bool is_filled)
 
     osys->cfg.is_display_filled = is_filled;
     if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_DISPLAY_FILLED,
-                             &osys->cfg))
+                             &osys->cfg) || vout_display_CheckReset(vd))
         vout_display_Reset(vd);
-    vout_display_CheckReset(vd);
 }
 
 void vout_SetDisplayZoom(vout_display_t *vd, unsigned num, unsigned den)
@@ -658,9 +654,11 @@ void vout_SetDisplayZoom(vout_display_t *vd, unsigned num, unsigned den)
 
     osys->cfg.zoom.num = num;
     osys->cfg.zoom.den = den;
-    if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_ZOOM, &osys->cfg))
+    if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_ZOOM, &osys->cfg) ||
+        vout_display_CheckReset(vd))
         vout_display_Reset(vd);
-    vout_display_CheckReset(vd);
+    else
+        vout_display_CheckReset(vd);
 }
 
 void vout_SetDisplayAspect(vout_display_t *vd, unsigned dar_num, unsigned dar_den)
@@ -677,9 +675,9 @@ void vout_SetDisplayAspect(vout_display_t *vd, unsigned dar_num, unsigned dar_de
         sar_den = 0;
     }
 
-    if (vout_SetSourceAspect(vd, sar_num, sar_den))
+    if (vout_SetSourceAspect(vd, sar_num, sar_den) ||
+        vout_display_CheckReset(vd))
         vout_display_Reset(vd);
-    vout_display_CheckReset(vd);
 }
 
 void vout_SetDisplayCrop(vout_display_t *vd,
@@ -700,9 +698,8 @@ void vout_SetDisplayCrop(vout_display_t *vd,
         osys->crop.num    = crop_num;
         osys->crop.den    = crop_den;
 
-        if (vout_UpdateSourceCrop(vd))
+        if (vout_UpdateSourceCrop(vd)|| vout_display_CheckReset(vd))
             vout_display_Reset(vd);
-        vout_display_CheckReset(vd);
     }
 }
 
-- 
2.17.1



More information about the vlc-devel mailing list