[vlc-devel] commit: System clock is given to input_ClockSetPCR. (Laurent Aimar )

git version control git at videolan.org
Sun Sep 28 13:35:56 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Sep 23 22:29:41 2008 +0200| [e2c71160baa30bbbf237e72e90a36bc59c030580] | committer: Laurent Aimar 

System clock is given to input_ClockSetPCR.

No functionnal change yet.

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

 src/input/clock.c          |   31 +++++++++++++++++--------------
 src/input/es_out.c         |    5 +++--
 src/input/input_internal.h |    2 +-
 3 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/src/input/clock.c b/src/input/clock.c
index 5aae7c7..81fffc5 100644
--- a/src/input/clock.c
+++ b/src/input/clock.c
@@ -144,19 +144,22 @@ void input_ClockInit( input_clock_t *cl, bool b_master, int i_cr_average, int i_
 
 /*****************************************************************************
  * input_ClockSetPCR: manages a clock reference
+ *
+ *  i_ck_stream: date in stream clock
+ *  i_ck_system: date in system clock
  *****************************************************************************/
 void input_ClockSetPCR( input_thread_t *p_input,
-                        input_clock_t *cl, mtime_t i_clock )
+                        input_clock_t *cl,
+                        mtime_t i_ck_stream, mtime_t i_ck_system )
 {
     const bool b_synchronize = p_input->b_can_pace_control && cl->b_master;
-    const mtime_t i_mdate = mdate();
 
     if( ( cl->i_synchro_state != SYNCHRO_OK ) ||
-        ( i_clock == 0 && cl->last_cr != 0 ) )
+        ( i_ck_stream == 0 && cl->last_cr != 0 ) )
     {
         /* Feed synchro with a new reference point. */
-        ClockNewRef( cl, i_clock,
-                         __MAX( cl->last_pts + CR_MEAN_PTS_GAP, i_mdate ) );
+        ClockNewRef( cl, i_ck_stream,
+                         __MAX( cl->last_pts + CR_MEAN_PTS_GAP, i_ck_system ) );
         cl->i_synchro_state = SYNCHRO_OK;
 
         if( !b_synchronize )
@@ -167,8 +170,8 @@ void input_ClockSetPCR( input_thread_t *p_input,
         }
     }
     else if ( cl->last_cr != 0 &&
-              ( (cl->last_cr - i_clock) > CR_MAX_GAP ||
-                (cl->last_cr - i_clock) < - CR_MAX_GAP ) )
+              ( (cl->last_cr - i_ck_stream) > CR_MAX_GAP ||
+                (cl->last_cr - i_ck_stream) < - CR_MAX_GAP ) )
     {
         /* Stream discontinuity, for which we haven't received a
          * warning from the stream control facilities (dd-edited
@@ -177,27 +180,27 @@ void input_ClockSetPCR( input_thread_t *p_input,
         input_ClockInit( cl, cl->b_master, cl->i_cr_average, cl->i_rate );
         /* Feed synchro with a new reference point. */
         msg_Warn( p_input, "feeding synchro with a new reference point trying to recover from clock gap" );
-        ClockNewRef( cl, i_clock,
-                         __MAX( cl->last_pts + CR_MEAN_PTS_GAP, i_mdate ) );
+        ClockNewRef( cl, i_ck_stream,
+                         __MAX( cl->last_pts + CR_MEAN_PTS_GAP, i_ck_system ) );
         cl->i_synchro_state = SYNCHRO_OK;
     }
 
-    cl->last_cr = i_clock;
-    cl->last_sysdate = i_mdate;
+    cl->last_cr = i_ck_stream;
+    cl->last_sysdate = i_ck_system;
 
-    if( !b_synchronize && i_mdate - cl->last_update > 200000 )
+    if( !b_synchronize && i_ck_system - cl->last_update > 200000 )
     {
         /* Smooth clock reference variations. */
         const mtime_t i_extrapoled_clock = ClockCurrent( cl );
         /* Bresenham algorithm to smooth variations. */
         const mtime_t i_tmp = cl->delta_cr * (cl->i_cr_average - 1) +
-                              ( i_extrapoled_clock - i_clock ) * 1  +
+                              ( i_extrapoled_clock - i_ck_stream ) * 1  +
                               cl->i_delta_cr_residue;
 
         cl->i_delta_cr_residue = i_tmp % cl->i_cr_average;
         cl->delta_cr           = i_tmp / cl->i_cr_average;
 
-        cl->last_update = i_mdate;
+        cl->last_update = i_ck_system;
     }
 }
 
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 2d25cb7..578e93b 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -1900,8 +1900,9 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
                 p_pgrm = EsOutProgramAdd( out, i_group );   /* Create it */
 
             i_pcr = (int64_t)va_arg( args, int64_t );
-            /* search program */
-            input_ClockSetPCR( p_sys->p_input, &p_pgrm->clock, i_pcr );
+            /* search program
+             * TODO do not use mdate() but proper stream acquisition date */
+            input_ClockSetPCR( p_sys->p_input, &p_pgrm->clock, i_pcr, mdate() );
             return VLC_SUCCESS;
         }
 
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index fadc167..cd9171d 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -377,7 +377,7 @@ typedef struct
 } input_clock_t;
 
 void    input_ClockInit( input_clock_t *, bool b_master, int i_cr_average, int i_rate );
-void    input_ClockSetPCR( input_thread_t *, input_clock_t *, mtime_t );
+void    input_ClockSetPCR( input_thread_t *, input_clock_t *, mtime_t i_clock, mtime_t i_system );
 void    input_ClockResetPCR( input_clock_t * );
 mtime_t input_ClockGetTS( input_thread_t *, input_clock_t *, mtime_t );
 void    input_ClockSetRate( input_clock_t *cl, int i_rate );




More information about the vlc-devel mailing list