Commit 51e99753 authored by Sam Hocevar's avatar Sam Hocevar

* ./src/audio_output/output.c: reverted my previous aout_OutputNextBuffer

    prototype change; it looks like we won't need it after all.
  * ./src/audio_output/output.c: if audio output is too slow, but we
    know there is no next packet, then we play it anyway. Rationale behind
    this is: better play a slightly wrongly dated packet than play silence,
    because it might be wrongly dated but there are chances it won't break
    audio continuity.
  * ./modules/audio_output/sdl.c: workaround for SDL's crap audio output
    system (callback gets called at random times, and no way to know the
    latency of the samples being played). Audio output is now rather good
    here, but please give feedback.
  * ./modules/audio_output/oss.c: we delay a bit before asking for a new
    buffer to avoid starvation.
parent 1c79a0fa
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_internal.h : internal defines for audio output * aout_internal.h : internal defines for audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: aout_internal.h,v 1.11 2002/08/24 10:19:42 sam Exp $ * $Id: aout_internal.h,v 1.12 2002/08/25 09:39:59 sam Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -211,7 +211,7 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -211,7 +211,7 @@ int aout_OutputNew( aout_instance_t * p_aout,
audio_sample_format_t * p_format ); audio_sample_format_t * p_format );
void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer ); void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer );
void aout_OutputDelete( aout_instance_t * p_aout ); void aout_OutputDelete( aout_instance_t * p_aout );
VLC_EXPORT( aout_buffer_t *, aout_OutputNextBuffer, ( aout_instance_t *, mtime_t, mtime_t, vlc_bool_t ) ); VLC_EXPORT( aout_buffer_t *, aout_OutputNextBuffer, ( aout_instance_t *, mtime_t, vlc_bool_t ) );
void aout_FormatPrepare( audio_sample_format_t * p_format ); void aout_FormatPrepare( audio_sample_format_t * p_format );
void aout_FifoInit( aout_instance_t *, aout_fifo_t *, u32 ); void aout_FifoInit( aout_instance_t *, aout_fifo_t *, u32 );
......
...@@ -4,7 +4,7 @@ struct module_symbols_t ...@@ -4,7 +4,7 @@ struct module_symbols_t
{ {
aout_buffer_t * (* aout_BufferNew_inner) ( aout_instance_t *, aout_input_t *, size_t ) ; aout_buffer_t * (* aout_BufferNew_inner) ( aout_instance_t *, aout_input_t *, size_t ) ;
aout_buffer_t * (* aout_FifoPop_inner) ( aout_instance_t * p_aout, aout_fifo_t * p_fifo ) ; aout_buffer_t * (* aout_FifoPop_inner) ( aout_instance_t * p_aout, aout_fifo_t * p_fifo ) ;
aout_buffer_t * (* aout_OutputNextBuffer_inner) ( aout_instance_t *, mtime_t, mtime_t, vlc_bool_t ) ; aout_buffer_t * (* aout_OutputNextBuffer_inner) ( aout_instance_t *, mtime_t, vlc_bool_t ) ;
aout_input_t * (* __aout_InputNew_inner) ( vlc_object_t *, aout_instance_t **, audio_sample_format_t * ) ; aout_input_t * (* __aout_InputNew_inner) ( vlc_object_t *, aout_instance_t **, audio_sample_format_t * ) ;
aout_instance_t * (* __aout_NewInstance_inner) ( vlc_object_t * ) ; aout_instance_t * (* __aout_NewInstance_inner) ( vlc_object_t * ) ;
char * (* __config_GetPsz_inner) (vlc_object_t *, const char *) ; char * (* __config_GetPsz_inner) (vlc_object_t *, const char *) ;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* alsa.c : alsa plugin for vlc * alsa.c : alsa plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: alsa.c,v 1.7 2002/08/24 10:19:42 sam Exp $ * $Id: alsa.c,v 1.8 2002/08/25 09:39:59 sam Exp $
* *
* Authors: Henri Fallon <henri@videolan.org> - Original Author * Authors: Henri Fallon <henri@videolan.org> - Original Author
* Jeffrey Baker <jwbaker@acm.org> - Port to ALSA 1.0 API * Jeffrey Baker <jwbaker@acm.org> - Port to ALSA 1.0 API
...@@ -473,7 +473,7 @@ static void ALSAFill( aout_instance_t * p_aout ) ...@@ -473,7 +473,7 @@ static void ALSAFill( aout_instance_t * p_aout )
snd_pcm_status_get_tstamp( p_status, &ts_next ); snd_pcm_status_get_tstamp( p_status, &ts_next );
next_date = (mtime_t)ts_next.tv_sec * 1000000 + ts_next.tv_usec; next_date = (mtime_t)ts_next.tv_sec * 1000000 + ts_next.tv_usec;
p_buffer = aout_OutputNextBuffer( p_aout, next_date, 0, p_buffer = aout_OutputNextBuffer( p_aout, next_date,
p_sys->b_can_sleek ); p_sys->b_can_sleek );
/* Audio output buffer shortage -> stop the fill process and /* Audio output buffer shortage -> stop the fill process and
......
...@@ -206,7 +206,7 @@ static int aRtsThread( aout_instance_t * p_aout ) ...@@ -206,7 +206,7 @@ static int aRtsThread( aout_instance_t * p_aout )
/* Get the presentation date of the next write() operation. It /* Get the presentation date of the next write() operation. It
* is equal to the current date + latency */ * is equal to the current date + latency */
p_buffer = aout_OutputNextBuffer( p_aout, mdate() + p_sys->latency, p_buffer = aout_OutputNextBuffer( p_aout, mdate() + p_sys->latency,
0, VLC_FALSE ); VLC_FALSE );
if ( p_buffer != NULL ) if ( p_buffer != NULL )
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* esd.c : EsounD module * esd.c : EsounD module
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: esd.c,v 1.9 2002/08/24 10:19:42 sam Exp $ * $Id: esd.c,v 1.10 2002/08/25 09:39:59 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -203,7 +203,7 @@ static int ESDThread( aout_instance_t * p_aout ) ...@@ -203,7 +203,7 @@ static int ESDThread( aout_instance_t * p_aout )
/* Get the presentation date of the next write() operation. It /* Get the presentation date of the next write() operation. It
* is equal to the current date + buffered samples + esd latency */ * is equal to the current date + buffered samples + esd latency */
p_buffer = aout_OutputNextBuffer( p_aout, mdate() + p_sys->latency, p_buffer = aout_OutputNextBuffer( p_aout, mdate() + p_sys->latency,
0, VLC_FALSE ); VLC_FALSE );
if ( p_buffer != NULL ) if ( p_buffer != NULL )
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* oss.c : OSS /dev/dsp module for vlc * oss.c : OSS /dev/dsp module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2002 VideoLAN * Copyright (C) 2000-2002 VideoLAN
* $Id: oss.c,v 1.17 2002/08/24 21:11:21 sam Exp $ * $Id: oss.c,v 1.18 2002/08/25 09:40:00 sam Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -318,29 +318,29 @@ static int OSSThread( aout_instance_t * p_aout ) ...@@ -318,29 +318,29 @@ static int OSSThread( aout_instance_t * p_aout )
if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF ) if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF )
{ {
mtime_t buffered = (mtime_t)GetBufInfo( p_aout ) * 1000000 mtime_t buffered;
/ p_aout->output.output.i_bytes_per_frame
/ p_aout->output.output.i_rate
* p_aout->output.output.i_frame_length;
while( buffered > 50000 ) do
{ {
msleep( buffered / 2 - 10000 );
buffered = (mtime_t)GetBufInfo( p_aout ) * 1000000 buffered = (mtime_t)GetBufInfo( p_aout ) * 1000000
/ p_aout->output.output.i_bytes_per_frame / p_aout->output.output.i_bytes_per_frame
/ p_aout->output.output.i_rate / p_aout->output.output.i_rate
* p_aout->output.output.i_frame_length; * p_aout->output.output.i_frame_length;
if( buffered < 50000 )
{
break;
} }
msleep( buffered / 2 - 10000 );
} while( VLC_TRUE );
/* Next buffer will be played at mdate()+buffered, and we tell /* Next buffer will be played at mdate()+buffered */
* the audio output that it can wait for a new packet for
* 20000 microseconds. */
p_buffer = aout_OutputNextBuffer( p_aout, mdate() + buffered, p_buffer = aout_OutputNextBuffer( p_aout, mdate() + buffered,
20000, VLC_FALSE ); VLC_FALSE );
} }
else else
{ {
p_buffer = aout_OutputNextBuffer( p_aout, 0, 0, VLC_TRUE ); p_buffer = aout_OutputNextBuffer( p_aout, 0, VLC_TRUE );
} }
if ( p_buffer != NULL ) if ( p_buffer != NULL )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sdl.c : SDL audio output plugin for vlc * sdl.c : SDL audio output plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2002 VideoLAN * Copyright (C) 2000-2002 VideoLAN
* $Id: sdl.c,v 1.5 2002/08/24 10:19:42 sam Exp $ * $Id: sdl.c,v 1.6 2002/08/25 09:40:00 sam Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -38,7 +38,19 @@ ...@@ -38,7 +38,19 @@
#include SDL_INCLUDE_FILE #include SDL_INCLUDE_FILE
#define FRAME_SIZE 2048*2 #define FRAME_SIZE 2048
/*****************************************************************************
* aout_sys_t: SDL audio output method descriptor
*****************************************************************************
* This structure is part of the audio output thread descriptor.
* It describes the specific properties of an audio device.
*****************************************************************************/
struct aout_sys_t
{
mtime_t call_time;
mtime_t buffer_time;
};
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
...@@ -66,12 +78,21 @@ vlc_module_end(); ...@@ -66,12 +78,21 @@ vlc_module_end();
static int Open ( vlc_object_t *p_this ) static int Open ( vlc_object_t *p_this )
{ {
aout_instance_t *p_aout = (aout_instance_t *)p_this; aout_instance_t *p_aout = (aout_instance_t *)p_this;
aout_sys_t * p_sys;
Uint32 i_flags = SDL_INIT_AUDIO; Uint32 i_flags = SDL_INIT_AUDIO;
if( SDL_WasInit( i_flags ) ) if( SDL_WasInit( i_flags ) )
{ {
return 1; return VLC_EGENERIC;
}
/* Allocate structure */
p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) );
if( p_sys == NULL )
{
msg_Err( p_aout, "out of memory" );
return VLC_ENOMEM;
} }
p_aout->output.pf_setformat = SetFormat; p_aout->output.pf_setformat = SetFormat;
...@@ -91,10 +112,11 @@ static int Open ( vlc_object_t *p_this ) ...@@ -91,10 +112,11 @@ static int Open ( vlc_object_t *p_this )
if( SDL_Init( i_flags ) < 0 ) if( SDL_Init( i_flags ) < 0 )
{ {
msg_Err( p_aout, "cannot initialize SDL (%s)", SDL_GetError() ); msg_Err( p_aout, "cannot initialize SDL (%s)", SDL_GetError() );
return 1; free( p_sys );
return VLC_EGENERIC;
} }
return 0; return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -102,6 +124,8 @@ static int Open ( vlc_object_t *p_this ) ...@@ -102,6 +124,8 @@ static int Open ( vlc_object_t *p_this )
*****************************************************************************/ *****************************************************************************/
static int SetFormat( aout_instance_t *p_aout ) static int SetFormat( aout_instance_t *p_aout )
{ {
aout_sys_t * p_sys = p_aout->output.p_sys;
/* TODO: finish and clean this */ /* TODO: finish and clean this */
SDL_AudioSpec desired; SDL_AudioSpec desired;
...@@ -115,15 +139,19 @@ static int SetFormat( aout_instance_t *p_aout ) ...@@ -115,15 +139,19 @@ static int SetFormat( aout_instance_t *p_aout )
/* Open the sound device - FIXME : get the "natural" parameters */ /* Open the sound device - FIXME : get the "natural" parameters */
if( SDL_OpenAudio( &desired, NULL ) < 0 ) if( SDL_OpenAudio( &desired, NULL ) < 0 )
{ {
return -1; return VLC_EGENERIC;
} }
p_aout->output.output.i_format = AOUT_FMT_S16_NE; p_aout->output.output.i_format = AOUT_FMT_S16_NE;
p_aout->output.i_nb_samples = FRAME_SIZE; p_aout->output.i_nb_samples = FRAME_SIZE;
p_sys->call_time = 0;
p_sys->buffer_time = (mtime_t)FRAME_SIZE * 1000000
/ p_aout->output.output.i_rate;
SDL_PauseAudio( 0 ); SDL_PauseAudio( 0 );
return 0; return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -138,9 +166,14 @@ static void Play( aout_instance_t * p_aout ) ...@@ -138,9 +166,14 @@ static void Play( aout_instance_t * p_aout )
*****************************************************************************/ *****************************************************************************/
static void Close ( vlc_object_t *p_this ) static void Close ( vlc_object_t *p_this )
{ {
aout_instance_t *p_aout = (aout_instance_t *)p_this;
aout_sys_t * p_sys = p_aout->output.p_sys;
SDL_PauseAudio( 1 ); SDL_PauseAudio( 1 );
SDL_CloseAudio(); SDL_CloseAudio();
SDL_QuitSubSystem( SDL_INIT_AUDIO ); SDL_QuitSubSystem( SDL_INIT_AUDIO );
free( p_sys );
} }
/***************************************************************************** /*****************************************************************************
...@@ -149,16 +182,29 @@ static void Close ( vlc_object_t *p_this ) ...@@ -149,16 +182,29 @@ static void Close ( vlc_object_t *p_this )
static void SDLCallback( void * _p_aout, byte_t * p_stream, int i_len ) static void SDLCallback( void * _p_aout, byte_t * p_stream, int i_len )
{ {
aout_instance_t * p_aout = (aout_instance_t *)_p_aout; aout_instance_t * p_aout = (aout_instance_t *)_p_aout;
//static mtime_t old = 0; aout_sys_t * p_sys = p_aout->output.p_sys;
//static mtime_t diff = 0;
//mtime_t foo = mdate();
aout_buffer_t * p_buffer; aout_buffer_t * p_buffer;
//if(old) diff = (9 * diff + (foo-old))/10;
/* FIXME : take into account SDL latency instead of mdate() */ /* We try to stay around call_time + buffer_time/2. This is kludgy but
p_buffer = aout_OutputNextBuffer( p_aout, mdate(), 0, VLC_TRUE ); * unavoidable because SDL is completely unable to 1. tell us about its
//p_buffer = aout_OutputNextBuffer( p_aout, foo - diff, 0, VLC_TRUE ); * latency, and 2. call SDLCallback at regular intervals. */
//fprintf(stderr, "foo - old : %lli, diff : %lli\n", foo-old, diff); if( mdate() < p_sys->call_time + p_sys->buffer_time / 2 )
//old=foo; {
/* We can't wait too much, because SDL will be lost, and we can't
* wait too little, because we are not sure that there will be
* samples in the queue. */
mwait( p_sys->call_time + p_sys->buffer_time / 4 );
p_sys->call_time += p_sys->buffer_time;
}
else
{
p_sys->call_time = mdate() + p_sys->buffer_time / 4;
}
/* Tell the output we're playing samples at call_time + 2*buffer_time */
p_buffer = aout_OutputNextBuffer( p_aout, p_sys->call_time
+ 2 * p_sys->buffer_time, VLC_TRUE );
if ( i_len != FRAME_SIZE * sizeof(s16) if ( i_len != FRAME_SIZE * sizeof(s16)
* p_aout->output.output.i_channels ) * p_aout->output.output.i_channels )
...@@ -168,14 +214,11 @@ static void SDLCallback( void * _p_aout, byte_t * p_stream, int i_len ) ...@@ -168,14 +214,11 @@ static void SDLCallback( void * _p_aout, byte_t * p_stream, int i_len )
if ( p_buffer != NULL ) if ( p_buffer != NULL )
{ {
//fprintf(stderr, "got buffer %lli\n", p_buffer->end_date - p_buffer->start_date);
p_aout->p_vlc->pf_memcpy( p_stream, p_buffer->p_buffer, i_len ); p_aout->p_vlc->pf_memcpy( p_stream, p_buffer->p_buffer, i_len );
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
} }
else else
{ {
//fprintf(stderr, "NO BUFFER !\n");
p_aout->p_vlc->pf_memset( p_stream, 0, i_len ); p_aout->p_vlc->pf_memset( p_stream, 0, i_len );
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* waveout.c : Windows waveOut plugin for vlc * waveout.c : Windows waveOut plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: waveout.c,v 1.4 2002/08/19 21:31:11 massiot Exp $ * $Id: waveout.c,v 1.5 2002/08/25 09:40:00 sam Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -310,7 +310,7 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg, ...@@ -310,7 +310,7 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg,
aout_BufferFree( (aout_buffer_t *)p_waveheader->dwUser ); aout_BufferFree( (aout_buffer_t *)p_waveheader->dwUser );
/* FIXME : take into account WaveOut latency instead of mdate() */ /* FIXME : take into account WaveOut latency instead of mdate() */
p_buffer = aout_OutputNextBuffer( p_aout, mdate(), 0 ); p_buffer = aout_OutputNextBuffer( p_aout, mdate(), VLC_FALSE );
PlayWaveOut( p_aout, h_waveout, p_waveheader, p_buffer ); PlayWaveOut( p_aout, h_waveout, p_waveheader, p_buffer );
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout.m: CoreAudio output plugin * aout.m: CoreAudio output plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: aout.m,v 1.6 2002/08/24 10:19:42 sam Exp $ * $Id: aout.m,v 1.7 2002/08/25 09:40:00 sam Exp $
* *
* Authors: Colin Delacroix <colin@zoy.org> * Authors: Colin Delacroix <colin@zoy.org>
* Jon Lech Johansen <jon-vl@nanocrew.net> * Jon Lech Johansen <jon-vl@nanocrew.net>
...@@ -236,7 +236,7 @@ static OSStatus IOCallback( AudioDeviceID inDevice, ...@@ -236,7 +236,7 @@ static OSStatus IOCallback( AudioDeviceID inDevice,
current_date = p_sys->clock_diff current_date = p_sys->clock_diff
+ AudioConvertHostTimeToNanos(host_time.mHostTime) / 1000; + AudioConvertHostTimeToNanos(host_time.mHostTime) / 1000;
p_buffer = aout_OutputNextBuffer( p_aout, current_date, 0, VLC_FALSE ); p_buffer = aout_OutputNextBuffer( p_aout, current_date, VLC_FALSE );
/* move data into output data buffer */ /* move data into output data buffer */
if ( p_buffer != NULL ) if ( p_buffer != NULL )
......
...@@ -306,11 +306,11 @@ static int QNXaoutThread( aout_instance_t * p_aout ) ...@@ -306,11 +306,11 @@ static int QNXaoutThread( aout_instance_t * p_aout )
* p_aout->output.output.i_frame_length; * p_aout->output.output.i_frame_length;
next_date += mdate(); next_date += mdate();
p_buffer = aout_OutputNextBuffer( p_aout, next_date, 0, VLC_FALSE ); p_buffer = aout_OutputNextBuffer( p_aout, next_date, VLC_FALSE );
} }
else else
{ {
p_buffer = aout_OutputNextBuffer( p_aout, 0, 0, VLC_TRUE ); p_buffer = aout_OutputNextBuffer( p_aout, 0, VLC_TRUE );
} }
if ( p_buffer != NULL ) if ( p_buffer != NULL )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout.c: Windows DirectX audio output method * aout.c: Windows DirectX audio output method
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: aout.c,v 1.6 2002/08/24 10:19:42 sam Exp $ * $Id: aout.c,v 1.7 2002/08/25 09:40:00 sam Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -559,7 +559,7 @@ static void DirectSoundThread( notification_thread_t *p_notif ) ...@@ -559,7 +559,7 @@ static void DirectSoundThread( notification_thread_t *p_notif )
} }
/* FIXME : take into account DirectSound latency instead of mdate() */ /* FIXME : take into account DirectSound latency instead of mdate() */
p_buffer = aout_OutputNextBuffer( p_aout, mdate(), 0, VLC_FALSE ); p_buffer = aout_OutputNextBuffer( p_aout, mdate(), VLC_FALSE );
/* Now do the actual memcpy into the circular buffer */ /* Now do the actual memcpy into the circular buffer */
if ( l_bytes1 != p_notif->i_buffer_size ) if ( l_bytes1 != p_notif->i_buffer_size )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* output.c : internal management of output streams for the audio output * output.c : internal management of output streams for the audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: output.c,v 1.10 2002/08/24 10:19:43 sam Exp $ * $Id: output.c,v 1.11 2002/08/25 09:40:00 sam Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -164,28 +164,16 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer ) ...@@ -164,28 +164,16 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
*****************************************************************************/ *****************************************************************************/
aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
mtime_t start_date, mtime_t start_date,
mtime_t timeout,
vlc_bool_t b_can_sleek ) vlc_bool_t b_can_sleek )
{ {
aout_buffer_t * p_buffer; aout_buffer_t * p_buffer;
mtime_t now = mdate();
vlc_mutex_lock( &p_aout->mixer_lock ); vlc_mutex_lock( &p_aout->mixer_lock );
timeout += now;
while( p_aout->output.fifo.p_first == NULL && timeout > now )
{
vlc_mutex_unlock( &p_aout->mixer_lock );
msleep( AOUT_PTS_TOLERANCE / 2 );
vlc_mutex_lock( &p_aout->mixer_lock );
now = mdate();
}
p_buffer = p_aout->output.fifo.p_first; p_buffer = p_aout->output.fifo.p_first;
while ( p_buffer != NULL && p_buffer->start_date < start_date ) while ( p_buffer && p_buffer->start_date < start_date && p_buffer->p_next )
{ {
msg_Dbg( p_aout, "audio output is too slow (%lld), trashing %lldms", msg_Dbg( p_aout, "audio output is too slow (%lld), trashing %lldus",
start_date - p_buffer->start_date, start_date - p_buffer->start_date,
p_buffer->end_date - p_buffer->start_date ); p_buffer->end_date - p_buffer->start_date );
p_buffer = p_buffer->p_next; p_buffer = p_buffer->p_next;
...@@ -198,7 +186,8 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, ...@@ -198,7 +186,8 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
/* Set date to 0, to allow the mixer to send a new buffer ASAP */ /* Set date to 0, to allow the mixer to send a new buffer ASAP */
aout_FifoSet( p_aout, &p_aout->output.fifo, 0 ); aout_FifoSet( p_aout, &p_aout->output.fifo, 0 );
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
msg_Dbg( p_aout, "audio output is starving, waited too long" ); msg_Dbg( p_aout,
"audio output is starving (no input), playing silence" );
return NULL; return NULL;
} }
...@@ -208,7 +197,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, ...@@ -208,7 +197,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
+ (p_buffer->end_date - p_buffer->start_date) ) + (p_buffer->end_date - p_buffer->start_date) )
{ {
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
msg_Dbg( p_aout, "audio output is starving (%lld)", msg_Dbg( p_aout, "audio output is starving (%lld), playing silence",
p_buffer->start_date - start_date ); p_buffer->start_date - start_date );
return NULL; return NULL;
} }
......
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