]> git.sesse.net Git - vlc/commitdiff
System clock is given to input_ClockSetPCR.
authorLaurent Aimar <fenrir@videolan.org>
Tue, 23 Sep 2008 20:29:41 +0000 (22:29 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Sun, 28 Sep 2008 01:08:36 +0000 (03:08 +0200)
No functionnal change yet.

src/input/clock.c
src/input/es_out.c
src/input/input_internal.h

index 5aae7c77e25c00bd1d36a09cedcc1e0557d8b9db..81fffc5f6398c8d0a96127bae60d2d9089c3e054 100644 (file)
@@ -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;
     }
 }
 
index 2d25cb7c4c363ff3b78b398dd0b02fd311af6cd8..578e93b43c0da89df08a42cd915f8401b4ce6ba5 100644 (file)
@@ -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;
         }
 
index fadc167eb11d6af9185f157a0a30c9b264f02b5a..cd9171df51cd9aec2af11d3d0e9151c7c2883a3f 100644 (file)
@@ -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 );