[MPlayer-dev-eng] packaging cygwin mplayer
Joey Parrish
joey at nicewarrior.org
Mon Feb 10 17:20:26 CET 2003
On Mon, Feb 10, 2003 at 04:52:12PM +0100, Diego Biurrun wrote:
> > > send the patch, i or alex will check it
> > It's only needed when packaging MPlayer outside of a complete cygwin
> > system. I'll try to make as much CVS-worthy patch as I can, but this is
> > mostly hacks that have no place in CVS.
>
> Umm, perhaps you don't realize this, but nobody has working real DLLs under
> Cygwin except you ... So what do you mean by "only needed when packaging
> MPlayer outside of a complete Cygwin environment"?
Really? I had no idea. Well, the audio is still broken, but here are
the patches I'm using. The *_clean.patch are the clean parts that I
think you might find useful under normal cygwin environments, and the
*_hack_cumulative.patch are the parts that I apply for packaging on top
of the clean patches.
These are based on my old (hacked) patches. I just finished remaking
them, but I haven't tested these yet. They should be the same, but
since it takes over half an hour to recompile on this cygwin box I'm
going on faith. :) If they blow up my computer in the next hour, I'll
post again and say "oops."
Also, I need to verify that these patches don't break anything under
linux. That might have to wait, because I have to go to school soon.
It might be later tonight (American night) before I get a chance to put
in more serious work.
I'll post bug reports on the audio crashing in a new thread.
--Joey
-------------- next part --------------
--- 0_90.cvs/libmpcodecs/ad_realaud.c 2003-02-10 09:09:18.000000000 -0600
+++ 0_90.dev/libmpocdecs/ad_realaud.c 2003-02-10 09:56:46.000000000 -0600
@@ -22,6 +22,10 @@
LIBAD_EXTERN(realaud)
+#ifdef __CYGWIN__
+#define USE_WIN32DLL
+#endif
+
static void *handle=NULL;
void *__builtin_new(unsigned long size) {
@@ -31,6 +35,9 @@
#if defined(__FreeBSD__) || defined(__NetBSD__)
void *__ctype_b=NULL;
#endif
+#ifdef USE_WIN32DLL
+static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */
+#endif
static unsigned long (*raCloseCodec)(void*);
static unsigned long (*raDecode)(void*, char*,unsigned long,char*,unsigned int*,long);
@@ -43,6 +50,107 @@
static unsigned long (*raSetFlavor)(void*,unsigned long);
static void (*raSetDLLAccessPath)(char*);
static void (*raSetPwd)(char*,char*);
+#ifdef USE_WIN32DLL
+static unsigned long WINAPI (*wraCloseCodec)(void*);
+static unsigned long WINAPI (*wraDecode)(void*, char*,unsigned long,char*,unsigned int*,long);
+static unsigned long WINAPI (*wraFlush)(unsigned long,unsigned long,unsigned long);
+static unsigned long WINAPI (*wraFreeDecoder)(void*);
+static void* WINAPI (*wraGetFlavorProperty)(void*,unsigned long,unsigned long,int*);
+//static unsigned long (*raGetNumberOfFlavors2)(void);
+static unsigned long WINAPI (*wraInitDecoder)(void*, void*);
+static unsigned long WINAPI (*wraOpenCodec2)(void*);
+static unsigned long WINAPI (*wraSetFlavor)(void*,unsigned long);
+static void WINAPI (*wraSetDLLAccessPath)(char*);
+static void WINAPI (*wraSetPwd)(char*,char*);
+#endif
+
+static int load_syms_linux(char *path) {
+
+ mp_msg(MSGT_DECAUDIO,MSGL_INFO, "opening shared obj '%s'\n", path);
+ handle = dlopen (path, RTLD_LAZY);
+ if (!handle) {
+ mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Error: %s\n",dlerror());
+ return 0;
+ }
+
+ raCloseCodec = dlsym(handle, "RACloseCodec");
+ raDecode = dlsym(handle, "RADecode");
+ raFlush = dlsym(handle, "RAFlush");
+ raFreeDecoder = dlsym(handle, "RAFreeDecoder");
+ raGetFlavorProperty = dlsym(handle, "RAGetFlavorProperty");
+ 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 && raOpenCodec2 && raSetFlavor &&
+ /*raSetDLLAccessPath &&*/ raInitDecoder){
+ return 1;
+ }
+
+ mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n");
+ dlclose(handle);
+ handle = NULL;
+ return 0;
+}
+
+#ifdef USE_WIN32DLL
+
+#ifndef __CYGWIN__
+#include "../loader/ldt_keeper.h"
+#endif
+void* WINAPI LoadLibraryA(char* name);
+void* WINAPI GetProcAddress(void* handle,char* func);
+int WINAPI FreeLibrary(void *handle);
+#ifdef __CYGWIN__
+int WINAPI SetEnvironmentVariableA(char *name, char *value);
+DWORD WINAPI GetLastError(void);
+#endif
+
+static int load_syms_windows(char *path) {
+
+ mp_msg(MSGT_DECAUDIO,MSGL_INFO, "opening win32 dll '%s'\n", path);
+#ifndef __CYGWIN__
+ Setup_LDT_Keeper();
+#endif
+ handle = LoadLibraryA(path);
+ mp_msg(MSGT_DECAUDIO,MSGL_V,"win32 real codec handle=%p \n",handle);
+ if (!handle) {
+#ifdef __CYGWIN__
+ mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Error loading dll (%d)\n",GetLastError());
+#else
+ mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Error loading dll\n");
+#endif
+ return 0;
+ }
+
+ raCloseCodec = GetProcAddress(handle, "RACloseCodec");
+ raDecode = GetProcAddress(handle, "RADecode");
+ raFlush = GetProcAddress(handle, "RAFlush");
+ raFreeDecoder = GetProcAddress(handle, "RAFreeDecoder");
+ raGetFlavorProperty = GetProcAddress(handle, "RAGetFlavorProperty");
+ raOpenCodec2 = GetProcAddress(handle, "RAOpenCodec2");
+ raInitDecoder = GetProcAddress(handle, "RAInitDecoder");
+ raSetFlavor = GetProcAddress(handle, "RASetFlavor");
+ raSetDLLAccessPath = GetProcAddress(handle, "SetDLLAccessPath");
+ raSetPwd = GetProcAddress(handle, "RASetPwd"); // optional, used by SIPR
+
+ if(raCloseCodec && raDecode && raFlush && raFreeDecoder &&
+ raGetFlavorProperty && raOpenCodec2 && raSetFlavor &&
+ /*raSetDLLAccessPath &&*/ raInitDecoder){
+ dll_type = 1;
+
+ return 1;
+ }
+
+ mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n");
+ FreeLibrary(handle);
+ handle = NULL;
+ return 0; // error
+}
+#endif
typedef struct {
int samplerate;
@@ -62,32 +170,37 @@
int len=0;
void* prop;
char path[4096];
+ char *temp;
+
sprintf(path, REALCODEC_PATH "/%s", sh->codec->dll);
- handle = dlopen (path, RTLD_LAZY);
- if(!handle){
- mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Cannot open dll: %s\n",dlerror());
- return 0;
- }
- raCloseCodec = dlsym(handle, "RACloseCodec");
- raDecode = dlsym(handle, "RADecode");
- raFlush = dlsym(handle, "RAFlush");
- raFreeDecoder = dlsym(handle, "RAFreeDecoder");
- raGetFlavorProperty = dlsym(handle, "RAGetFlavorProperty");
- 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 || !raOpenCodec2 || !raSetFlavor ||
- /*!raSetDLLAccessPath ||*/ !raInitDecoder){
- mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Cannot resolve symbols - incompatible dll: %s\n",path);
+ if(!load_syms_linux(path))
+#ifdef USE_WIN32DLL
+ if (!load_syms_windows(path))
+#endif
+ {
+ mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll);
+ mp_msg(MSGT_DECAUDIO,MSGL_HINT,"You need to copy the contents from the RealPlayer codecs directory\n");
+ mp_msg(MSGT_DECAUDIO,MSGL_HINT,"into " REALCODEC_PATH "!\n");
return 0;
}
- if(raSetDLLAccessPath){
+
+#ifdef USE_WIN32DLL
+ if (dll_type == 1) {
+ if(wraSetDLLAccessPath){
+ sprintf(path, "DT_Codecs=" REALCODEC_PATH);
+ if(path[strlen(path)-1]!='/'){
+ path[strlen(path)+1]=0;
+ path[strlen(path)]='/';
+ }
+ path[strlen(path)+1]=0;
+ wraSetDLLAccessPath(path);
+ }
+ } else
+#endif
+ {
+ if(raSetDLLAccessPath){
sprintf(path, "DT_Codecs=" REALCODEC_PATH);
if(path[strlen(path)-1]!='/'){
path[strlen(path)+1]=0;
@@ -95,13 +208,25 @@
}
path[strlen(path)+1]=0;
raSetDLLAccessPath(path);
+ }
}
+#ifdef USE_WIN32DLL
+ if (dll_type == 1) {
+ result=wraOpenCodec2(&sh->context);
+ if(result){
+ mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder open failed, error code: 0x%X\n",result);
+ return 0;
+ }
+ } else
+#endif
+ {
result=raOpenCodec2(&sh->context);
if(result){
mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder open failed, error code: 0x%X\n",result);
return 0;
}
+ }
sh->samplerate=sh->wf->nSamplesPerSec;
sh->samplesize=sh->wf->wBitsPerSample/8;
@@ -116,6 +241,11 @@
((short*)(sh->wf+1))[4], // codec data length
((char*)(sh->wf+1))+10 // extras
};
+#ifdef USE_WIN32DLL
+ if (dll_type == 1)
+ result=wraInitDecoder(sh->context,&init_data);
+ else
+#endif
result=raInitDecoder(sh->context,&init_data);
if(result){
mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder init failed, error code: 0x%X\n",result);
@@ -123,20 +253,45 @@
}
}
+#ifdef USE_WIN32DLL
+ if (dll_type == 1)
+ if(wraSetPwd){
+ // used by 'SIPR'
+ wraSetPwd(sh->context,"Ardubancel Quazanga"); // set password... lol.
+ }
+ } else
+#endif
+ {
if(raSetPwd){
// used by 'SIPR'
raSetPwd(sh->context,"Ardubancel Quazanga"); // set password... lol.
}
+ }
+#ifdef USE_WIN32DLL
+ if (dll_type == 1)
+ result=wraSetFlavor(sh->context,((short*)(sh->wf+1))[2]);
+ else
+#endif
result=raSetFlavor(sh->context,((short*)(sh->wf+1))[2]);
if(result){
mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder flavor setup failed, error code: 0x%X\n",result);
return 0;
}
+#ifdef USE_WIN32DLL
+ if (dll_type == 1)
+ prop=wraGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],0,&len);
+ else
+#endif
prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],0,&len);
mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Audio codec: [%d] %s\n",((short*)(sh->wf+1))[2],prop);
+#ifdef USE_WIN32DLL
+ if (dll_type == 1)
+ prop=wraGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],1,&len);
+ 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);
@@ -229,6 +384,12 @@
}
#endif
+#ifdef USE_WIN32DLL
+ if (dll_type == 1)
+ result=wraDecode(sh->context, sh->a_in_buffer+sh->a_in_buffer_size-sh->a_in_buffer_len, sh->wf->nBlockAlign,
+ buf, &len, -1);
+ else
+#endif
result=raDecode(sh->context, sh->a_in_buffer+sh->a_in_buffer_size-sh->a_in_buffer_len, sh->wf->nBlockAlign,
buf, &len, -1);
sh->a_in_buffer_len-=sh->wf->nBlockAlign;
-------------- next part --------------
--- 0_90.cvs/libmpcodecs/ad_realaud.c 2003-02-10 09:56:46.000000000 -0600
+++ 0_90.dev/libmpcodecs/ad_realaud.c 2003-02-10 09:56:04.000000000 -0600
@@ -172,7 +172,10 @@
char path[4096];
char *temp;
- sprintf(path, REALCODEC_PATH "/%s", sh->codec->dll);
+ temp = get_path(REALCODEC_PATH);
+ sprintf(path, "%s\\%s", temp, sh->codec->dll);
+
+ SetEnvironmentVariableA("PATH", temp);
if(!load_syms_linux(path))
#ifdef USE_WIN32DLL
-------------- next part --------------
--- 0_90.cvs/libmpcodecs/vd_realvid.c 2003-02-10 09:09:07.000000000 -0600
+++ 0_90.dev/libmpcodecs/vd_realvid.c 2003-02-10 09:18:48.000000000 -0600
@@ -22,6 +22,9 @@
LIBVD_EXTERN(realvid)
+#ifdef __CYGWIN__
+#define USE_WIN32DLL
+#endif
/*
* Structures for data packets. These used to be tables of unsigned ints, but
* that does not work on 64 bit platforms (e.g. Alpha). The entries that are
@@ -125,21 +128,33 @@
#ifdef USE_WIN32DLL
+#ifndef __CYGWIN__
#include "../loader/ldt_keeper.h"
+#endif
void* WINAPI LoadLibraryA(char* name);
void* WINAPI GetProcAddress(void* handle,char* func);
int WINAPI FreeLibrary(void *handle);
+#ifdef __CYGWIN__
+int WINAPI SetEnvironmentVariableA(char *name, char *value);
+DWORD WINAPI GetLastError(void);
+#endif
static int load_syms_windows(char *path) {
void *handle;
mp_msg(MSGT_DECVIDEO,MSGL_INFO, "opening win32 dll '%s'\n", path);
+#ifndef __CYGWIN__
Setup_LDT_Keeper();
+#endif
rv_handle = handle = LoadLibraryA(path);
mp_msg(MSGT_DECVIDEO,MSGL_V,"win32 real codec handle=%p \n",handle);
if (!handle) {
+#ifdef __CYGWIN__
+ mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error loading dll (%d)\n",GetLastError());
+#else
mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error loading dll\n");
+#endif
return 0;
}
@@ -193,7 +209,9 @@
/* first try to load linux dlls, if failed and we're supporting win32 dlls,
then try to load the windows ones */
+#ifndef __CYGWIN__
if(!load_syms_linux(path))
+#endif
#ifdef USE_WIN32DLL
if (!load_syms_windows(path))
#endif
-------------- next part --------------
--- 0_90.cvs/libmpcodecs/vd_realvid.c 2003-02-10 09:18:48.000000000 -0600
+++ 0_90.dev/libmpcodecs/vd_realvid.c 2003-02-10 09:18:29.000000000 -0600
@@ -205,7 +205,10 @@
mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo codec id: 0x%08X sub-id: 0x%08X\n",extrahdr[1],extrahdr[0]);
- sprintf(path, REALCODEC_PATH "/%s", sh->codec->dll);
+ temp = get_path(REALCODEC_PATH);
+ sprintf(path, "%s\\%s", temp, sh->codec->dll);
+
+ SetEnvironmentVariableA("PATH", temp);
/* first try to load linux dlls, if failed and we're supporting win32 dlls,
then try to load the windows ones */
More information about the MPlayer-dev-eng
mailing list