X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Frealaudio.c;h=1945f2aa76c0567f30761159dc066b8bd1113a86;hb=56391b1fb93e8e5d38f8a08537252ab37e3dcd65;hp=a00bc0f4a2b25044d76867ac0093fb5e7f781e12;hpb=99fab9089e9e1709d9c3a4bc5ced0c137ac59134;p=vlc diff --git a/modules/codec/realaudio.c b/modules/codec/realaudio.c index a00bc0f4a2..1945f2aa76 100644 --- a/modules/codec/realaudio.c +++ b/modules/codec/realaudio.c @@ -26,7 +26,8 @@ # include "config.h" #endif -#include +#include +#include #include #include @@ -60,13 +61,13 @@ int WINAPI FreeLibrary( void *handle ); static int Open ( vlc_object_t * ); static void Close( vlc_object_t * ); -vlc_module_begin(); - set_description( _("RealAudio library decoder") ); - set_capability( "decoder", 10 ); - set_category( CAT_INPUT ); - set_subcategory( SUBCAT_INPUT_VCODEC ); - set_callbacks( Open, Close ); -vlc_module_end(); +vlc_module_begin () + set_description( N_("RealAudio library decoder") ) + set_capability( "decoder", 10 ) + set_category( CAT_INPUT ) + set_subcategory( SUBCAT_INPUT_VCODEC ) + set_callbacks( Open, Close ) +vlc_module_end () /***************************************************************************** * Local prototypes @@ -154,7 +155,7 @@ typedef struct __attribute__((__packed__)) { void *__builtin_new(unsigned long size) {return malloc(size);} void __builtin_delete(void *p) {free(p);} -static int pi_channels_maps[7] = +static const int pi_channels_maps[7] = { 0, AOUT_CHAN_CENTER, @@ -200,6 +201,8 @@ static int Open( vlc_object_t *p_this ) } p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) ); + if( !p_sys ) + return VLC_ENOMEM; memset( p_sys, 0, sizeof(decoder_sys_t) ); /* Flavor for SIPR codecs */ @@ -235,6 +238,11 @@ static int Open( vlc_object_t *p_this ) p_dec->pf_decode_audio = Decode; p_sys->p_out = malloc( 4096 * 10 ); + if( !p_sys->p_out ) + { + free( p_sys ); + return VLC_ENOMEM; + } p_sys->i_out = 0; return VLC_SUCCESS; @@ -248,7 +256,7 @@ static void Close( vlc_object_t *p_this ) decoder_t *p_dec = (decoder_t*)p_this; CloseDll( p_dec ); - if( p_dec->p_sys->p_out ) free( p_dec->p_sys->p_out ); + free( p_dec->p_sys->p_out ); free( p_dec->p_sys ); } @@ -337,19 +345,22 @@ static int OpenDll( decoder_t *p_dec ) for( i = 0; ppsz_path[i]; i++ ) { /* Old format */ - asprintf( &psz_dll, "%s/%4.4s.so.6.0", ppsz_path[i], - (char *)&p_dec->fmt_in.i_codec ); - i_result = OpenNativeDll( p_dec, ppsz_path[i], psz_dll ); - free( psz_dll ); - if( i_result == VLC_SUCCESS ) return VLC_SUCCESS; + if( asprintf( &psz_dll, "%s/%4.4s.so.6.0", ppsz_path[i], + (char *)&p_dec->fmt_in.i_codec ) != -1 ) + { + i_result = OpenNativeDll( p_dec, ppsz_path[i], psz_dll ); + free( psz_dll ); + if( i_result == VLC_SUCCESS ) return VLC_SUCCESS; + } /* New format */ - asprintf( &psz_dll, "%s/%4.4s.so", ppsz_path[i], - (char *)&p_dec->fmt_in.i_codec ); - i_result = OpenNativeDll( p_dec, ppsz_path[i], psz_dll ); - free( psz_dll ); - if( i_result == VLC_SUCCESS ) return VLC_SUCCESS; - + if( asprintf( &psz_dll, "%s/%4.4s.so", ppsz_path[i], + (char *)&p_dec->fmt_in.i_codec ) != -1 ) + { + i_result = OpenNativeDll( p_dec, ppsz_path[i], psz_dll ); + free( psz_dll ); + if( i_result == VLC_SUCCESS ) return VLC_SUCCESS; + } } #endif @@ -358,18 +369,22 @@ static int OpenDll( decoder_t *p_dec ) for( i = 0; ppsz_path[i]; i++ ) { /* New format */ - asprintf( &psz_dll, "%s\\%4.4s.dll", ppsz_path[i], - (char *)&p_dec->fmt_in.i_codec ); - i_result = OpenWin32Dll( p_dec, ppsz_path[i], psz_dll ); - free( psz_dll ); - if( i_result == VLC_SUCCESS ) return VLC_SUCCESS; + if( asprintf( &psz_dll, "%s\\%4.4s.dll", ppsz_path[i], + (char *)&p_dec->fmt_in.i_codec ) != -1 ) + { + i_result = OpenWin32Dll( p_dec, ppsz_path[i], psz_dll ); + free( psz_dll ); + if( i_result == VLC_SUCCESS ) return VLC_SUCCESS; + } /* Old format */ - asprintf( &psz_dll, "%s\\%4.4s3260.dll", ppsz_path[i], - (char *)&p_dec->fmt_in.i_codec ); - i_result = OpenWin32Dll( p_dec, ppsz_path[i], psz_dll ); - free( psz_dll ); - if( i_result == VLC_SUCCESS ) return VLC_SUCCESS; + if( asprintf( &psz_dll, "%s\\%4.4s3260.dll", ppsz_path[i], + (char *)&p_dec->fmt_in.i_codec ) != -1 ) + { + i_result = OpenWin32Dll( p_dec, ppsz_path[i], psz_dll ); + free( psz_dll ); + if( i_result == VLC_SUCCESS ) return VLC_SUCCESS; + } } #endif @@ -649,7 +664,7 @@ static aout_buffer_t *Decode( decoder_t *p_dec, block_t **pp_block ) if( OpenDll( p_dec ) != VLC_SUCCESS ) { /* Fatal */ - p_dec->b_error = VLC_TRUE; + p_dec->b_error = true; return NULL; } } @@ -691,7 +706,7 @@ static aout_buffer_t *Decode( decoder_t *p_dec, block_t **pp_block ) p_dec->fmt_out.audio.i_bitspersample /p_dec->fmt_out.audio.i_channels; p_aout_buffer = - p_dec->pf_aout_buffer_new( p_dec, i_samples ); + decoder_NewAudioBuffer( p_dec, i_samples ); if( p_aout_buffer ) { memcpy( p_aout_buffer->p_buffer, p_sys->p_out, p_sys->i_out );