[vlc-commits] video_output: return a pre-rendered picture from ThreadDisplayPreparePicture

Steve Lhomme git at videolan.org
Tue Oct 20 11:03:02 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Sep 16 13:14:55 2020 +0200| [3d22269eff0ca4d29b65bb7d30d7e5bd49dcc24f] | committer: Steve Lhomme

video_output: return a pre-rendered picture from ThreadDisplayPreparePicture

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.

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

 src/video_output/video_output.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 62d87aa55a..b155bbf54f 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1060,7 +1060,8 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout)
 
 
 /* */
-static int ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reuse_decoded,
+VLC_USED
+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 +1147,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 +1476,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;
         }
     }



More information about the vlc-commits mailing list