2 * Modified for use with MPlayer, detailed CVS changelog at
3 * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
19 #include "wine/driver.h"
20 #include "wine/pe_image.h"
21 #include "wine/winreg.h"
25 #include "ldt_keeper.h"
33 char* def_path=WIN32_PATH;
35 extern char* def_path;
41 * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
42 * WINAPI/no-WINAPI bustage.
44 * There should be no need for the STORE_ALL/REST_ALL hack once all
45 * function definitions agree with their prototypes (WINAPI-wise) and
46 * we make sure, that we do not call these functions without a proper
53 // this asm code is no longer needed
55 __asm__ __volatile__ ( \
63 __asm__ __volatile__ ( \
71 static int needs_free=0;
72 void SetCodecPath(const char* path)
74 if(needs_free)free(def_path);
81 def_path = (char*) malloc(strlen(path)+1);
82 strcpy(def_path, path);
86 static DWORD dwDrvID = 0;
88 LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
89 LPARAM lParam1, LPARAM lParam2)
91 DRVR* module=(DRVR*)hDriver;
97 printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2);
99 if (!module || !module->hDriverModule || !module->DriverProc) return -1;
101 __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
109 result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2);
113 __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw));
117 printf("\t\tResult: %X\n", result);
122 void DrvClose(HDRVR hDriver)
126 DRVR* d = (DRVR*)hDriver;
127 if (d->hDriverModule)
134 SendDriverMessage(hDriver, DRV_CLOSE, 0, 0);
136 SendDriverMessage(hDriver, DRV_FREE, 0, 0);
138 FreeLibrary(d->hDriverModule);
147 //DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
148 HDRVR DrvOpen(LPARAM lParam2)
153 const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved;
159 printf("Loading codec DLL: '%s'\n",filename);
162 hDriver = (NPDRVR) malloc(sizeof(DRVR));
165 memset((void*)hDriver, 0, sizeof(DRVR));
172 hDriver->hDriverModule = LoadLibraryA(filename);
173 if (!hDriver->hDriverModule)
175 printf("Can't open library %s\n", filename);
176 DrvClose((HDRVR)hDriver);
180 hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule,
182 if (!hDriver->DriverProc)
184 printf("Library %s is not a valid VfW/ACM codec\n", filename);
185 DrvClose((HDRVR)hDriver);
189 TRACE("DriverProc == %X\n", hDriver->DriverProc);
190 SendDriverMessage((HDRVR)hDriver, DRV_LOAD, 0, 0);
191 TRACE("DRV_LOAD Ok!\n");
192 SendDriverMessage((HDRVR)hDriver, DRV_ENABLE, 0, 0);
193 TRACE("DRV_ENABLE Ok!\n");
194 hDriver->dwDriverID = ++dwDrvID; // generate new id
196 // open driver and remmeber proper DriverID
197 hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2);
198 TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID);
200 printf("Loaded DLL driver %s at %x\n", filename, hDriver->hDriverModule);
201 return (HDRVR)hDriver;