Commit 63757407 authored by Pierre Baillet's avatar Pierre Baillet

- minor cosmetic changes :P

- modified alsa and sdl default level to 50.
parent 4cff6916
...@@ -145,7 +145,7 @@ static int aout_Probe( probedata_t *p_data ) ...@@ -145,7 +145,7 @@ static int aout_Probe( probedata_t *p_data )
} }
/* And return score */ /* And return score */
return( 100 ); return( 50 );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -66,6 +66,7 @@ typedef struct aout_sys_s ...@@ -66,6 +66,7 @@ typedef struct aout_sys_s
{ {
byte_t * audio_buf; byte_t * audio_buf;
int i_audio_end; int i_audio_end;
boolean_t b_active;
} aout_sys_t; } aout_sys_t;
...@@ -107,7 +108,10 @@ static int aout_Probe( probedata_t *p_data ) ...@@ -107,7 +108,10 @@ static int aout_Probe( probedata_t *p_data )
/* Start AudioSDL */ /* Start AudioSDL */
if( SDL_Init(SDL_INIT_AUDIO) != 0) if( SDL_Init(SDL_INIT_AUDIO) != 0)
intf_ErrMsgImm( "aout_Probe: SDL init error: %s", SDL_GetError() ); {
intf_DbgMsg( "aout_Probe: SDL init error: %s", SDL_GetError() );
return( 0 );
}
/* asks for a minimum audio spec so that we are sure the dsp exists */ /* asks for a minimum audio spec so that we are sure the dsp exists */
desired = (SDL_AudioSpec *)malloc( sizeof(SDL_AudioSpec) ); desired = (SDL_AudioSpec *)malloc( sizeof(SDL_AudioSpec) );
...@@ -125,14 +129,17 @@ static int aout_Probe( probedata_t *p_data ) ...@@ -125,14 +129,17 @@ static int aout_Probe( probedata_t *p_data )
* the plugin. Return a score of 0. */ * the plugin. Return a score of 0. */
if(SDL_OpenAudio( desired, obtained ) < 0) if(SDL_OpenAudio( desired, obtained ) < 0)
{ {
SDL_CloseAudio(); free( desired );
intf_ErrMsgImm( "aout_Probe: aout sdl error : %s", SDL_GetError() ); free( obtained );
intf_DbgMsg( "aout_Probe: aout sdl error : %s", SDL_GetError() );
return( 0 ); return( 0 );
} }
free( desired );
free( obtained );
/* Otherwise, there are good chances we can use this plugin, return 100. */ /* Otherwise, there are good chances we can use this plugin, return 100. */
SDL_CloseAudio(); SDL_CloseAudio();
return( 100 ); return( 50 );
} }
/***************************************************************************** /*****************************************************************************
...@@ -144,7 +151,7 @@ static int aout_Probe( probedata_t *p_data ) ...@@ -144,7 +151,7 @@ static int aout_Probe( probedata_t *p_data )
static int aout_Open( aout_thread_t *p_aout ) static int aout_Open( aout_thread_t *p_aout )
{ {
SDL_AudioSpec *desired; SDL_AudioSpec *desired;
int i_stereo = p_aout->b_stereo?2:1; int i_channels = p_aout->b_stereo?2:1;
/* asks for a minimum audio spec so that we are sure the dsp exists */ /* asks for a minimum audio spec so that we are sure the dsp exists */
desired = (SDL_AudioSpec *)malloc( sizeof(SDL_AudioSpec) ); desired = (SDL_AudioSpec *)malloc( sizeof(SDL_AudioSpec) );
...@@ -176,7 +183,7 @@ static int aout_Open( aout_thread_t *p_aout ) ...@@ -176,7 +183,7 @@ static int aout_Open( aout_thread_t *p_aout )
/* TODO: write conversion beetween AOUT_FORMAT_DEFAULT /* TODO: write conversion beetween AOUT_FORMAT_DEFAULT
* AND AUDIO* from SDL. */ * AND AUDIO* from SDL. */
desired->format = AUDIO_S16LSB; /* stereo 16 bits */ desired->format = AUDIO_S16LSB; /* stereo 16 bits */
desired->channels = i_stereo; desired->channels = i_channels;
desired->callback = SDL_aout_callback; desired->callback = SDL_aout_callback;
desired->userdata = p_aout->p_sys; desired->userdata = p_aout->p_sys;
desired->samples = 2048; desired->samples = 2048;
...@@ -188,10 +195,13 @@ static int aout_Open( aout_thread_t *p_aout ) ...@@ -188,10 +195,13 @@ static int aout_Open( aout_thread_t *p_aout )
*/ */
if( SDL_OpenAudio(desired,NULL) < 0 ) if( SDL_OpenAudio(desired,NULL) < 0 )
{ {
intf_ErrMsgImm( "aout_Open error: can't open audio device: %s", free( desired );
intf_ErrMsg( "aout_Open error: can't open audio device: %s",
SDL_GetError() ); SDL_GetError() );
return( -1 ); return( -1 );
} }
p_aout->p_sys->b_active = 1;
free( desired );
SDL_PauseAudio(0); SDL_PauseAudio(0);
return( 0 ); return( 0 );
...@@ -225,7 +235,13 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -225,7 +235,13 @@ static int aout_SetFormat( aout_thread_t *p_aout )
SDL_PauseAudio(1); SDL_PauseAudio(1);
SDL_CloseAudio(); SDL_CloseAudio();
if( SDL_OpenAudio(desired,NULL) < 0 ) if( SDL_OpenAudio(desired,NULL) < 0 )
{
free( desired );
p_aout->p_sys->b_active = 0;
return( -1 ); return( -1 );
}
p_aout->p_sys->b_active = 1;
free( desired );
SDL_PauseAudio(0); SDL_PauseAudio(0);
return(0); return(0);
} }
...@@ -249,7 +265,7 @@ static void SDL_aout_callback(void *userdata, byte_t *stream, int len) ...@@ -249,7 +265,7 @@ static void SDL_aout_callback(void *userdata, byte_t *stream, int len)
if(end > OVERFLOWLIMIT) if(end > OVERFLOWLIMIT)
{ {
intf_ErrMsgImm("aout SDL_aout_callback: Overflow."); intf_ErrMsg("aout SDL_aout_callback: Overflow.");
free(p_sys->audio_buf); free(p_sys->audio_buf);
p_sys->audio_buf = NULL; p_sys->audio_buf = NULL;
p_sys->i_audio_end = 0; p_sys->i_audio_end = 0;
...@@ -292,12 +308,15 @@ static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size ) ...@@ -292,12 +308,15 @@ static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
*****************************************************************************/ *****************************************************************************/
static void aout_Close( aout_thread_t *p_aout ) static void aout_Close( aout_thread_t *p_aout )
{ {
SDL_LockAudio(); /* Stop callbacking */ if( p_aout->p_sys->b_active )
SDL_PauseAudio(1); /* pause audio */
if(p_aout->p_sys->audio_buf != NULL) /* do we have a buffer now ? */
{ {
free(p_aout->p_sys->audio_buf); SDL_PauseAudio(1); /* pause audio */
if(p_aout->p_sys->audio_buf != NULL) /* do we have a buffer now ? */
{
free(p_aout->p_sys->audio_buf);
}
p_aout->p_sys->b_active = 0; /* just for sam */
} }
free(p_aout->p_sys); /* Close the Output. */ free(p_aout->p_sys); /* Close the Output. */
SDL_CloseAudio(); SDL_CloseAudio();
......
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