[MPlayer-cvslog] r30930 - in trunk: Makefile loader/codecpath.c loader/codecpath.h loader/drv.c loader/drv.h loader/elfdll.c loader/module.c loader/win32.c mencoder.c mplayer.c

reimar subversion at mplayerhq.hu
Thu Mar 18 21:44:02 CET 2010


Author: reimar
Date: Thu Mar 18 21:44:01 2010
New Revision: 30930

Log:
Split codec path related code into a separate file to fix Windows build.

Added:
   trunk/loader/codecpath.c
      - copied, changed from r30929, trunk/loader/drv.c
   trunk/loader/codecpath.h
      - copied, changed from r30929, trunk/loader/drv.h
Modified:
   trunk/Makefile
   trunk/loader/drv.c
   trunk/loader/drv.h
   trunk/loader/elfdll.c
   trunk/loader/module.c
   trunk/loader/win32.c
   trunk/mencoder.c
   trunk/mplayer.c

Modified: trunk/Makefile
==============================================================================
--- trunk/Makefile	Thu Mar 18 01:45:18 2010	(r30929)
+++ trunk/Makefile	Thu Mar 18 21:44:01 2010	(r30930)
@@ -315,6 +315,7 @@ SRCS_COMMON-$(WIN32DLL)              += 
                                         libmpcodecs/vd_vfwex.c \
                                         libmpdemux/demux_avs.c \
                                         loader/afl.c \
+                                        loader/codecpath.c \
                                         loader/drv.c \
                                         loader/vfl.c \
                                         loader/dshow/DS_AudioDecoder.c \

Copied and modified: trunk/loader/codecpath.c (from r30929, trunk/loader/drv.c)
==============================================================================
--- trunk/loader/drv.c	Thu Mar 18 01:45:18 2010	(r30929, copy source)
+++ trunk/loader/codecpath.c	Thu Mar 18 21:44:01 2010	(r30930)
@@ -3,67 +3,12 @@
  * http://svn.mplayerhq.hu/mplayer/trunk/
  */
 
-#include "config.h"
-#include "debug.h"
-
-#include <stdio.h>
 #include <stdlib.h>
-#ifdef __FreeBSD__
-#include <sys/time.h>
-#endif
-
-#include "win32.h"
-#include "wine/driver.h"
-#include "wine/pe_image.h"
-#include "wine/winreg.h"
-#include "wine/vfw.h"
-#include "registry.h"
-#ifdef WIN32_LOADER
-#include "ldt_keeper.h"
-#endif
-#include "drv.h"
-#ifndef __MINGW32__
-#include "ext.h"
-#endif
+#include <string.h>
+#include "config.h"
+#include "codecpath.h"
 
-#ifndef WIN32_LOADER
 char* def_path = BINARY_CODECS_PATH;
-#else
-extern char* def_path;
-#endif
-
-#if 1
-
-/*
- * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
- * WINAPI/no-WINAPI bustage.
- *
- * There should be no need for the STORE_ALL/REST_ALL hack once all
- * function definitions agree with their prototypes (WINAPI-wise) and
- * we make sure, that we do not call these functions without a proper
- * prototype in scope.
- */
-
-#define STORE_ALL
-#define REST_ALL
-#else
-// this asm code is no longer needed
-#define STORE_ALL \
-    __asm__ volatile ( \
-    "push %%ebx\n\t" \
-    "push %%ecx\n\t" \
-    "push %%edx\n\t" \
-    "push %%esi\n\t" \
-    "push %%edi\n\t"::)
-
-#define REST_ALL \
-    __asm__ volatile ( \
-    "pop %%edi\n\t" \
-    "pop %%esi\n\t" \
-    "pop %%edx\n\t" \
-    "pop %%ecx\n\t" \
-    "pop %%ebx\n\t"::)
-#endif
 
 static int needs_free=0;
 void SetCodecPath(const char* path)
@@ -79,118 +24,3 @@ void SetCodecPath(const char* path)
     strcpy(def_path, path);
     needs_free=1;
 }
-
-static DWORD dwDrvID = 0;
-
-LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
-				 LPARAM lParam1, LPARAM lParam2)
-{
-    DRVR* module=(DRVR*)hDriver;
-    int result;
-#ifndef __svr4__
-    char qw[300];
-#endif
-#ifdef DETAILED_OUT
-    printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2);
-#endif
-    if (!module || !module->hDriverModule || !module->DriverProc) return -1;
-#ifndef __svr4__
-    __asm__ volatile ("fsave (%0)\n\t": :"r"(&qw));
-#endif
-
-#ifdef WIN32_LOADER
-    Setup_FS_Segment();
-#endif
-
-    STORE_ALL;
-    result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2);
-    REST_ALL;
-
-#ifndef __svr4__
-    __asm__ volatile ("frstor (%0)\n\t": :"r"(&qw));
-#endif
-
-#ifdef DETAILED_OUT
-    printf("\t\tResult: %X\n", result);
-#endif
-    return result;
-}
-
-void DrvClose(HDRVR hDriver)
-{
-    if (hDriver)
-    {
-	DRVR* d = (DRVR*)hDriver;
-	if (d->hDriverModule)
-	{
-#ifdef WIN32_LOADER
-	    Setup_FS_Segment();
-#endif
-	    if (d->DriverProc)
-	    {
-		SendDriverMessage(hDriver, DRV_CLOSE, 0, 0);
-		d->dwDriverID = 0;
-		SendDriverMessage(hDriver, DRV_FREE, 0, 0);
-	    }
-	    FreeLibrary(d->hDriverModule);
-	}
-	free(d);
-    }
-#ifdef WIN32_LOADER
-    CodecRelease();
-#endif
-}
-
-//DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
-HDRVR DrvOpen(LPARAM lParam2)
-{
-    NPDRVR hDriver;
-    char unknown[0x124];
-    const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved;
-
-#ifdef WIN32_LOADER
-    Setup_LDT_Keeper();
-#endif
-    printf("Loading codec DLL: '%s'\n",filename);
-
-    hDriver = malloc(sizeof(DRVR));
-    if (!hDriver)
-	return (HDRVR) 0;
-    memset((void*)hDriver, 0, sizeof(DRVR));
-
-#ifdef WIN32_LOADER
-    CodecAlloc();
-    Setup_FS_Segment();
-#endif
-
-    hDriver->hDriverModule = LoadLibraryA(filename);
-    if (!hDriver->hDriverModule)
-    {
-	printf("Can't open library %s\n", filename);
-	DrvClose((HDRVR)hDriver);
-	return (HDRVR) 0;
-    }
-
-    hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule,
-						      "DriverProc");
-    if (!hDriver->DriverProc)
-    {
-	printf("Library %s is not a valid VfW/ACM codec\n", filename);
-	DrvClose((HDRVR)hDriver);
-	return (HDRVR) 0;
-    }
-
-    TRACE("DriverProc == %X\n", hDriver->DriverProc);
-    SendDriverMessage((HDRVR)hDriver, DRV_LOAD, 0, 0);
-    TRACE("DRV_LOAD Ok!\n");
-    SendDriverMessage((HDRVR)hDriver, DRV_ENABLE, 0, 0);
-    TRACE("DRV_ENABLE Ok!\n");
-    hDriver->dwDriverID = ++dwDrvID; // generate new id
-
-    // open driver and remmeber proper DriverID
-    hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2);
-    TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID);
-
-    printf("Loaded DLL driver %s at %x\n", filename, hDriver->hDriverModule);
-    return (HDRVR)hDriver;
-}

Copied and modified: trunk/loader/codecpath.h (from r30929, trunk/loader/drv.h)
==============================================================================
--- trunk/loader/drv.h	Thu Mar 18 01:45:18 2010	(r30929, copy source)
+++ trunk/loader/codecpath.h	Thu Mar 18 21:44:01 2010	(r30930)
@@ -3,17 +3,10 @@
  * http://svn.mplayerhq.hu/mplayer/trunk/
  */
 
-#ifndef MPLAYER_DRV_H
-#define MPLAYER_DRV_H
-
-#include "wine/windef.h"
-#include "wine/driver.h"
+#ifndef MPLAYER_CODECPATH_H
+#define MPLAYER_CODECPATH_H
 
+extern char *def_path;
 void SetCodecPath(const char* path);
-void CodecAlloc(void);
-void CodecRelease(void);
 
-HDRVR DrvOpen(LPARAM lParam2);
-void DrvClose(HDRVR hdrvr);
-
-#endif /* MPLAYER_DRV_H */
+#endif /* MPLAYER_CODECPATH_H */

Modified: trunk/loader/drv.c
==============================================================================
--- trunk/loader/drv.c	Thu Mar 18 01:45:18 2010	(r30929)
+++ trunk/loader/drv.c	Thu Mar 18 21:44:01 2010	(r30930)
@@ -25,12 +25,7 @@
 #ifndef __MINGW32__
 #include "ext.h"
 #endif
-
-#ifndef WIN32_LOADER
-char* def_path = BINARY_CODECS_PATH;
-#else
-extern char* def_path;
-#endif
+#include "codecpath.h"
 
 #if 1
 
@@ -65,21 +60,6 @@ extern char* def_path;
     "pop %%ebx\n\t"::)
 #endif
 
-static int needs_free=0;
-void SetCodecPath(const char* path)
-{
-    if(needs_free)free(def_path);
-    if(path==0)
-    {
-	def_path = BINARY_CODECS_PATH;
-	needs_free=0;
-	return;
-    }
-    def_path = malloc(strlen(path)+1);
-    strcpy(def_path, path);
-    needs_free=1;
-}
-
 static DWORD dwDrvID = 0;
 
 LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,

Modified: trunk/loader/drv.h
==============================================================================
--- trunk/loader/drv.h	Thu Mar 18 01:45:18 2010	(r30929)
+++ trunk/loader/drv.h	Thu Mar 18 21:44:01 2010	(r30930)
@@ -9,7 +9,6 @@
 #include "wine/windef.h"
 #include "wine/driver.h"
 
-void SetCodecPath(const char* path);
 void CodecAlloc(void);
 void CodecRelease(void);
 

Modified: trunk/loader/elfdll.c
==============================================================================
--- trunk/loader/elfdll.c	Thu Mar 18 01:45:18 2010	(r30929)
+++ trunk/loader/elfdll.c	Thu Mar 18 21:44:01 2010	(r30930)
@@ -18,6 +18,7 @@
 #include "wine/debugtools.h"
 #include "wine/winerror.h"
 #include "debug.h"
+#include "codecpath.h"
 
 //DEFAULT_DEBUG_CHANNEL(elfdll)
 
@@ -38,7 +39,6 @@ void dump_exports(HMODULE hModule);
 /*---------------- END HACKS ---------------*/
 
 //char *extra_ld_library_path = "/usr/lib/win32";
-extern char* def_path;
 
 struct elfdll_image
 {

Modified: trunk/loader/module.c
==============================================================================
--- trunk/loader/module.c	Thu Mar 18 01:45:18 2010	(r30929)
+++ trunk/loader/module.c	Thu Mar 18 21:44:01 2010	(r30930)
@@ -46,6 +46,7 @@
 #endif
 #include "win32.h"
 #include "drv.h"
+#include "codecpath.h"
 
 #ifdef EMU_QTX_API
 #include "wrapper.h"
@@ -366,7 +367,6 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR lib
 {
 	WINE_MODREF *wm = 0;
 	char* listpath[] = { "", "", "/usr/lib/win32", "/usr/local/lib/win32", 0 };
-	extern char* def_path;
 	char path[512];
 	char checked[2000];
         int i = -1;

Modified: trunk/loader/win32.c
==============================================================================
--- trunk/loader/win32.c	Thu Mar 18 01:45:18 2010	(r30929)
+++ trunk/loader/win32.c	Thu Mar 18 21:44:01 2010	(r30930)
@@ -49,6 +49,7 @@ for DLL to know too much about its envir
 #include "loader.h"
 #include "com.h"
 #include "ext.h"
+#include "codecpath.h"
 
 #include <stdlib.h>
 #include <assert.h>
@@ -77,8 +78,6 @@ for DLL to know too much about its envir
 #include "osdep/mmap_anon.h"
 #include "libavutil/avstring.h"
 
-char* def_path = BINARY_CODECS_PATH;
-
 static void do_cpuid(unsigned int ax, unsigned int *regs)
 {
     __asm__ volatile

Modified: trunk/mencoder.c
==============================================================================
--- trunk/mencoder.c	Thu Mar 18 01:45:18 2010	(r30929)
+++ trunk/mencoder.c	Thu Mar 18 21:44:01 2010	(r30930)
@@ -66,7 +66,7 @@
 #include "get_path.h"
 
 #ifdef CONFIG_WIN32DLL
-#include "loader/drv.h"         // for SetCodecPath()
+#include "loader/codecpath.h"         // for SetCodecPath()
 #endif
 
 #include "stream/stream.h"

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Thu Mar 18 01:45:18 2010	(r30929)
+++ trunk/mplayer.c	Thu Mar 18 21:44:01 2010	(r30930)
@@ -96,7 +96,7 @@
 #include "input/input.h"
 
 #ifdef CONFIG_WIN32DLL
-#include "loader/drv.h"         // for SetCodecPath()
+#include "loader/codecpath.h"         // for SetCodecPath()
 #endif
 
 int slave_mode=0;


More information about the MPlayer-cvslog mailing list