* input.c : internal management of input streams for the audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: input.c,v 1.7 2002/08/21 22:41:59 massiot Exp $
+ * $Id: input.c,v 1.10 2002/08/28 22:25:39 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
#include <vlc/vlc.h>
+#ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+#endif
+
#include "audio_output.h"
#include "aout_internal.h"
/* The decoder is _very_ late. This can only happen if the user
* pauses the stream (or if the decoder is buggy, which cannot
* happen :). */
- msg_Warn( p_aout, "Computed PTS is out of range (%lld), clearing out",
+ msg_Warn( p_aout, "computed PTS is out of range (%lld), clearing out",
start_date );
vlc_mutex_lock( &p_aout->mixer_lock );
aout_FifoSet( p_aout, &p_input->fifo, 0 );
start_date = 0;
}
- if ( p_buffer->start_date < mdate() - AOUT_MIN_PREPARE_TIME )
+ if ( p_buffer->start_date < mdate() + AOUT_MIN_PREPARE_TIME )
{
/* The decoder gives us f*cked up PTS. It's its business, but we
* can't present it anyway, so drop the buffer. */
* synchronization
* Solution : resample the buffer to avoid a scratch.
*/
- audio_sample_format_t new_output;
+ audio_sample_format_t new_input;
int i_ratio, i_nb_filters;
mtime_t old_duration;
aout_filter_t * pp_filters[AOUT_MAX_FILTERS];
msg_Warn( p_aout, "buffer is %lld %s, resampling",
drift > 0 ? drift : -drift,
drift > 0 ? "in advance" : "late" );
- memcpy( &new_output, &p_aout->mixer.mixer,
+ memcpy( &new_input, &p_input->input,
sizeof(audio_sample_format_t) );
old_duration = p_buffer->end_date - p_buffer->start_date;
duration = p_buffer->end_date - start_date;
{
duration = old_duration * 150 / 100;
}
- new_output.i_rate = new_output.i_rate * duration / old_duration;
+ new_input.i_rate = new_input.i_rate * old_duration / duration;
+ aout_FormatPrepare( &new_input );
if ( aout_FiltersCreatePipeline( p_aout, pp_filters,
- &i_nb_filters, &p_input->input,
- &new_output ) < 0 )
+ &i_nb_filters, &new_input,
+ &p_aout->mixer.mixer ) < 0 )
{
msg_Err( p_aout, "couldn't set an input pipeline for resampling" );
vlc_mutex_lock( &p_aout->mixer_lock );
&dummy_alloc );
dummy_alloc.i_bytes_per_sec = __MAX(
dummy_alloc.i_bytes_per_sec,
- p_input->input.i_bytes_per_frame
- * p_input->input.i_rate
- / p_input->input.i_frame_length );
+ new_input.i_bytes_per_frame
+ * new_input.i_rate
+ / new_input.i_frame_length );
dummy_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
- aout_BufferAlloc( &dummy_alloc, old_duration, NULL, p_new_buffer );
+ aout_BufferAlloc( &dummy_alloc, duration, NULL, p_new_buffer );
memcpy( p_new_buffer->p_buffer, p_buffer->p_buffer,
p_buffer->i_nb_bytes );
p_new_buffer->i_nb_samples = p_buffer->i_nb_samples;
p_new_buffer->i_nb_bytes = p_buffer->i_nb_bytes;
+
aout_BufferFree( p_buffer );
p_buffer = p_new_buffer;