]> git.sesse.net Git - vlc/commitdiff
No functionnal changes (clean up)
authorLaurent Aimar <fenrir@videolan.org>
Tue, 30 Sep 2008 21:30:00 +0000 (23:30 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Wed, 1 Oct 2008 20:47:39 +0000 (22:47 +0200)
src/input/clock.c
src/input/decoder.c
src/input/es_out.c
src/input/input_clock.h
src/input/input_decoder.h

index f9799561f03de436b34c86b5fb7d26c578ae905e..50ec932f05a2bc0964d155ae826fdc9460150853 100644 (file)
@@ -322,13 +322,16 @@ mtime_t input_clock_GetWakeup( input_clock_t *cl )
 /*****************************************************************************
  * input_clock_GetTS: manages a PTS or DTS
  *****************************************************************************/
-mtime_t input_clock_GetTS( input_clock_t *cl,
+mtime_t input_clock_GetTS( input_clock_t *cl, int *pi_rate,
                            mtime_t i_pts_delay, mtime_t i_ts )
 {
     mtime_t i_converted_ts;
 
     vlc_mutex_lock( &cl->lock );
 
+    if( pi_rate )
+        *pi_rate = cl->i_rate;
+
     if( !cl->b_has_reference )
     {
         vlc_mutex_unlock( &cl->lock );
index d08192dbaccfd25d76d2e52f4f9fe4c6a273d862..12d08cc9f0a0d328e08bdab2a3e894072bf60e4e 100644 (file)
@@ -159,7 +159,7 @@ mtime_t decoder_GetDisplayDate( decoder_t *p_dec, mtime_t i_ts )
 
     if( !p_owner->p_clock )
         return i_ts;
-    return input_clock_GetTS( p_owner->p_clock, p_owner->p_input->i_pts_delay, i_ts );
+    return input_clock_GetTS( p_owner->p_clock, NULL, p_owner->p_input->i_pts_delay, i_ts );
 }
 /* decoder_GetDisplayRate:
  */
@@ -363,29 +363,7 @@ void input_DecoderDecode( decoder_t * p_dec, block_t *p_block )
     }
 }
 
-void input_DecoderDiscontinuity( decoder_t * p_dec, bool b_flush )
-{
-    decoder_owner_sys_t *p_owner = p_dec->p_owner;
-    block_t *p_null;
-
-    /* Empty the fifo */
-    if( p_owner->b_own_thread && b_flush )
-        block_FifoEmpty( p_owner->p_fifo );
-
-    /* Send a special block */
-    p_null = block_New( p_dec, 128 );
-    p_null->i_flags |= BLOCK_FLAG_DISCONTINUITY;
-    if( b_flush && p_dec->fmt_in.i_cat == SPU_ES )
-        p_null->i_flags |= BLOCK_FLAG_CORE_FLUSH;
-    /* FIXME check for p_packetizer or b_packitized from es_format_t of input ? */
-    if( p_owner->p_packetizer && b_flush )
-        p_null->i_flags |= BLOCK_FLAG_CORRUPTED;
-    memset( p_null->p_buffer, 0, p_null->i_buffer );
-
-    input_DecoderDecode( p_dec, p_null );
-}
-
-bool input_DecoderEmpty( decoder_t * p_dec )
+bool input_DecoderIsEmpty( decoder_t * p_dec )
 {
     if( p_dec->p_owner->b_own_thread &&
         block_FifoCount( p_dec->p_owner->p_fifo ) > 0 )
@@ -504,6 +482,29 @@ void input_DecoderChangeDelay( decoder_t *p_dec, mtime_t i_delay )
     p_owner->i_ts_delay = i_delay;
     vlc_mutex_unlock( &p_owner->lock );
 }
+
+void input_DecoderFlush( decoder_t *p_dec )
+{
+    decoder_owner_sys_t *p_owner = p_dec->p_owner;
+    block_t *p_null;
+
+    /* Empty the fifo */
+    if( p_owner->b_own_thread )
+        block_FifoEmpty( p_owner->p_fifo );
+
+    /* Send a special block */
+    p_null = block_New( p_dec, 128 );
+    p_null->i_flags |= BLOCK_FLAG_DISCONTINUITY;
+    if( p_dec->fmt_in.i_cat == SPU_ES )
+        p_null->i_flags |= BLOCK_FLAG_CORE_FLUSH;
+    /* FIXME check for p_packetizer or b_packitized from es_format_t of input ? */
+    if( p_owner->p_packetizer )
+        p_null->i_flags |= BLOCK_FLAG_CORRUPTED;
+    memset( p_null->p_buffer, 0, p_null->i_buffer );
+
+    input_DecoderDecode( p_dec, p_null );
+}
+
 /**
  * Create a decoder object
  *
@@ -769,13 +770,15 @@ static void DecoderSoutBufferFixTs( block_t *p_block,
 {
     assert( p_clock );
 
-    p_block->i_rate = input_clock_GetRate( p_clock );
+    p_block->i_rate = 0;
 
     if( p_block->i_dts > 0 )
-        p_block->i_dts = input_clock_GetTS( p_clock, i_ts_delay, p_block->i_dts );
+        p_block->i_dts = input_clock_GetTS( p_clock, &p_block->i_rate,
+                                            i_ts_delay, p_block->i_dts );
 
     if( p_block->i_pts > 0 )
-        p_block->i_pts = input_clock_GetTS( p_clock, i_ts_delay, p_block->i_pts );
+        p_block->i_pts = input_clock_GetTS( p_clock, &p_block->i_rate,
+                                            i_ts_delay, p_block->i_pts );
 
     if( p_block->i_length > 0 )
         p_block->i_length = ( p_block->i_length * p_block->i_rate +
@@ -784,18 +787,23 @@ static void DecoderSoutBufferFixTs( block_t *p_block,
     if( b_teletext )
         p_block->i_pts = DecoderTeletextFixTs( p_block->i_pts, i_ts_delay );
 }
-static void DecoderAoutBufferFixTs( aout_buffer_t *p_buffer,
+static void DecoderAoutBufferFixTs( aout_buffer_t *p_buffer, int *pi_rate,
                                     input_clock_t *p_clock, mtime_t i_ts_delay )
 {
     /* sout display module does not set clock */
     if( !p_clock )
         return;
 
+    if( !p_buffer->start_date && !p_buffer->end_date )
+        *pi_rate = input_clock_GetRate( p_clock );
+
     if( p_buffer->start_date )
-        p_buffer->start_date = input_clock_GetTS( p_clock, i_ts_delay, p_buffer->start_date );
+        p_buffer->start_date = input_clock_GetTS( p_clock, pi_rate,
+                                                  i_ts_delay, p_buffer->start_date );
 
     if( p_buffer->end_date )
-        p_buffer->end_date = input_clock_GetTS( p_clock, i_ts_delay, p_buffer->end_date );
+        p_buffer->end_date = input_clock_GetTS( p_clock, pi_rate,
+                                                i_ts_delay, p_buffer->end_date );
 }
 static void DecoderVoutBufferFixTs( picture_t *p_picture,
                                     input_clock_t *p_clock, mtime_t i_ts_delay )
@@ -805,7 +813,8 @@ static void DecoderVoutBufferFixTs( picture_t *p_picture,
         return;
 
     if( p_picture->date )
-        p_picture->date = input_clock_GetTS( p_clock, i_ts_delay, p_picture->date );
+        p_picture->date = input_clock_GetTS( p_clock, NULL,
+                                             i_ts_delay, p_picture->date );
 }
 static void DecoderSpuBufferFixTs( subpicture_t *p_subpic,
                                    input_clock_t *p_clock, mtime_t i_ts_delay,
@@ -818,10 +827,12 @@ static void DecoderSpuBufferFixTs( subpicture_t *p_subpic,
         return;
 
     if( p_subpic->i_start )
-        p_subpic->i_start = input_clock_GetTS( p_clock, i_ts_delay, p_subpic->i_start );
+        p_subpic->i_start = input_clock_GetTS( p_clock, NULL,
+                                               i_ts_delay, p_subpic->i_start );
 
     if( p_subpic->i_stop )
-        p_subpic->i_stop = input_clock_GetTS( p_clock, i_ts_delay, p_subpic->i_stop );
+        p_subpic->i_stop = input_clock_GetTS( p_clock, NULL,
+                                              i_ts_delay, p_subpic->i_stop );
 
     /* Do not create ephemere picture because of rounding errors */
     if( !b_ephemere && p_subpic->i_start == p_subpic->i_stop )
@@ -845,7 +856,6 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
     {
         aout_instance_t *p_aout = p_owner->p_aout;
         aout_input_t    *p_aout_input = p_owner->p_aout_input;
-        int i_rate;
         int i_lost;
         int i_played;
 
@@ -875,15 +885,12 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
         DecoderWaitUnpause( p_dec );
 
         const mtime_t i_delay = DecoderGetTotalDelay( p_dec );
+        int i_rate = INPUT_RATE_DEFAULT;
 
-        DecoderAoutBufferFixTs( p_aout_buf, p_clock, i_delay );
+        DecoderAoutBufferFixTs( p_aout_buf, &i_rate, p_clock, i_delay );
 
-        if( p_clock )
-            i_rate = input_clock_GetRate( p_clock );
-        else if( p_block && p_block->i_rate > 0 )
+        if( !p_clock && p_block && p_block->i_rate > 0 )
             i_rate = p_block->i_rate;
-        else
-            i_rate = INPUT_RATE_DEFAULT;
 
         /* FIXME TODO take care of audio-delay for mdate check */
         const mtime_t i_max_date = mdate() + i_delay + AOUT_MAX_ADVANCE_TIME;
index 46399f90cc1dbebc48e4ff5e142973ac50757d54..7b6ceb7bd1353d4a59d3bea39c22c1edb0ee4a76 100644 (file)
@@ -367,25 +367,6 @@ mtime_t input_EsOutGetWakeup( es_out_t *out )
     return input_clock_GetWakeup( p_sys->p_pgrm->p_clock );
 }
 
-static void EsOutDiscontinuity( es_out_t *out, bool b_flush, bool b_audio )
-{
-    es_out_sys_t      *p_sys = out->p_sys;
-    int i;
-
-    for( i = 0; i < p_sys->i_es; i++ )
-    {
-        es_out_id_t *es = p_sys->es[i];
-
-        /* Send a dummy block to let decoder know that
-         * there is a discontinuity */
-        if( es->p_dec && ( !b_audio || es->fmt.i_cat == AUDIO_ES ) )
-        {
-            input_DecoderDiscontinuity( es->p_dec, b_flush );
-            if( es->p_dec_record )
-                input_DecoderDiscontinuity( es->p_dec_record, b_flush );
-        }
-    }
-}
 static void EsOutDecodersChangePause( es_out_t *out, bool b_paused, mtime_t i_date )
 {
     es_out_sys_t *p_sys = out->p_sys;
@@ -542,10 +523,23 @@ void input_EsOutChangePause( es_out_t *out, bool b_paused, mtime_t i_date )
 }
 void input_EsOutChangePosition( es_out_t *out )
 {
-    //es_out_sys_t *p_sys = out->p_sys;
+    es_out_sys_t      *p_sys = out->p_sys;
+
+    for( int i = 0; i < p_sys->i_es; i++ )
+    {
+        es_out_id_t *es = p_sys->es[i];
+
+        /* Send a dummy block to let decoder know that
+         * there is a discontinuity */
+        if( es->p_dec )
+        {
+            input_DecoderFlush( es->p_dec );
+            if( es->p_dec_record )
+                input_DecoderFlush( es->p_dec_record );
+        }
+    }
 
     es_out_Control( out, ES_OUT_RESET_PCR );
-    EsOutDiscontinuity( out, true, false );
 }
 
 bool input_EsOutDecodersEmpty( es_out_t *out )
@@ -557,9 +551,9 @@ bool input_EsOutDecodersEmpty( es_out_t *out )
     {
         es_out_id_t *es = p_sys->es[i];
 
-        if( es->p_dec && !input_DecoderEmpty( es->p_dec ) )
+        if( es->p_dec && !input_DecoderIsEmpty( es->p_dec ) )
             return false;
-        if( es->p_dec_record && !input_DecoderEmpty( es->p_dec_record ) )
+        if( es->p_dec_record && !input_DecoderIsEmpty( es->p_dec_record ) )
             return false;
     }
     return true;
@@ -1558,7 +1552,6 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
 {
     es_out_sys_t   *p_sys = out->p_sys;
     input_thread_t *p_input = p_sys->p_input;
-    es_out_pgrm_t  *p_pgrm = es->p_pgrm;
     int i_total = 0;
 
     if( libvlc_stats( p_input ) )
@@ -1653,8 +1646,8 @@ static void EsOutDel( es_out_t *out, es_out_id_t *es )
     {
         while( !out->p_sys->p_input->b_die && es->p_dec )
         {
-            if( input_DecoderEmpty( es->p_dec ) &&
-                ( !es->p_dec_record || input_DecoderEmpty( es->p_dec_record ) ))
+            if( input_DecoderIsEmpty( es->p_dec ) &&
+                ( !es->p_dec_record || input_DecoderIsEmpty( es->p_dec_record ) ))
                 break;
             msleep( 20*1000 );
         }
@@ -1933,7 +1926,7 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
             {
                 int64_t i_ts = (int64_t)va_arg( args, int64_t );
                 int64_t *pi_ts = (int64_t *)va_arg( args, int64_t * );
-                *pi_ts = input_clock_GetTS( p_sys->p_pgrm->p_clock,
+                *pi_ts = input_clock_GetTS( p_sys->p_pgrm->p_clock, NULL,
                                             p_sys->p_input->i_pts_delay, i_ts );
                 return VLC_SUCCESS;
             }
index 4f004603fda0f46050d5099c0759fe0b7c222523..3b90aa64119dd72fe65fc056def6efac71f2f6f5 100644 (file)
@@ -77,8 +77,11 @@ void    input_clock_ChangePause( input_clock_t *, bool b_paused, mtime_t i_date
 
 /**
  * This function converts a timestamp from stream clock to system clock.
+ *
+ * If pi_rate is provided it will be field with the rate value used for
+ * the conversion.
  */
-mtime_t input_clock_GetTS( input_clock_t *, mtime_t i_pts_delay, mtime_t );
+mtime_t input_clock_GetTS( input_clock_t *, int *pi_rate, mtime_t i_pts_delay, mtime_t );
 
 /**
  * This function returns the current rate.
index eeac4b04655ca5dd03dd31c5be1c662803758d0e..d498b94246038a17abd1be044253370c34f4c8ff 100644 (file)
@@ -47,15 +47,14 @@ void input_DecoderChangePause( decoder_t *, bool b_paused, mtime_t i_date );
 void input_DecoderChangeDelay( decoder_t *, mtime_t i_delay );
 
 /**
- * This function warn the decoder about a discontinuity and allow flushing
- * if requested.
+ * This function will cause a flush of the decoder.
  */
-void input_DecoderDiscontinuity( decoder_t *, bool b_flush );
+void input_DecoderFlush( decoder_t * );
 
 /**
  * This function returns true if the decoder fifo is empty and false otherwise.
  */
-bool input_DecoderEmpty( decoder_t * );
+bool input_DecoderIsEmpty( decoder_t * );
 
 /**
  * This function activates the request closed caption channel.