1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-25 04:38:01 +00:00

- removed unused global 'handle'

- added __builtin_delete() for cook (rp9 version at least)
- use OpenCodec2 when avaialble, 2nd param is codecpath (traced from rp8)
- fallback to i_bps=12000 when raGetFlavorProperty(1) fails (some rp9 cook flavors)
- disabled dlclose, caused memcorruption (FIXME)
inspired by bugreports/patches by Balatoni Denes <pnis@coder.hu>


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9552 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi 2003-03-09 17:17:39 +00:00
parent d3f99faefb
commit e68b46b244

View File

@ -23,12 +23,15 @@ static ad_info_t info = {
LIBAD_EXTERN(realaud) LIBAD_EXTERN(realaud)
static void *handle=NULL;
void *__builtin_new(unsigned long size) { void *__builtin_new(unsigned long size) {
return malloc(size); return malloc(size);
} }
// required for cook's uninit:
void __builtin_delete(void* ize) {
free(ize);
}
#if defined(__FreeBSD__) || defined(__NetBSD__) #if defined(__FreeBSD__) || defined(__NetBSD__)
void *__ctype_b=NULL; void *__ctype_b=NULL;
#endif #endif
@ -127,14 +130,14 @@ static int load_syms_linux(char *path)
raFreeDecoder = dlsym(handle, "RAFreeDecoder"); raFreeDecoder = dlsym(handle, "RAFreeDecoder");
raGetFlavorProperty = dlsym(handle, "RAGetFlavorProperty"); raGetFlavorProperty = dlsym(handle, "RAGetFlavorProperty");
raOpenCodec = dlsym(handle, "RAOpenCodec"); raOpenCodec = dlsym(handle, "RAOpenCodec");
// raOpenCodec2 = dlsym(handle, "RAOpenCodec2"); raOpenCodec2 = dlsym(handle, "RAOpenCodec2");
raInitDecoder = dlsym(handle, "RAInitDecoder"); raInitDecoder = dlsym(handle, "RAInitDecoder");
raSetFlavor = dlsym(handle, "RASetFlavor"); raSetFlavor = dlsym(handle, "RASetFlavor");
raSetDLLAccessPath = dlsym(handle, "SetDLLAccessPath"); raSetDLLAccessPath = dlsym(handle, "SetDLLAccessPath");
raSetPwd = dlsym(handle, "RASetPwd"); // optional, used by SIPR raSetPwd = dlsym(handle, "RASetPwd"); // optional, used by SIPR
if (raCloseCodec && raDecode && raFlush && raFreeDecoder && if (raCloseCodec && raDecode && raFlush && raFreeDecoder &&
raGetFlavorProperty && raOpenCodec/*2*/ && raSetFlavor && raGetFlavorProperty && (raOpenCodec||raOpenCodec2) && raSetFlavor &&
/*raSetDLLAccessPath &&*/ raInitDecoder) /*raSetDLLAccessPath &&*/ raInitDecoder)
{ {
rv_handle = handle; rv_handle = handle;
@ -172,14 +175,14 @@ static int load_sysm_windows(char *path)
wraFreeDecoder = GetProcAddress(handle, "RAFreeDecoder"); wraFreeDecoder = GetProcAddress(handle, "RAFreeDecoder");
wraGetFlavorProperty = GetProcAddress(handle, "RAGetFlavorProperty"); wraGetFlavorProperty = GetProcAddress(handle, "RAGetFlavorProperty");
wraOpenCodec = GetProcAddress(handle, "RAOpenCodec"); wraOpenCodec = GetProcAddress(handle, "RAOpenCodec");
// wraOpenCodec2 = GetProcAddress(handle, "RAOpenCodec2"); wraOpenCodec2 = GetProcAddress(handle, "RAOpenCodec2");
wraInitDecoder = GetProcAddress(handle, "RAInitDecoder"); wraInitDecoder = GetProcAddress(handle, "RAInitDecoder");
wraSetFlavor = GetProcAddress(handle, "RASetFlavor"); wraSetFlavor = GetProcAddress(handle, "RASetFlavor");
wraSetDLLAccessPath = GetProcAddress(handle, "SetDLLAccessPath"); wraSetDLLAccessPath = GetProcAddress(handle, "SetDLLAccessPath");
wraSetPwd = GetProcAddress(handle, "RASetPwd"); // optional, used by SIPR wraSetPwd = GetProcAddress(handle, "RASetPwd"); // optional, used by SIPR
if (wraCloseCodec && wraDecode && wraFlush && wraFreeDecoder && if (wraCloseCodec && wraDecode && wraFlush && wraFreeDecoder &&
wraGetFlavorProperty && wraOpenCodec/*2*/ && wraSetFlavor && wraGetFlavorProperty && (wraOpenCodec || wraOpenCodec2) && wraSetFlavor &&
/*wraSetDLLAccessPath &&*/ wraInitDecoder) /*wraSetDLLAccessPath &&*/ wraInitDecoder)
{ {
rv_handle = handle; rv_handle = handle;
@ -237,13 +240,17 @@ static int preinit(sh_audio_t *sh){
} }
#ifdef USE_WIN32DLL #ifdef USE_WIN32DLL
if (dll_type == 1) if (dll_type == 1){
// result=wraOpenCodec2(&sh->context,NULL); if(wraOpenCodec2)
result=wraOpenCodec2(&sh->context,REALCODEC_PATH "\\");
else
result=wraOpenCodec(&sh->context); result=wraOpenCodec(&sh->context);
else } else
#endif #endif
// result=raOpenCodec2(&sh->context,NULL); if(raOpenCodec2)
result=raOpenCodec(&sh->context); result=raOpenCodec2(&sh->context,REALCODEC_PATH "/");
else
result=raOpenCodec(&sh->context);
if(result){ if(result){
mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder open failed, error code: 0x%X\n",result); mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder open failed, error code: 0x%X\n",result);
return 0; return 0;
@ -327,8 +334,11 @@ static int preinit(sh_audio_t *sh){
else else
#endif #endif
prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],1,&len); prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],1,&len);
sh->i_bps=((*((int*)prop))+4)/8; if(prop){
mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Audio bitrate: %5.3f kbit/s (%d bps) \n",(*((int*)prop))*0.001f,sh->i_bps); sh->i_bps=((*((int*)prop))+4)/8;
mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Audio bitrate: %5.3f kbit/s (%d bps) \n",(*((int*)prop))*0.001f,sh->i_bps);
} else
sh->i_bps=12000; // dunno :((( [12000 seems to be OK for crash.rmvb too]
// prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],0x13,&len); // prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],0x13,&len);
// mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Samples/block?: %d \n",(*((int*)prop))); // mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Samples/block?: %d \n",(*((int*)prop)));
@ -358,8 +368,9 @@ static void uninit(sh_audio_t *sh){
{ {
if (wraFreeDecoder) wraFreeDecoder(sh->context); if (wraFreeDecoder) wraFreeDecoder(sh->context);
if (wraCloseCodec) wraCloseCodec(sh->context); if (wraCloseCodec) wraCloseCodec(sh->context);
} else }
#endif #endif
if (raFreeDecoder) raFreeDecoder(sh->context); if (raFreeDecoder) raFreeDecoder(sh->context);
if (raCloseCodec) raCloseCodec(sh->context); if (raCloseCodec) raCloseCodec(sh->context);
@ -369,7 +380,8 @@ static void uninit(sh_audio_t *sh){
if (rv_handle) FreeLibrary(rv_handle); if (rv_handle) FreeLibrary(rv_handle);
} else } else
#endif #endif
if (rv_handle) dlclose(rv_handle); // this dlclose() causes some memory corruption, and crashes soon (in caller):
// if (rv_handle) dlclose(rv_handle);
rv_handle = NULL; rv_handle = NULL;
} }