2 * Modified for use with MPlayer, detailed changelog at
3 * http://svn.mplayerhq.hu/mplayer/trunk/
20 #include "wine/driver.h"
21 #include "wine/pe_image.h"
22 #include "wine/winreg.h"
26 #include "ldt_keeper.h"
34 char* def_path
=WIN32_PATH
;
36 extern char* def_path
;
42 * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
43 * WINAPI/no-WINAPI bustage.
45 * There should be no need for the STORE_ALL/REST_ALL hack once all
46 * function definitions agree with their prototypes (WINAPI-wise) and
47 * we make sure, that we do not call these functions without a proper
54 // this asm code is no longer needed
56 __asm__ __volatile__ ( \
64 __asm__ __volatile__ ( \
72 static int needs_free
=0;
73 void SetCodecPath(const char* path
)
75 if(needs_free
)free(def_path
);
82 def_path
= (char*) malloc(strlen(path
)+1);
83 strcpy(def_path
, path
);
87 static DWORD dwDrvID
= 0;
89 LRESULT WINAPI
SendDriverMessage(HDRVR hDriver
, UINT message
,
90 LPARAM lParam1
, LPARAM lParam2
)
92 DRVR
* module
=(DRVR
*)hDriver
;
98 printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver
, message
, lParam1
, lParam2
);
100 if (!module
|| !module
->hDriverModule
|| !module
->DriverProc
) return -1;
102 __asm__
__volatile__ ("fsave (%0)\n\t": :"r"(&qw
));
110 result
=module
->DriverProc(module
->dwDriverID
, hDriver
, message
, lParam1
, lParam2
);
114 __asm__
__volatile__ ("frstor (%0)\n\t": :"r"(&qw
));
118 printf("\t\tResult: %X\n", result
);
123 void DrvClose(HDRVR hDriver
)
127 DRVR
* d
= (DRVR
*)hDriver
;
128 if (d
->hDriverModule
)
135 SendDriverMessage(hDriver
, DRV_CLOSE
, 0, 0);
137 SendDriverMessage(hDriver
, DRV_FREE
, 0, 0);
139 FreeLibrary(d
->hDriverModule
);
148 //DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
149 HDRVR
DrvOpen(LPARAM lParam2
)
154 const char* filename
= (const char*) ((ICOPEN
*) lParam2
)->pV1Reserved
;
160 printf("Loading codec DLL: '%s'\n",filename
);
163 hDriver
= (NPDRVR
) malloc(sizeof(DRVR
));
166 memset((void*)hDriver
, 0, sizeof(DRVR
));
173 hDriver
->hDriverModule
= LoadLibraryA(filename
);
174 if (!hDriver
->hDriverModule
)
176 printf("Can't open library %s\n", filename
);
177 DrvClose((HDRVR
)hDriver
);
181 hDriver
->DriverProc
= (DRIVERPROC
) GetProcAddress(hDriver
->hDriverModule
,
183 if (!hDriver
->DriverProc
)
185 printf("Library %s is not a valid VfW/ACM codec\n", filename
);
186 DrvClose((HDRVR
)hDriver
);
190 TRACE("DriverProc == %X\n", hDriver
->DriverProc
);
191 SendDriverMessage((HDRVR
)hDriver
, DRV_LOAD
, 0, 0);
192 TRACE("DRV_LOAD Ok!\n");
193 SendDriverMessage((HDRVR
)hDriver
, DRV_ENABLE
, 0, 0);
194 TRACE("DRV_ENABLE Ok!\n");
195 hDriver
->dwDriverID
= ++dwDrvID
; // generate new id
197 // open driver and remmeber proper DriverID
198 hDriver
->dwDriverID
= SendDriverMessage((HDRVR
)hDriver
, DRV_OPEN
, (LPARAM
) unknown
, lParam2
);
199 TRACE("DRV_OPEN Ok!(%X)\n", hDriver
->dwDriverID
);
201 printf("Loaded DLL driver %s at %x\n", filename
, hDriver
->hDriverModule
);
202 return (HDRVR
)hDriver
;