2 * Modified for use with MPlayer, detailed changelog at
3 * http://svn.mplayerhq.hu/mplayer/trunk/
16 #include "wine/driver.h"
17 #include "wine/pe_image.h"
18 #include "wine/winreg.h"
22 #include "ldt_keeper.h"
30 char* def_path
=WIN32_PATH
;
32 extern char* def_path
;
38 * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
39 * WINAPI/no-WINAPI bustage.
41 * There should be no need for the STORE_ALL/REST_ALL hack once all
42 * function definitions agree with their prototypes (WINAPI-wise) and
43 * we make sure, that we do not call these functions without a proper
50 // this asm code is no longer needed
68 static int needs_free
=0;
69 void SetCodecPath(const char* path
)
71 if(needs_free
)free(def_path
);
78 def_path
= malloc(strlen(path
)+1);
79 strcpy(def_path
, path
);
83 static DWORD dwDrvID
= 0;
85 LRESULT WINAPI
SendDriverMessage(HDRVR hDriver
, UINT message
,
86 LPARAM lParam1
, LPARAM lParam2
)
88 DRVR
* module
=(DRVR
*)hDriver
;
94 printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver
, message
, lParam1
, lParam2
);
96 if (!module
|| !module
->hDriverModule
|| !module
->DriverProc
) return -1;
98 __asm__
volatile ("fsave (%0)\n\t": :"r"(&qw
));
106 result
=module
->DriverProc(module
->dwDriverID
, hDriver
, message
, lParam1
, lParam2
);
110 __asm__
volatile ("frstor (%0)\n\t": :"r"(&qw
));
114 printf("\t\tResult: %X\n", result
);
119 void DrvClose(HDRVR hDriver
)
123 DRVR
* d
= (DRVR
*)hDriver
;
124 if (d
->hDriverModule
)
131 SendDriverMessage(hDriver
, DRV_CLOSE
, 0, 0);
133 SendDriverMessage(hDriver
, DRV_FREE
, 0, 0);
135 FreeLibrary(d
->hDriverModule
);
144 //DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
145 HDRVR
DrvOpen(LPARAM lParam2
)
149 const char* filename
= (const char*) ((ICOPEN
*) lParam2
)->pV1Reserved
;
154 printf("Loading codec DLL: '%s'\n",filename
);
156 hDriver
= malloc(sizeof(DRVR
));
159 memset((void*)hDriver
, 0, sizeof(DRVR
));
166 hDriver
->hDriverModule
= LoadLibraryA(filename
);
167 if (!hDriver
->hDriverModule
)
169 printf("Can't open library %s\n", filename
);
170 DrvClose((HDRVR
)hDriver
);
174 hDriver
->DriverProc
= (DRIVERPROC
) GetProcAddress(hDriver
->hDriverModule
,
176 if (!hDriver
->DriverProc
)
178 printf("Library %s is not a valid VfW/ACM codec\n", filename
);
179 DrvClose((HDRVR
)hDriver
);
183 TRACE("DriverProc == %X\n", hDriver
->DriverProc
);
184 SendDriverMessage((HDRVR
)hDriver
, DRV_LOAD
, 0, 0);
185 TRACE("DRV_LOAD Ok!\n");
186 SendDriverMessage((HDRVR
)hDriver
, DRV_ENABLE
, 0, 0);
187 TRACE("DRV_ENABLE Ok!\n");
188 hDriver
->dwDriverID
= ++dwDrvID
; // generate new id
190 // open driver and remmeber proper DriverID
191 hDriver
->dwDriverID
= SendDriverMessage((HDRVR
)hDriver
, DRV_OPEN
, (LPARAM
) unknown
, lParam2
);
192 TRACE("DRV_OPEN Ok!(%X)\n", hDriver
->dwDriverID
);
194 printf("Loaded DLL driver %s at %x\n", filename
, hDriver
->hDriverModule
);
195 return (HDRVR
)hDriver
;