X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=plugins%2Fsdl%2Faout_sdl.c;h=4db795f30388be9a6e3470e3eab53fb6335e7889;hb=9e3ab283c258cba17e4ca6730d84f9d00d49b068;hp=28743655bbd4d1b30a404dd833c45a328b44540d;hpb=c40571df602ed76eaf7971130f212f4a79a3f5c5;p=vlc diff --git a/plugins/sdl/aout_sdl.c b/plugins/sdl/aout_sdl.c index 28743655bb..4db795f303 100644 --- a/plugins/sdl/aout_sdl.c +++ b/plugins/sdl/aout_sdl.c @@ -2,7 +2,7 @@ * aout_sdl.c : audio sdl functions library ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: aout_sdl.c,v 1.26 2002/02/24 20:51:10 gbazin Exp $ + * $Id: aout_sdl.c,v 1.29 2002/06/01 12:32:00 sam Exp $ * * Authors: Michel Kaempf * Samuel Hocevar @@ -30,15 +30,13 @@ #include /* open(), O_WRONLY */ #include /* strerror() */ #include /* write(), close() */ -#include /* "intf_msg.h" */ #include /* calloc(), malloc(), free() */ -#include +#include +#include #include SDL_INCLUDE_FILE -#include "audio_output.h" /* aout_thread_t */ - /***************************************************************************** * aout_sys_t: dsp audio output method descriptor ***************************************************************************** @@ -49,21 +47,20 @@ /* the overflow limit is used to prevent the fifo from growing too big */ #define OVERFLOWLIMIT 100000 -typedef struct aout_sys_s +struct aout_sys_s { byte_t * audio_buf; int i_audio_end; - boolean_t b_active; - -} aout_sys_t; + vlc_bool_t b_active; +}; /***************************************************************************** * Local prototypes. *****************************************************************************/ static int aout_Open ( aout_thread_t *p_aout ); static int aout_SetFormat ( aout_thread_t *p_aout ); -static long aout_GetBufInfo ( aout_thread_t *p_aout, long l_buffer_info ); +static int aout_GetBufInfo ( aout_thread_t *p_aout, int i_buffer_info ); static void aout_Play ( aout_thread_t *p_aout, byte_t *buffer, int i_size ); static void aout_Close ( aout_thread_t *p_aout ); @@ -92,7 +89,6 @@ void _M( aout_getfunctions )( function_list_t * p_function_list ) static int aout_Open( aout_thread_t *p_aout ) { SDL_AudioSpec desired; - int i_channels = p_aout->b_stereo ? 2 : 1; if( SDL_WasInit( SDL_INIT_AUDIO ) != 0 ) { @@ -104,7 +100,7 @@ static int aout_Open( aout_thread_t *p_aout ) if( p_aout->p_sys == NULL ) { - intf_ErrMsg( "aout error: %s", strerror(ENOMEM) ); + msg_Err( p_aout, "out of memory" ); return( 1 ); } @@ -121,7 +117,7 @@ static int aout_Open( aout_thread_t *p_aout ) #endif ) < 0 ) { - intf_ErrMsg( "aout error: can't initialize SDL (%s)", SDL_GetError() ); + msg_Err( p_aout, "cannot initialize SDL (%s)", SDL_GetError() ); free( p_aout->p_sys ); return( 1 ); } @@ -130,12 +126,16 @@ static int aout_Open( aout_thread_t *p_aout ) p_aout->p_sys->audio_buf = malloc( OVERFLOWLIMIT ); /* Initialize some variables */ - desired.freq = p_aout->l_rate; /* TODO: write conversion beetween AOUT_FORMAT_DEFAULT * AND AUDIO* from SDL. */ + desired.freq = p_aout->i_rate; +#ifdef WORDS_BIGENDIAN + desired.format = AUDIO_S16MSB; /* stereo 16 bits */ +#else desired.format = AUDIO_S16LSB; /* stereo 16 bits */ - desired.channels = i_channels; +#endif + desired.channels = p_aout->i_channels; desired.callback = aout_SDLCallback; desired.userdata = p_aout->p_sys; desired.samples = 1024; @@ -147,7 +147,7 @@ static int aout_Open( aout_thread_t *p_aout ) */ if( SDL_OpenAudio( &desired, NULL ) < 0 ) { - intf_ErrMsg( "aout error: SDL_OpenAudio failed (%s)", SDL_GetError() ); + msg_Err( p_aout, "SDL_OpenAudio failed (%s)", SDL_GetError() ); SDL_QuitSubSystem( SDL_INIT_AUDIO ); free( p_aout->p_sys ); return( -1 ); @@ -171,12 +171,15 @@ static int aout_SetFormat( aout_thread_t *p_aout ) { /* TODO: finish and clean this */ SDL_AudioSpec desired; - int i_stereo = p_aout->b_stereo ? 2 : 1; /*i_format = p_aout->i_format;*/ - desired.freq = p_aout->l_rate; /* Set the output rate */ + desired.freq = p_aout->i_rate; /* Set the output rate */ +#ifdef WORDS_BIGENDIAN + desired.format = AUDIO_S16MSB; /* stereo 16 bits */ +#else desired.format = AUDIO_S16LSB; /* stereo 16 bits */ - desired.channels = i_stereo; +#endif + desired.channels = p_aout->i_channels; desired.callback = aout_SDLCallback; desired.userdata = p_aout->p_sys; desired.samples = 2048; @@ -201,16 +204,16 @@ static int aout_SetFormat( aout_thread_t *p_aout ) * aout_GetBufInfo: buffer status query ***************************************************************************** * returns the number of bytes in the audio buffer compared to the size of - * l_buffer_limit... + * i_buffer_limit... *****************************************************************************/ -static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit ) +static int aout_GetBufInfo( aout_thread_t *p_aout, int i_buffer_limit ) { - if(l_buffer_limit > p_aout->p_sys->i_audio_end) + if(i_buffer_limit > p_aout->p_sys->i_audio_end) { /* returning 0 here juste gives awful sound in the speakers :/ */ - return( l_buffer_limit ); + return( i_buffer_limit ); } - return( p_aout->p_sys->i_audio_end - l_buffer_limit); + return( p_aout->p_sys->i_audio_end - i_buffer_limit); } /***************************************************************************** @@ -261,11 +264,11 @@ static void aout_Close( aout_thread_t *p_aout ) *****************************************************************************/ static void aout_SDLCallback( void *userdata, byte_t *stream, int len ) { - struct aout_sys_s * p_sys = userdata; + aout_sys_t * p_sys = userdata; if( p_sys->i_audio_end > OVERFLOWLIMIT ) { - intf_ErrMsg( "aout error: aout_SDLCallback overflowed" ); +//X msg_Err( p_aout, "aout_SDLCallback overflowed" ); free( p_sys->audio_buf ); p_sys->audio_buf = NULL;