2 * Modified for use with MPlayer, detailed changelog at
3 * http://svn.mplayerhq.hu/mplayer/trunk/
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
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
)
152 const char* filename
= (const char*) ((ICOPEN
*) lParam2
)->pV1Reserved
;
157 printf("Loading codec DLL: '%s'\n",filename
);
159 hDriver
= (NPDRVR
) malloc(sizeof(DRVR
));
162 memset((void*)hDriver
, 0, sizeof(DRVR
));
169 hDriver
->hDriverModule
= LoadLibraryA(filename
);
170 if (!hDriver
->hDriverModule
)
172 printf("Can't open library %s\n", filename
);
173 DrvClose((HDRVR
)hDriver
);
177 hDriver
->DriverProc
= (DRIVERPROC
) GetProcAddress(hDriver
->hDriverModule
,
179 if (!hDriver
->DriverProc
)
181 printf("Library %s is not a valid VfW/ACM codec\n", filename
);
182 DrvClose((HDRVR
)hDriver
);
186 TRACE("DriverProc == %X\n", hDriver
->DriverProc
);
187 SendDriverMessage((HDRVR
)hDriver
, DRV_LOAD
, 0, 0);
188 TRACE("DRV_LOAD Ok!\n");
189 SendDriverMessage((HDRVR
)hDriver
, DRV_ENABLE
, 0, 0);
190 TRACE("DRV_ENABLE Ok!\n");
191 hDriver
->dwDriverID
= ++dwDrvID
; // generate new id
193 // open driver and remmeber proper DriverID
194 hDriver
->dwDriverID
= SendDriverMessage((HDRVR
)hDriver
, DRV_OPEN
, (LPARAM
) unknown
, lParam2
);
195 TRACE("DRV_OPEN Ok!(%X)\n", hDriver
->dwDriverID
);
197 printf("Loaded DLL driver %s at %x\n", filename
, hDriver
->hDriverModule
);
198 return (HDRVR
)hDriver
;