diff gui/win32/interface.c @ 34115:3d7ee643b110

Port to Wine. This makes MPlayer and the GUI compile and run as a Wine executable, which is mainly to allow Windows code checking in a Linux environment. In Makefile: Generalize the windres call by specifying option "-o" for the output file. In gui/win32/interface.c: Use the same function to create a thread as Cygwin, and convert Windows style file names so that they are accessible in the Linux environment. In osdep/priority.c: Include windows.h. In configure: Add system "Wine" which shall be considered (mostly) a win32 system. Since winegcc by default compiles all files with the "-fpic" flag, remove it, and remove all MinGW compatibility WIN32 defines, because we're not compiling for real Windows. Define to not use Windows sockets (Wine uses different ones) and replace Windows' stricmp by strcasecmp. Ensure that yasm's object format isn't win32 and that HAVE_LINUX_DVD_STRUCT will be defined. In stream/tvi_dshow.c: Define MP_DEFINE_LOCAL_GUID, because Wine's DEFINE_GUID macro isn't compatible using "static" with it. In loader/com.h: Rename the IIDs to become local ones, because Wine's unknwn.h not only declares but defines them. In mplayer.c: Don't define a SIGSEGV signal handler, or the Wine executable will crash.
author ib
date Sat, 15 Oct 2011 13:20:52 +0000
parents b77b5e7bee72
children 39ca8e25ba79
line wrap: on
line diff
--- a/gui/win32/interface.c	Sat Oct 15 11:07:29 2011 +0000
+++ b/gui/win32/interface.c	Sat Oct 15 13:20:52 2011 +0000
@@ -23,7 +23,7 @@
 
 #include <windows.h>
 
-#if defined(__CYGWIN__)
+#if defined(__CYGWIN__) || defined(__WINE__)
 #define _beginthreadex CreateThread
 #else
 #include <process.h>
@@ -332,6 +332,44 @@
     mygui->startplay(mygui);
 }
 
+#ifdef __WINE__
+/**
+ * @brief Convert a Windows style file name into an Unix style one.
+ *
+ * @param filename pointer to the file name to be converted
+ *
+ * @return pointer to the converted file name
+ */
+static char *unix_name (char *filename)
+{
+    static char *unix_filename;
+    LPSTR (*CDECL wine_get_unix_file_name_ptr)(LPCWSTR);
+    int wchar_conv;
+
+    if (*filename && (filename[1] == ':'))
+    {
+        wine_get_unix_file_name_ptr = (void *) GetProcAddress(GetModuleHandleA("KERNEL32"), "wine_get_unix_file_name");
+        wchar_conv = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0);
+
+        if (wine_get_unix_file_name_ptr && wchar_conv)
+        {
+            WCHAR *ntpath;
+            char *unix_name;
+
+            ntpath = HeapAlloc(GetProcessHeap(), 0, sizeof(*ntpath) * (wchar_conv + 1));
+            MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, ntpath, wchar_conv);
+            unix_name = wine_get_unix_file_name_ptr(ntpath);
+            setdup(&unix_filename, unix_name);
+            filename = unix_filename;
+            HeapFree(GetProcessHeap(), 0, unix_name);
+            HeapFree(GetProcessHeap(), 0, ntpath);
+        }
+    }
+
+    return filename;
+}
+#endif
+
 void uiSetFileName(char *dir, char *name, int type)
 {
     if(!name) return;
@@ -341,6 +379,9 @@
         setddup(&guiInfo.Filename, dir, name);
 
     filename = guiInfo.Filename;
+#ifdef __WINE__
+    filename = unix_name(filename);
+#endif
     guiInfo.StreamType = type;
 
     nfree(guiInfo.AudioFilename);