Commit 84eeae30 authored by Christophe Massiot's avatar Christophe Massiot

* modules/audio_filter/resampler/coreaudio.c: more accurate frame length

  calculation
* modules/audio_output/coreaudio.c: apparently the audio card clock can
  be screwed, so probe it at every buffer
* src/audio_output/output.c: Thou shalt not drop buffers
parent fe93476f
......@@ -2,7 +2,7 @@
* coreaudio.c resampler based on CoreAudio's AudioConverter
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: coreaudio.c,v 1.3 2003/05/04 15:02:42 massiot Exp $
* $Id: coreaudio.c,v 1.4 2003/05/11 01:00:26 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -54,6 +54,7 @@ struct aout_filter_sys_t
AudioStreamBasicDescription s_src_stream_format;
AudioStreamBasicDescription s_dst_stream_format;
AudioConverterRef s_converter;
unsigned int i_remainder;
unsigned int i_first_rate;
};
......@@ -109,6 +110,7 @@ static int Create( vlc_object_t *p_this )
}
memset( p_filter->p_sys, 0, sizeof(struct aout_filter_sys_t) );
p_sys->i_first_rate = i_first_rate;
p_sys->i_remainder = 0;
p_sys->s_src_stream_format.mFormatID = kAudioFormatLinearPCM;
p_sys->s_src_stream_format.mFormatFlags
......@@ -240,11 +242,14 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
(char *)&err );
}
p_filter->b_continuity = VLC_TRUE;
p_sys->i_remainder = 0;
}
#endif
i_out_nb = p_in_buf->i_nb_samples * p_filter->output.i_rate
/ p_sys->i_first_rate;
i_out_nb = (p_in_buf->i_nb_samples * p_filter->output.i_rate
+ p_sys->i_remainder) / p_sys->i_first_rate;
p_sys->i_remainder = (p_in_buf->i_nb_samples * p_filter->output.i_rate
+ p_sys->i_remainder) % p_sys->i_first_rate;
i_output_size = i_out_nb * 4 * i_nb_channels;
if ( i_output_size > p_out_buf->i_size )
......
......@@ -2,7 +2,7 @@
* coreaudio.c: CoreAudio output plugin
*****************************************************************************
* Copyright (C) 2002-2003 VideoLAN
* $Id: coreaudio.c,v 1.3 2003/05/04 22:42:15 gbazin Exp $
* $Id: coreaudio.c,v 1.4 2003/05/11 01:00:26 massiot Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -586,6 +586,13 @@ static OSStatus IOCallback( AudioDeviceID inDevice,
host_time.mFlags = kAudioTimeStampHostTimeValid;
AudioDeviceTranslateTime( inDevice, inOutputTime, &host_time );
#if 1
p_sys->clock_diff = - (mtime_t)
AudioConvertHostTimeToNanos( AudioGetCurrentHostTime() ) / 1000;
p_sys->clock_diff += mdate();
#endif
current_date = p_sys->clock_diff +
AudioConvertHostTimeToNanos( host_time.mHostTime ) / 1000;
......
......@@ -2,7 +2,7 @@
* output.c : internal management of output streams for the audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: output.c,v 1.39 2003/05/04 23:39:02 gbazin Exp $
* $Id: output.c,v 1.40 2003/05/11 01:00:26 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -271,7 +271,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
vlc_mutex_lock( &p_aout->output_fifo_lock );
p_buffer = p_aout->output.fifo.p_first;
while ( p_buffer && p_buffer->start_date < mdate() )
while ( p_buffer && p_buffer->start_date < mdate() - AOUT_PTS_TOLERANCE )
{
msg_Dbg( p_aout, "audio output is too slow ("I64Fd"), "
"trashing "I64Fd"us", mdate() - p_buffer->start_date,
......@@ -304,7 +304,8 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
/* Here we suppose that all buffers have the same duration - this is
* generally true, and anyway if it's wrong it won't be a disaster. */
if ( p_buffer->start_date > start_date
+ (p_buffer->end_date - p_buffer->start_date) )
+ (p_buffer->end_date - p_buffer->start_date)
+ AOUT_PTS_TOLERANCE )
{
vlc_mutex_unlock( &p_aout->output_fifo_lock );
if ( !p_aout->output.b_starving )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment