[vlc-devel] commit: Moved clock master flag to es_out. (Laurent Aimar )

git version control git at videolan.org
Sun Sep 28 13:36:02 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Sep 27 16:19:51 2008 +0200| [a18cf1de2e0e1cecfb44894e5043b6806361d15d] | committer: Laurent Aimar 

Moved clock master flag to es_out.

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

 src/input/clock.c       |   56 +++++++++++++++++-----------------------------
 src/input/es_out.c      |    5 +---
 src/input/input.c       |    3 --
 src/input/input_clock.h |   13 ++++------
 4 files changed, 27 insertions(+), 50 deletions(-)

diff --git a/src/input/clock.c b/src/input/clock.c
index d7b53a6..7d1d5b0 100644
--- a/src/input/clock.c
+++ b/src/input/clock.c
@@ -2,6 +2,7 @@
  * input_clock.c: Clock/System date convertions, stream management
  *****************************************************************************
  * Copyright (C) 1999-2008 the VideoLAN team
+ * Copyright (C) 2008 Laurent Aimar
  * $Id$
  *
  * Authors: Christophe Massiot <massiot at via.ecp.fr>
@@ -132,7 +133,6 @@ struct input_clock_t
     average_t drift;
 
     /* Current modifiers */
-    bool    b_master;
     int     i_rate;
 };
 
@@ -142,7 +142,7 @@ static mtime_t ClockSystemToStream( input_clock_t *, mtime_t i_system );
 /*****************************************************************************
  * input_clock_New: create a new clock
  *****************************************************************************/
-input_clock_t *input_clock_New( bool b_master, int i_cr_average, int i_rate )
+input_clock_t *input_clock_New( int i_cr_average, int i_rate )
 {
     input_clock_t *cl = malloc( sizeof(*cl) );
     if( !cl )
@@ -158,7 +158,6 @@ input_clock_t *input_clock_New( bool b_master, int i_cr_average, int i_rate )
     cl->i_next_drift_update = 0;
     AvgInit( &cl->drift, i_cr_average );
 
-    cl->b_master = b_master;
     cl->i_rate = i_rate;
 
     return cl;
@@ -183,7 +182,6 @@ void input_clock_Update( input_clock_t *cl,
                          vlc_object_t *p_log, bool b_can_pace_control,
                          mtime_t i_ck_stream, mtime_t i_ck_system )
 {
-    const bool b_synchronize = b_can_pace_control && cl->b_master;
     bool b_reset_reference = false;
 
     if( ( !cl->b_has_reference ) ||
@@ -217,7 +215,7 @@ void input_clock_Update( input_clock_t *cl,
                                       __MAX( cl->i_ts_max + CR_MEAN_PTS_GAP, i_ck_system ) );
     }
 
-    if( !b_synchronize && cl->i_next_drift_update < i_ck_system )
+    if( !b_can_pace_control && cl->i_next_drift_update < i_ck_system )
     {
         const mtime_t i_converted = ClockSystemToStream( cl, i_ck_system );
 
@@ -239,25 +237,6 @@ void input_clock_Reset( input_clock_t *cl )
 }
 
 /*****************************************************************************
- * input_clock_GetTS: manages a PTS or DTS
- *****************************************************************************/
-mtime_t input_clock_GetTS( input_clock_t *cl,
-                           mtime_t i_pts_delay, mtime_t i_ts )
-{
-    mtime_t i_converted_ts;
-
-    if( !cl->b_has_reference )
-        return 0;
-
-    /* */
-    i_converted_ts = ClockStreamToSystem( cl, i_ts + AvgGet( &cl->drift ) );
-    if( i_converted_ts > cl->i_ts_max )
-        cl->i_ts_max = i_converted_ts;
-
-    return i_converted_ts + i_pts_delay;
-}
-
-/*****************************************************************************
  * input_clock_ChangeRate:
  *****************************************************************************/
 void input_clock_ChangeRate( input_clock_t *cl, int i_rate )
@@ -270,14 +249,6 @@ void input_clock_ChangeRate( input_clock_t *cl, int i_rate )
 }
 
 /*****************************************************************************
- * input_clock_ChangeMaster:
- *****************************************************************************/
-void input_clock_ChangeMaster( input_clock_t *cl, bool b_master )
-{
-    cl->b_master = b_master;
-}
-
-/*****************************************************************************
  * input_clock_GetWakeup
  *****************************************************************************/
 mtime_t input_clock_GetWakeup( input_clock_t *cl )
@@ -286,12 +257,27 @@ mtime_t input_clock_GetWakeup( input_clock_t *cl )
     if( !cl->b_has_reference )
         return 0;
 
-    /* We must not wait if we are not the master clock */
-    if( !cl->b_master  )
+    /* */
+    return ClockStreamToSystem( cl, cl->last.i_stream );
+}
+
+/*****************************************************************************
+ * input_clock_GetTS: manages a PTS or DTS
+ *****************************************************************************/
+mtime_t input_clock_GetTS( input_clock_t *cl,
+                           mtime_t i_pts_delay, mtime_t i_ts )
+{
+    mtime_t i_converted_ts;
+
+    if( !cl->b_has_reference )
         return 0;
 
     /* */
-    return ClockStreamToSystem( cl, cl->last.i_stream );
+    i_converted_ts = ClockStreamToSystem( cl, i_ts + AvgGet( &cl->drift ) );
+    if( i_converted_ts > cl->i_ts_max )
+        cl->i_ts_max = i_converted_ts;
+
+    return i_converted_ts + i_pts_delay;
 }
 
 /*****************************************************************************
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 887bf08..c32bf64 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -646,9 +646,6 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
     p_pgrm->b_selected = true;
 
     /* Switch master stream */
-    if( p_sys->p_pgrm )
-        input_clock_ChangeMaster( p_sys->p_pgrm->p_clock, false );
-    input_clock_ChangeMaster( p_pgrm->p_clock, true );
     p_sys->p_pgrm = p_pgrm;
 
     /* Update "program" */
@@ -697,7 +694,7 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group )
     p_pgrm->psz_now_playing = NULL;
     p_pgrm->psz_publisher = NULL;
     p_pgrm->p_epg = NULL;
-    p_pgrm->p_clock = input_clock_New( false, p_input->p->input.i_cr_average, p_sys->i_rate );
+    p_pgrm->p_clock = input_clock_New( p_input->p->input.i_cr_average, p_sys->i_rate );
     if( !p_pgrm->p_clock )
     {
         free( p_pgrm );
diff --git a/src/input/input.c b/src/input/input.c
index 6253649..14fa876 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -774,10 +774,7 @@ static void MainLoop( input_thread_t *p_input )
             {
                 mtime_t i_new_wakeup = input_EsOutGetWakeup( p_input->p->p_es_out );
                 if( !i_new_wakeup )
-                {
-                    msg_Err( p_input, "RESET" );
                     i_wakeup = 0;
-                }
             }
         } while( i_current < i_wakeup );
     }
diff --git a/src/input/input_clock.h b/src/input/input_clock.h
index 5f78c67..db5340a 100644
--- a/src/input/input_clock.h
+++ b/src/input/input_clock.h
@@ -40,7 +40,7 @@ typedef struct input_clock_t input_clock_t;
  * This function creates a new input_clock_t.
  * You must use input_clock_Delete to delete it once unused.
  */
-input_clock_t *input_clock_New( bool b_master, int i_cr_average, int i_rate );
+input_clock_t *input_clock_New( int i_cr_average, int i_rate );
 /**
  * This function destroys a input_clock_t created by input_clock_New.
  */
@@ -59,22 +59,19 @@ void    input_clock_Update( input_clock_t *, vlc_object_t *p_log,
 void    input_clock_Reset( input_clock_t * );
 
 /**
- * This function converts a timestamp from stream clock to system clock.
- */
-mtime_t input_clock_GetTS( input_clock_t *, mtime_t i_pts_delay, mtime_t );
-/**
  * This functions will return a deadline used to control the reading speed.
  */
 mtime_t input_clock_GetWakeup( input_clock_t *cl );
+
 /**
  * This functions allows to change the actual reading speed.
  */
 void    input_clock_ChangeRate( input_clock_t *cl, int i_rate );
+
 /**
- * This function allows to change the master status of a clock.
- * FIXME it should probably be moved out of input_clock_t.
+ * This function converts a timestamp from stream clock to system clock.
  */
-void    input_clock_ChangeMaster( input_clock_t *cl, bool b_master );
+mtime_t input_clock_GetTS( input_clock_t *, mtime_t i_pts_delay, mtime_t );
 
 #endif
 




More information about the vlc-devel mailing list