[vlc-devel] [PATCH 08/16] video_output: return a pre-rendered picture from ThreadDisplayPreparePicture

Steve Lhomme robux4 at ycbcr.xyz
Fri Oct 16 16:26:39 CEST 2020


Let ThreadDisplayPicture decide what to do with it.

In the first call sys->displayed.current is NULL, so that's always the value
read. We can copy the assert on sys->displayed.next from the original code.

In the second call sys->displayed.current is never NULL, so we already read
the sys->displayed.next value. The assert on sys->displayed.next from the
original code is not needed.
The while loop was ending if ThreadDisplayPreparePicture didn't return SUCCESS
so that's when sys->displayed.next is read as NULL.
---
 src/video_output/video_output.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 62d87aa55ab..ff0a2e26123 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1060,7 +1060,7 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout)
 
 
 /* */
-static int ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reuse_decoded,
+static picture_t *ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reuse_decoded,
                                        bool frame_by_frame, bool *paused)
 {
     vout_thread_sys_t *sys = vout;
@@ -1146,15 +1146,7 @@ static int ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reuse_decod
 
     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)
@@ -1483,15 +1475,22 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
     if (deadline)
         *deadline = VLC_TICK_INVALID;
 
-    if (first)
-        if (ThreadDisplayPreparePicture(vout, true, frame_by_frame, &paused) != VLC_SUCCESS) /* FIXME not sure it is ok */
-            return VLC_EGENERIC;
+    if (!sys->displayed.current)
+    {
+        assert(!sys->displayed.next);
+        sys->displayed.current =
+            ThreadDisplayPreparePicture(vout, true, frame_by_frame, &paused);
+        if (!sys->displayed.current)
+            return VLC_EGENERIC; // wait with no known deadline
+    }
 
     if (!paused || frame_by_frame)
     {
         while (!sys->displayed.next)
         {
-            if (ThreadDisplayPreparePicture(vout, false, frame_by_frame, &paused) != VLC_SUCCESS)
+            sys->displayed.next =
+                ThreadDisplayPreparePicture(vout, false, frame_by_frame, &paused);
+            if (!sys->displayed.next)
                 break;
         }
     }
-- 
2.26.2



More information about the vlc-devel mailing list