[vlc-commits] mixer: do not check for expired input PTS

Rémi Denis-Courmont git at videolan.org
Thu Jun 9 21:39:39 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jun  9 19:43:46 2011 +0300| [3ac60f9326a0c135fccce57046bc2215b22fc769] | committer: Rémi Denis-Courmont

mixer: do not check for expired input PTS

The audio input drops expired packets before they hit the mixer. Since
we only support a single input per mixer, the mixer check is mostly
redumdant.

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

 src/audio_output/mixer.c |   40 +++++++++++++---------------------------
 1 files changed, 13 insertions(+), 27 deletions(-)

diff --git a/src/audio_output/mixer.c b/src/audio_output/mixer.c
index c7ade44..424f42c 100644
--- a/src/audio_output/mixer.c
+++ b/src/audio_output/mixer.c
@@ -97,6 +97,7 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
     aout_mixer_input_t *p_input = p_mixer->input;
     aout_fifo_t *p_fifo = &p_input->fifo;
     mtime_t now = mdate();
+    const unsigned samples = p_aout->output.i_nb_samples;
 
     aout_lock_input_fifos( p_aout );
     aout_lock_output_fifo( p_aout );
@@ -119,41 +120,24 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
 
     aout_unlock_output_fifo( p_aout );
 
-    /* See if we have enough data to prepare a new buffer for the audio
-     * output. First : start date. */
+    /* See if we have enough data to prepare a new buffer for the audio output. */
+    aout_buffer_t *p_buffer = p_fifo->p_first;
+    if( p_buffer == NULL )
+        goto giveup;
+
+    /* Find the earliest start date available. */
     if ( !start_date )
     {
-        /* Find the latest start date available. */
-        aout_buffer_t *p_buffer;
-        for( ;; )
-        {
-            p_buffer = p_fifo->p_first;
-            if( p_buffer == NULL )
-                goto giveup;
-            if( p_buffer->i_pts >= now )
-                break;
-
-            msg_Warn( p_mixer, "input PTS is out of range (%"PRId64"), "
-                      "trashing", now - p_buffer->i_pts );
-            aout_BufferFree( aout_FifoPop( p_fifo ) );
-        }
-
-        date_Set( &exact_start_date, p_buffer->i_pts );
         start_date = p_buffer->i_pts;
+        date_Set( &exact_start_date, start_date );
     }
-
-    date_Increment( &exact_start_date, p_aout->output.i_nb_samples );
-    mtime_t end_date = date_Get( &exact_start_date );
+    /* Compute the end date for the new buffer. */
+    mtime_t end_date = date_Increment( &exact_start_date, samples );
 
     /* Check that start_date is available. */
-    aout_buffer_t *p_buffer = p_fifo->p_first;
     mtime_t prev_date;
-
     for( ;; )
     {
-        if( p_buffer == NULL )
-            goto giveup;
-
         /* Check for the continuity of start_date */
         prev_date = p_buffer->i_pts + p_buffer->i_length;
         if( prev_date >= start_date - 1 )
@@ -163,7 +147,10 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
         msg_Warn( p_mixer, "the mixer got a packet in the past (%"PRId64")",
                   start_date - prev_date );
         aout_BufferFree( aout_FifoPop( p_fifo ) );
+
         p_buffer = p_fifo->p_first;
+        if( p_buffer == NULL )
+            goto giveup;
     }
 
     /* Check that we have enough samples. */
@@ -218,7 +205,6 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
         }
 
         /* Build packet with adequate number of samples */
-        const unsigned samples = p_aout->output.i_nb_samples;
         unsigned needed = samples * framesize;
         p_buffer = block_Alloc( needed );
         if( unlikely(p_buffer == NULL) )



More information about the vlc-commits mailing list