[vlc-devel] [PATCH v2 14/18] video_output: return the rendered picture in ThreadDisplayPreparePicture

Steve Lhomme robux4 at ycbcr.xyz
Wed Sep 16 13:14:40 CEST 2020


This makes the use of the result more readable.

The new code is strictly equivalent to the previous one :
If displayed.current is NULL the call sets displayed.current (to a usable
picture or NULL).
---
 src/video_output/video_output.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 98832588ce8..c15dc2c8a67 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1067,8 +1067,8 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout)
 
 
 /* */
-static int ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reuse,
-                                       bool frame_by_frame, bool *paused)
+static picture_t *ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reuse,
+                                              bool frame_by_frame, bool *paused)
 {
     vout_thread_sys_t *sys = vout;
     bool is_late_dropped = sys->is_late_dropped && !sys->pause.is_on && !frame_by_frame;
@@ -1151,15 +1151,7 @@ static int ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reuse,
 
     vlc_mutex_unlock(&sys->filter.lock);
 
-    if (!picture)
-        return VLC_EGENERIC;
-
-    assert(!sys->displayed.next);
-    if (!sys->displayed.current)
-        sys->displayed.current = picture;
-    else
-        sys->displayed.next    = picture;
-    return VLC_SUCCESS;
+    return picture;
 }
 
 static vlc_decoder_device * VoutHoldDecoderDevice(vlc_object_t *o, void *opaque)
@@ -1492,15 +1484,26 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
 
     if (!sys->displayed.current)
     {
+        sys->displayed.current =
         ThreadDisplayPreparePicture(vout, true, frame_by_frame, &paused);
         if (sys->displayed.current == NULL)
             return VLC_EGENERIC; // wait with no known deadline
     }
 
     if (!paused || frame_by_frame)
-        while (!sys->displayed.next
-            && !ThreadDisplayPreparePicture(vout, false, frame_by_frame, &paused))
-            ;
+        while (!sys->displayed.next)
+        {
+            picture_t *picture =
+            ThreadDisplayPreparePicture(vout, false, frame_by_frame, &paused);
+
+            if (!picture)
+                break;
+
+            if (!sys->displayed.current)
+                sys->displayed.current = picture;
+            else
+                sys->displayed.next    = picture;
+        }
 
     if (!sys->displayed.current)
         return VLC_EGENERIC; // wait with no known deadline
-- 
2.26.2



More information about the vlc-devel mailing list