]> git.sesse.net Git - vlc/commitdiff
* src/audio_output/input.c, mixer.c: don't try to resample when the audio output...
authorGildas Bazin <gbazin@videolan.org>
Mon, 18 Oct 2004 13:57:03 +0000 (13:57 +0000)
committerGildas Bazin <gbazin@videolan.org>
Mon, 18 Oct 2004 13:57:03 +0000 (13:57 +0000)
src/audio_output/input.c
src/audio_output/mixer.c

index 20ded4148d118e86292183a02bd673b1d8663378..8d6c7a050ee78f20200ba439e9d15cb95ecc21d1 100644 (file)
@@ -409,6 +409,36 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
         return 0;
     }
 
+    /* If the audio drift is too big then it's not worth trying to resample
+     * the audio. */
+    if ( start_date != 0 &&
+         ( start_date < p_buffer->start_date - 3 * AOUT_PTS_TOLERANCE ) )
+    {
+        msg_Warn( p_aout, "audio drift is too big ("I64Fd"), clearing out",
+                  start_date - p_buffer->start_date );
+        vlc_mutex_lock( &p_aout->input_fifos_lock );
+        aout_FifoSet( p_aout, &p_input->fifo, 0 );
+        p_input->p_first_byte_to_mix = NULL;
+        vlc_mutex_unlock( &p_aout->input_fifos_lock );
+        if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
+            msg_Warn( p_aout, "timing screwed, stopping resampling" );
+        p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
+        if ( p_input->i_nb_resamplers != 0 )
+        {
+            p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
+            p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
+        }
+        start_date = 0;
+    }
+    else if ( start_date != 0 &&
+              ( start_date > p_buffer->start_date + 3 * AOUT_PTS_TOLERANCE ) )
+    {
+        msg_Warn( p_aout, "audio drift is too big ("I64Fd"), dropping buffer",
+                  start_date - p_buffer->start_date );
+        aout_BufferFree( p_buffer );
+        return 0;
+    }
+
     if ( start_date == 0 ) start_date = p_buffer->start_date;
 
     /* Run pre-filters. */
index 972f12e44b0dd196d54bc14ca802aa9380133a23..519e39596201f5d7bd96eb270e25ec24d7c15c46 100644 (file)
@@ -274,8 +274,13 @@ static int MixBuffer( aout_instance_t * p_aout )
                 /* Round to the nearest multiple */
                 i_nb_bytes /= p_aout->mixer.mixer.i_bytes_per_frame;
                 i_nb_bytes *= p_aout->mixer.mixer.i_bytes_per_frame;
-
-                if( i_nb_bytes < 0 ) break; /* FIXME: reset state properly */
+                if( i_nb_bytes < 0 )
+                {
+                    /* Is it really the best way to do it ? */
+                    aout_FifoSet( p_aout, &p_aout->output.fifo, 0 );
+                    aout_DateSet( &exact_start_date, 0 );
+                    break;
+                }
 
                 p_input->p_first_byte_to_mix = p_buffer->p_buffer + i_nb_bytes;
             }