[vlc-devel] [PATCH 05/17] vout: handle when the vlc_clock is reset

Thomas Guillem thomas at gllm.fr
Mon Feb 15 10:15:00 UTC 2021


Abort picture display when the main clock is reset (the master ES is
flushed).

This can speed up the seek process. Indeed, if the audio is flushed
first, the video output can be notified sooner that the main clock is
reset and drop its current.
---
 src/video_output/video_output.c | 47 ++++++++++++++++++++++++---------
 1 file changed, 34 insertions(+), 13 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index d04d3f4d111..ab308b3cc9d 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -972,11 +972,17 @@ static picture_t *ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reus
                     vlc_clock_ConvertToSystem(sys->clock, system_now,
                                               decoded->date, sys->rate);
 
-                if (system_pts == INT64_MAX)
+                if (unlikely(system_pts == VLC_TICK_INVALID))
+                {
+                    /* Flushed */
+                    picture_Release(decoded);
+                    break;
+                }
+                else if (system_pts == INT64_MAX)
                 {
                     /* The clock is paused, notify it (so that the current
-                        * picture is displayed but not the next one), this
-                        * current picture can't be be late. */
+                     * picture is displayed but not the next one), this
+                     * current picture can't be be late. */
                     *paused = true;
                 }
                 else if (is_late_dropped && !decoded->b_force)
@@ -1137,11 +1143,18 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now)
             vlc_clock_ConvertToSystem(sys->clock, system_now, filtered->date,
                                       sys->rate);
 
-        /* The clock is paused, it's too late to fallback to the previous
-         * picture, display the current picture anyway and force the rendering
-         * to now. */
-        if (unlikely(render_subtitle_date == INT64_MAX))
+        if (unlikely(render_subtitle_date == VLC_TICK_INVALID))
+        {
+            /* Flushed */
+            picture_Release(filtered);
+            vlc_mutex_unlock(&sys->display_lock);
+            return VLC_EGENERIC;
+        }
+        else if (unlikely(render_subtitle_date == INT64_MAX))
         {
+            /* The clock is paused, it's too late to fallback to the previous
+             * picture, display the current picture anyway and force the
+             * rendering to now. */
             render_subtitle_date = system_now;
             render_now = true;
         }
@@ -1276,11 +1289,12 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now)
     const vlc_tick_t pts = todisplay->date;
     vlc_tick_t system_pts = render_now ? system_now :
         vlc_clock_ConvertToSystem(sys->clock, system_now, pts, sys->rate);
-    if (unlikely(system_pts == INT64_MAX))
+
+    if (unlikely(system_pts == INT64_MAX || system_pts == VLC_TICK_INVALID))
     {
-        /* The clock is paused, it's too late to fallback to the previous
-         * picture, display the current picture anyway and force the rendering
-         * to now. */
+        /* The clock is paused or flushed, it's too late to fallback to the
+         * previous picture, display the current picture anyway and force the
+         * rendering to now. */
         system_pts = system_now;
         render_now = true;
     }
@@ -1417,7 +1431,14 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
             const vlc_tick_t next_system_pts =
                 vlc_clock_ConvertToSystem(sys->clock, system_now,
                                           sys->displayed.current->date, sys->rate);
-            if (likely(next_system_pts != INT64_MAX))
+
+            if (unlikely(next_system_pts == VLC_TICK_INVALID))
+            {
+                /* Flushed, skip the current picture. */
+                next =
+                    ThreadDisplayPreparePicture(vout, false, false, &paused);
+            }
+            else if (likely(next_system_pts != INT64_MAX))
             {
                 vlc_tick_t date_next = next_system_pts - render_delay;
                 if (date_next <= system_now)
@@ -1434,7 +1455,7 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
             const vlc_tick_t swap_next_pts =
                 vlc_clock_ConvertToSystem(sys->clock, vlc_tick_now(),
                                             next->date, sys->rate);
-            if (likely(swap_next_pts != INT64_MAX))
+            if (likely(swap_next_pts != INT64_MAX && swap_next_pts != VLC_TICK_INVALID))
                 date_refresh = swap_next_pts - render_delay;
 
             // next frame will still need some waiting before display
-- 
2.30.0



More information about the vlc-devel mailing list