X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Frealaudio.c;h=1eb45e08877f27cf83b485cef1ec756d8747147d;hb=4e9597b800d1140dfab1cf33c3df8c608d58878f;hp=9d329bff66d2066445f757723ef316e668780c50;hpb=45ff435b9ab009961399c235039d190b4f62fba7;p=vlc diff --git a/modules/codec/realaudio.c b/modules/codec/realaudio.c index 9d329bff66..1eb45e0887 100644 --- a/modules/codec/realaudio.c +++ b/modules/codec/realaudio.c @@ -22,10 +22,14 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include #ifdef LOADER /* Need the w32dll loader from mplayer */ @@ -58,7 +62,7 @@ static int Open ( vlc_object_t * ); static void Close( vlc_object_t * ); vlc_module_begin(); - set_description( _("RealAudio library decoder") ); + set_description( N_("RealAudio library decoder") ); set_capability( "decoder", 10 ); set_category( CAT_INPUT ); set_subcategory( SUBCAT_INPUT_VCODEC ); @@ -85,7 +89,7 @@ struct decoder_sys_t /* Codec params */ void *context; - int i_codec_flavor; + short int i_codec_flavor; void *dll; unsigned long (*raCloseCodec)(void*); @@ -107,20 +111,20 @@ struct decoder_sys_t #endif void *win32_dll; - unsigned long (*wraCloseCodec)(void*); - unsigned long (*wraDecode)(void*, char*, unsigned long, char*, - unsigned int*, long); - unsigned long (*wraFlush)(unsigned long, unsigned long, - unsigned long); - unsigned long (*wraFreeDecoder)(void*); - void* (*wraGetFlavorProperty)(void*, unsigned long, - unsigned long, int*); - unsigned long (*wraInitDecoder)(void*, void*); - unsigned long (*wraOpenCodec)(void*); - unsigned long (*wraOpenCodec2)(void*, void*); - unsigned long (*wraSetFlavor)(void*, unsigned long); - void (*wraSetDLLAccessPath)(char*); - void (*wraSetPwd)(char*, char*); + unsigned long (WINAPI *wraCloseCodec)(void*); + unsigned long (WINAPI *wraDecode)(void*, char*, unsigned long, char*, + unsigned int*, long); + unsigned long (WINAPI *wraFlush)(unsigned long, unsigned long, + unsigned long); + unsigned long (WINAPI *wraFreeDecoder)(void*); + void* (WINAPI *wraGetFlavorProperty)(void*, unsigned long, + unsigned long, int*); + unsigned long (WINAPI *wraInitDecoder)(void*, void*); + unsigned long (WINAPI *wraOpenCodec)(void*); + unsigned long (WINAPI *wraOpenCodec2)(void*, void*); + unsigned long (WINAPI *wraSetFlavor)(void*, unsigned long); + void (WINAPI *wraSetDLLAccessPath)(char*); + void (WINAPI *wraSetPwd)(char*, char*); }; /* linux dlls doesn't need packing */ @@ -179,26 +183,34 @@ static int Open( vlc_object_t *p_this ) switch( p_dec->fmt_in.i_codec ) { case VLC_FOURCC('c','o','o','k'): + case VLC_FOURCC('a','t','r','c'): + case VLC_FOURCC('s','i','p','r'): break; default: return VLC_EGENERIC; } + /* Channel detection */ + if( p_dec->fmt_in.audio.i_channels <= 0 || + p_dec->fmt_in.audio.i_channels > 6 ) + { + msg_Err( p_dec, "invalid number of channels (not between 1 and 6): %i", + p_dec->fmt_in.audio.i_channels ); + return VLC_EGENERIC; + } + 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 */ p_sys->i_codec_flavor = -1; if( p_dec->fmt_in.i_codec == VLC_FOURCC('s','i','p','r') ) { - if( p_dec->fmt_in.audio.i_bitspersample > 1531 ) - p_sys->i_codec_flavor = 3; - else if( p_dec->fmt_in.audio.i_bitspersample > 937 ) - p_sys->i_codec_flavor = 1; - else if( p_dec->fmt_in.audio.i_bitspersample > 719 ) - p_sys->i_codec_flavor = 0; - else - p_sys->i_codec_flavor = 2; + p_sys->i_codec_flavor = p_dec->fmt_in.audio.i_flavor; + msg_Dbg( p_dec, "Got sipr flavor %d", p_sys->i_codec_flavor ); } if( OpenDll( p_dec ) != VLC_SUCCESS ) @@ -226,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; @@ -239,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 ); } @@ -251,6 +268,7 @@ static int OpenDll( decoder_t *p_dec ) char *psz_dll; int i, i_result; + /** Find the good path for the dlls.**/ char *ppsz_path[] = { ".", @@ -260,9 +278,16 @@ static int OpenDll( decoder_t *p_dec ) "/usr/lib/RealPlayer8/Codecs", "/opt/RealPlayer8/Codecs", "/usr/lib/RealPlayer9/users/Real/Codecs", + "/usr/lib/RealPlayer10/codecs", + "/usr/lib/RealPlayer10GOLD/codecs", + "/usr/lib/helix/player/codecs", "/usr/lib64/RealPlayer8/Codecs", "/usr/lib64/RealPlayer9/users/Real/Codecs", + "/usr/lib64/RealPlayer10/codecs", + "/usr/lib64/RealPlayer10GOLD/codecs", "/usr/lib/win32", + "/usr/lib/codecs", + "/usr/local/lib/codecs", #endif NULL, NULL, @@ -272,18 +297,7 @@ static int OpenDll( decoder_t *p_dec ) #ifdef WIN32 char psz_win32_real_codecs[MAX_PATH + 1]; char psz_win32_helix_codecs[MAX_PATH + 1]; -#endif - for( i = 0; ppsz_path[i]; i++ ) - { - 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; - } - -#ifdef WIN32 { HKEY h_key; DWORD i_type, i_data = MAX_PATH + 1, i_index = 1; @@ -325,6 +339,30 @@ static int OpenDll( decoder_t *p_dec ) } #endif + + /** Try the native libraries first **/ +#ifndef WIN32 + 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; + + /* 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; + + } +#endif + + /** Or use the WIN32 dlls **/ +#if defined(LOADER) || defined(WIN32) for( i = 0; ppsz_path[i]; i++ ) { /* New format */ @@ -341,6 +379,7 @@ static int OpenDll( decoder_t *p_dec ) free( psz_dll ); if( i_result == VLC_SUCCESS ) return VLC_SUCCESS; } +#endif return VLC_EGENERIC; } @@ -618,7 +657,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; } }