[Mplayer-cvslog] CVS: main/libmpcodecs ad_realaud.c,1.20,1.21

Arpi of Ize arpi at mplayerhq.hu
Sun Mar 9 18:18:05 CET 2003


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv15044

Modified Files:
	ad_realaud.c 
Log Message:
- 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 at coder.hu>


Index: ad_realaud.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_realaud.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ad_realaud.c	11 Feb 2003 15:24:26 -0000	1.20
+++ ad_realaud.c	9 Mar 2003 17:17:39 -0000	1.21
@@ -23,12 +23,15 @@
 
 LIBAD_EXTERN(realaud)
 
-static void *handle=NULL;
-
 void *__builtin_new(unsigned long size) {
 	return malloc(size);
 }
 
+// required for cook's uninit:
+void __builtin_delete(void* ize) {
+	free(ize);
+}
+
 #if defined(__FreeBSD__) || defined(__NetBSD__)
 void *__ctype_b=NULL;
 #endif
@@ -127,14 +130,14 @@
     raFreeDecoder = dlsym(handle, "RAFreeDecoder");
     raGetFlavorProperty = dlsym(handle, "RAGetFlavorProperty");
     raOpenCodec = dlsym(handle, "RAOpenCodec");
-//    raOpenCodec2 = dlsym(handle, "RAOpenCodec2");
+    raOpenCodec2 = dlsym(handle, "RAOpenCodec2");
     raInitDecoder = dlsym(handle, "RAInitDecoder");
     raSetFlavor = dlsym(handle, "RASetFlavor");
     raSetDLLAccessPath = dlsym(handle, "SetDLLAccessPath");
     raSetPwd = dlsym(handle, "RASetPwd"); // optional, used by SIPR
     
     if (raCloseCodec && raDecode && raFlush && raFreeDecoder &&
-	raGetFlavorProperty && raOpenCodec/*2*/ && raSetFlavor &&
+	raGetFlavorProperty && (raOpenCodec||raOpenCodec2) && raSetFlavor &&
 	/*raSetDLLAccessPath &&*/ raInitDecoder)
     {
 	rv_handle = handle;
@@ -172,14 +175,14 @@
     wraFreeDecoder = GetProcAddress(handle, "RAFreeDecoder");
     wraGetFlavorProperty = GetProcAddress(handle, "RAGetFlavorProperty");
     wraOpenCodec = GetProcAddress(handle, "RAOpenCodec");
-//    wraOpenCodec2 = GetProcAddress(handle, "RAOpenCodec2");
+    wraOpenCodec2 = GetProcAddress(handle, "RAOpenCodec2");
     wraInitDecoder = GetProcAddress(handle, "RAInitDecoder");
     wraSetFlavor = GetProcAddress(handle, "RASetFlavor");
     wraSetDLLAccessPath = GetProcAddress(handle, "SetDLLAccessPath");
     wraSetPwd = GetProcAddress(handle, "RASetPwd"); // optional, used by SIPR
     
     if (wraCloseCodec && wraDecode && wraFlush && wraFreeDecoder &&
-	wraGetFlavorProperty && wraOpenCodec/*2*/ && wraSetFlavor &&
+	wraGetFlavorProperty && (wraOpenCodec || wraOpenCodec2) && wraSetFlavor &&
 	/*wraSetDLLAccessPath &&*/ wraInitDecoder)
     {
 	rv_handle = handle;
@@ -237,13 +240,17 @@
   }
 
 #ifdef USE_WIN32DLL
-    if (dll_type == 1)
-//	result=wraOpenCodec2(&sh->context,NULL);
+    if (dll_type == 1){
+      if(wraOpenCodec2)
+	result=wraOpenCodec2(&sh->context,REALCODEC_PATH "\\");
+      else
 	result=wraOpenCodec(&sh->context);
-    else
+    } else
 #endif
-//    result=raOpenCodec2(&sh->context,NULL);
-    result=raOpenCodec(&sh->context);
+    if(raOpenCodec2)
+      result=raOpenCodec2(&sh->context,REALCODEC_PATH "/");
+    else
+      result=raOpenCodec(&sh->context);
     if(result){
       mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder open failed, error code: 0x%X\n",result);
       return 0;
@@ -327,9 +334,12 @@
     else
 #endif
     prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],1,&len);
-    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);
-
+    if(prop){
+      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);
 //    mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Samples/block?: %d  \n",(*((int*)prop)));
 
@@ -358,8 +368,9 @@
     {
 	if (wraFreeDecoder) wraFreeDecoder(sh->context);
 	if (wraCloseCodec) wraCloseCodec(sh->context);
-    } else
+    }
 #endif
+
     if (raFreeDecoder) raFreeDecoder(sh->context);
     if (raCloseCodec) raCloseCodec(sh->context);
 
@@ -369,7 +380,8 @@
 	if (rv_handle) FreeLibrary(rv_handle);
     } else
 #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;
 }
 



More information about the MPlayer-cvslog mailing list