[MPlayer-dev-eng] [PATCH] mencoder to load win32 codecs properly

Sascha Sommer saschasommer at freenet.de
Thu Oct 13 14:40:15 CEST 2005


On Thursday 13 October 2005 07:21, Zuxy wrote:
> 2005/10/11, Guillaume POIRIER <poirierg at gmail.com>:
> > Hi,
> >
> > That seems to be the place where it should be, indeed.
>
> Now the new patches. Code moved to get_path.c
>

Some remarks, see below

+#if defined(WIN32) && defined(USE_WIN32DLL)
+void set_path_env()
+{
+ /*make our codec dirs available for LoadLibraryA()*/
+ char tmppath[MAX_PATH*2 + 1];
+ char win32path[MAX_PATH];
+ char realpath[MAX_PATH];
+#ifdef __CYGWIN__
+ cygwin_conv_to_full_win32_path(WIN32_PATH,win32path);
+ strcpy(tmppath,win32path);
+ mp_msg(MSGT_WIN32, MSGL_V, "Expanded WIN32_PATH: %s\n", win32path);
+#ifdef USE_REALCODECS
+ cygwin_conv_to_full_win32_path(REALCODEC_PATH,realpath);
+ mp_msg(MSGT_WIN32, MSGL_V, "Expanded REALCODEC_PATH: %s\n", realpath);
+ sprintf(tmppath,"%s;%s",win32path,realpath);
+#endif /*USE_REALCODECS*/
+#else /*__CYGWIN__*/
+ /* Expand to absolute path unless it's already absolute */
+ if(!strstr(WIN32_PATH,":") && WIN32_PATH[0] != '\\'){
+  GetModuleFileNameA(NULL, win32path, MAX_PATH);
+ strcpy(strrchr(win32path, '\\') + 1, WIN32_PATH);
+ }
+ else strcpy(win32path,WIN32_PATH);
+ strcpy(tmppath,win32path);
+ mp_msg(MSGT_WIN32, MSGL_V, "Expanded WIN32_PATH: %s\n", win32path);
+#ifdef USE_REALCODECS
+ /* Expand to absolute path unless it's already absolute */
+ if(!strstr(REALCODEC_PATH,":") && REALCODEC_PATH[0] != '\\'){
+  GetModuleFileNameA(NULL, realpath, MAX_PATH);
+ strcpy(strrchr(realpath, '\\') + 1, REALCODEC_PATH);
+ }
+ else strcpy(realpath,REALCODEC_PATH);
+ mp_msg(MSGT_WIN32, MSGL_V, "Expanded REALCODEC_PATH: %s\n", realpath);
+ sprintf(tmppath,"%s;%s",win32path,realpath);
+#endif /*USE_REALCODECS*/
+#endif /*__CYGWIN__*/
+ if (!SetEnvironmentVariableA("PATH", tmppath))
+  mp_msg(MSGT_WIN32, MSGL_WARN, "Cannot set PATH!");
+}
+#endif /*WIN32 && USE_WIN32DLL*/

I think we don't need that many mp_msgs. One that outputs the whole  PATH 
environment variable in a higher debug level than MSGL_V should be enough.
Also the current content of the PATH environment variable gets discarded.
Please change the code to only append the real and win32 paths.
Last but not least the function should be a bit more carefull with the 
strings.

Thanks in advance

Sascha




More information about the MPlayer-dev-eng mailing list