/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_aout.h>
#include <vlc_codec.h>
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
/* Codec params */
void *context;
- int i_codec_flavor;
+ short int i_codec_flavor;
void *dll;
unsigned long (*raCloseCodec)(void*);
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,
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 )
{
}
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 )
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;
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 );
}
char *psz_dll;
int i, i_result;
+ /** Find the good path for the dlls.**/
char *ppsz_path[] =
{
".",
"/usr/lib64/RealPlayer10GOLD/codecs",
"/usr/lib/win32",
"/usr/lib/codecs",
- "/usr/local/lib/codecs"
+ "/usr/local/lib/codecs",
#endif
NULL,
NULL,
#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;
}
#endif
+
+ /** Try the native libraries first **/
+#ifndef WIN32
for( i = 0; ppsz_path[i]; i++ )
{
+ /* Old format */
+ 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.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.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
+
+ /** Or use the WIN32 dlls **/
+#if defined(LOADER) || defined(WIN32)
+ for( i = 0; ppsz_path[i]; i++ )
+ {
+ /* New format */
+ 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
return VLC_EGENERIC;
}
if( OpenDll( p_dec ) != VLC_SUCCESS )
{
/* Fatal */
- p_dec->b_error = VLC_TRUE;
+ p_dec->b_error = true;
return NULL;
}
}
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 );