[vlc-commits] video_output: fix potentially uninitialized render_now

Steve Lhomme git at videolan.org
Thu Feb 4 08:46:20 UTC 2021


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Feb  1 07:50:36 2021 +0100| [f10cebf8158baa3d32ca95fed41906944811876e] | committer: Steve Lhomme

video_output: fix potentially uninitialized render_now

It's in fact an incorrect warning for the compiler as there is no logical case
where render_now would not be set when reaching
  render_now |= sys->displayed.current->b_force;

Move the 'first' variable to the normal playback case to be more logical with
  if (!first && !refresh && !dropped_current_frame)

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

 src/video_output/video_output.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index a4a00abe9c..323b40c084 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1458,7 +1458,6 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
     vout_thread_sys_t *sys = vout;
     bool frame_by_frame = !deadline;
     bool paused = sys->pause.is_on;
-    bool first = !sys->displayed.current;
 
     assert(sys->clock);
 
@@ -1471,7 +1470,7 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
     }
     vlc_mutex_unlock(&sys->filter.lock);
 
-    bool render_now;
+    bool render_now = true;
     if (frame_by_frame)
     {
         picture_t *next;
@@ -1487,13 +1486,12 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
 
         if (!sys->displayed.current)
             return VLC_EGENERIC;
-
-        render_now = true;
     }
     else
     {
         const vlc_tick_t system_now = vlc_tick_now();
         const vlc_tick_t render_delay = vout_chrono_GetHigh(&sys->render) + VOUT_MWAIT_TOLERANCE;
+        const bool first = !sys->displayed.current;
 
         bool dropped_current_frame = false;
 
@@ -1511,7 +1509,7 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
         vlc_tick_t date_refresh = VLC_TICK_INVALID;
 
         picture_t *next = NULL;
-        if (!sys->displayed.current)
+        if (first)
         {
             next =
                 ThreadDisplayPreparePicture(vout, true, false, &paused);
@@ -1569,10 +1567,11 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
             // nothing changed, wait until the next deadline or a control
             return VLC_EGENERIC;
         }
+
+        /* display the picture immediately */
+        render_now |= sys->displayed.current->b_force;
     }
 
-    /* display the picture immediately */
-    render_now |= sys->displayed.current->b_force;
     int ret = ThreadDisplayRenderPicture(vout, render_now);
     return render_now ? VLC_EGENERIC : ret;
 }



More information about the vlc-commits mailing list