[vlc-commits] [Git][videolan/vlc][master] 2 commits: input_clock: fix discontinuity when origin has been changed

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Jul 11 09:17:22 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
a7ddfd61 by Thomas Guillem at 2024-07-11T08:50:25+00:00
input_clock: fix discontinuity when origin has been changed

Regression from 03d91093af3fb6f1bd913715bc4656b87ead8f09

Thought that b_has_external_clock was always true after
input_clock_ChangeSystemOrigin() (called at the end of buffering) was
being called, but this variable was never changed.

Therefore, the clock offset after this call always led to a discontinuity.

- - - - -
861556aa by Thomas Guillem at 2024-07-11T08:50:25+00:00
input_clock: remove external clock handling

It was never used.

- - - - -


3 changed files:

- src/clock/input_clock.c
- src/clock/input_clock.h
- src/input/es_out.c


Changes:

=====================================
src/clock/input_clock.c
=====================================
@@ -130,9 +130,7 @@ struct input_clock_t
     clock_point_t ref;
     bool          b_has_reference;
 
-    /* External clock drift */
-    vlc_tick_t    i_external_clock;
-    bool          b_has_external_clock;
+    bool          b_origin_changed;
 
     /* Current modifiers */
     bool    b_paused;
@@ -173,8 +171,8 @@ input_clock_t *input_clock_New( float rate )
     cl->listener.opaque = NULL;
 
     cl->b_has_reference = false;
+    cl->b_origin_changed = false;
     cl->ref = clock_point_Create( VLC_TICK_INVALID, VLC_TICK_INVALID );
-    cl->b_has_external_clock = false;
 
     cl->last = clock_point_Create( VLC_TICK_INVALID, VLC_TICK_INVALID );
 
@@ -234,7 +232,8 @@ vlc_tick_t input_clock_Update( input_clock_t *cl, vlc_object_t *p_log,
         /* */
         b_reset_reference= true;
     }
-    else if (cl->last.stream != VLC_TICK_INVALID && cl->b_has_external_clock)
+    /* Don't check discontinuities if the origin has just been changed */
+    else if (cl->last.stream != VLC_TICK_INVALID && !cl->b_origin_changed)
     {
         assert(cl->last.system != VLC_TICK_INVALID);
 
@@ -258,6 +257,7 @@ vlc_tick_t input_clock_Update( input_clock_t *cl, vlc_object_t *p_log,
             b_reset_reference= true;
         }
     }
+    cl->b_origin_changed = false;
 
     /* */
     if( b_reset_reference )
@@ -269,7 +269,6 @@ vlc_tick_t input_clock_Update( input_clock_t *cl, vlc_object_t *p_log,
         cl->b_has_reference = true;
         cl->ref = clock_point_Create( __MAX( CR_MEAN_PTS_GAP, i_ck_system ),
                                       i_ck_stream );
-        cl->b_has_external_clock = false;
     }
 
     /* Compute the drift between the stream clock and the system clock
@@ -325,9 +324,9 @@ vlc_tick_t input_clock_Update( input_clock_t *cl, vlc_object_t *p_log,
 void input_clock_Reset( input_clock_t *cl )
 {
     cl->b_has_reference = false;
+    cl->b_origin_changed = false;
     cl->ref = cl->last
         = clock_point_Create( VLC_TICK_INVALID, VLC_TICK_INVALID );
-    cl->b_has_external_clock = false;
 
     if (cl->listener.cbs != NULL && cl->listener.cbs->reset != NULL)
         cl->listener.cbs->reset(cl->listener.opaque);
@@ -410,23 +409,12 @@ int input_clock_GetState( input_clock_t *cl,
     return VLC_SUCCESS;
 }
 
-void input_clock_ChangeSystemOrigin( input_clock_t *cl, bool b_absolute, vlc_tick_t i_system )
+void input_clock_ChangeSystemOrigin( input_clock_t *cl, vlc_tick_t i_system )
 {
     assert( cl->b_has_reference );
-    vlc_tick_t i_offset;
-    if( b_absolute )
-    {
-        i_offset = i_system - cl->ref.system - ClockGetTsOffset( cl );
-    }
-    else
-    {
-        if( !cl->b_has_external_clock )
-        {
-            cl->b_has_external_clock = true;
-            cl->i_external_clock     = i_system;
-        }
-        i_offset = i_system - cl->i_external_clock;
-    }
+    cl->b_origin_changed = true;
+
+    vlc_tick_t i_offset = i_system - cl->ref.system - ClockGetTsOffset( cl );
 
     cl->ref.system += i_offset;
     cl->last.system += i_offset;


=====================================
src/clock/input_clock.h
=====================================
@@ -134,10 +134,8 @@ void input_clock_ChangePause(input_clock_t *, bool b_paused, vlc_tick_t i_date);
 /**
  * This function allows rebasing the original system value date (a valid
  * reference point must have been set).
- * When using the absolute mode, it will create a discontinuity unless
- * called immediately after a input_clock_Update.
  */
-void input_clock_ChangeSystemOrigin(input_clock_t *, bool b_absolute, vlc_tick_t i_system);
+void input_clock_ChangeSystemOrigin(input_clock_t *, vlc_tick_t i_system);
 
 /**
  * This function returns the current rate.


=====================================
src/input/es_out.c
=====================================
@@ -1027,7 +1027,7 @@ static void EsOutDecodersStopBuffering(es_out_sys_t *p_sys, bool b_forced)
      *   PCR point.
      */
 
-    input_clock_ChangeSystemOrigin( p_sys->p_pgrm->p_input_clock, true, update );
+    input_clock_ChangeSystemOrigin( p_sys->p_pgrm->p_input_clock, update );
 
     vlc_clock_main_Lock(p_sys->p_pgrm->clocks.main);
     /* Resetting the main_clock here will drop all points that were sent during



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4e1259f35991ba2d5177a349634fc64c4216dc09...861556aad7101650791e6051c1cce9d9a3c4d195

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4e1259f35991ba2d5177a349634fc64c4216dc09...861556aad7101650791e6051c1cce9d9a3c4d195
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list