[MPlayer-dev-eng] [PATCH] win32 codec path

Joey Parrish joey at nicewarrior.org
Sun Aug 10 22:29:17 CEST 2003


On Sun, Aug 10, 2003 at 08:40:29PM +0200, Sascha Sommer wrote:
> > On Sat, Aug 09, 2003 at 08:11:21PM +0200, Sascha Sommer wrote:
> > > What about the attached patch?
> > > Like on linux real dlls only get loaded from WIN32_PATH.
> >
> > I don't understand... real dlls get loaded from REALCODEC_PATH on
> > linux by hardcoding the path into the dll.  What does WIN32_PATH have to
> 
> No, it was changed to only load the linux libs from REALCODEC_PATH

Oh, I see.  You mean that the path gets hardcoded to LoadLibrary only
under linux?  That makes sense.

> I think the best thing would be to combine the two paths. Afair you can do
> this with ";"
Yes, that's correct.

> Then I would set this path once at the beginning of mplayer execution. Imho
> a RegisterCodecPath() is to much overhead.

That's fine.  Doing this should solve all of our problems, then.
What do you think of this patch?  It moves the expansion of relative
to full path on mingw into a function, to make the PATH building
code nicer.  (untested, I'm away from home...)  Comments?

--Joey
-------------- next part --------------
--- mplayer.c	9 Aug 2003 14:22:49 -0000	1.710
+++ mplayer.c	9 Aug 2003 18:18:40 -0000
@@ -790,6 +790,29 @@
 #endif
 #endif
 
+#ifdef WIN32
+#ifndef __CYGWIN__
+// convert from relative path to full path under mingw
+// we assume newpath is MAX_PATH long, and neither arg is NULL
+void cygwin_conv_to_full_win32_path(char *path, char *newpath) {
+  int WINAPI GetModuleFileNameA(void*,char*,int);
+  if(!strstr(path, ":")) {
+    GetModuleFileNameA(NULL, newpath, MAX_PATH);
+    strncpy(rindex(newpath, '\\') +1, path, MAX_PATH - strlen(WIN32_PATH) -1);
+  }
+}
+#endif
+  
+{  /*make our codecs dirs available for LoadLibraryA()*/
+  char tmppath[MAX_PATH * 2];
+  int WINAPI SetEnvironmentVariableA(char*,char*);
+  cygwin_conv_to_full_win32_path(WIN32_PATH,tmppath);
+  tmppath[strlen(tmppath)] = ';';
+  cygwin_conv_to_full_win32_path(REALCODEC_PATH,tmppath + strlen(tmppath));
+  SetEnvironmentVariableA("PATH", tmppath);
+}
+#endif
+
 #ifdef USE_TV
   tv_param_immediate = 1;
 #endif


More information about the MPlayer-dev-eng mailing list