4 * Copyright 1993, 1994 Martin Ayotte
5 * Copyright 1998 Marcus Meissner
6 * Copyright 1999 Eric Pouech
8 * Originally distributed under LPGL 2.1 (or later) by the Wine project.
10 * Modified for use with MPlayer, detailed CVS changelog at
11 * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
13 * File now distributed as part of VLC media player with no modifications.
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
42 #include "wine/driver.h"
43 #include "wine/pe_image.h"
44 #include "wine/winreg.h"
48 #include "ldt_keeper.h"
56 char* def_path
=WIN32_PATH
;
58 extern char* def_path
;
64 * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
65 * WINAPI/no-WINAPI bustage.
67 * There should be no need for the STORE_ALL/REST_ALL hack once all
68 * function definitions agree with their prototypes (WINAPI-wise) and
69 * we make sure, that we do not call these functions without a proper
76 // this asm code is no longer needed
78 __asm__ __volatile__ ( \
86 __asm__ __volatile__ ( \
94 static int needs_free
=0;
95 void SetCodecPath(const char* path
)
97 if(needs_free
)free(def_path
);
104 def_path
= (char*) malloc(strlen(path
)+1);
105 strcpy(def_path
, path
);
109 static DWORD dwDrvID
= 0;
111 LRESULT WINAPI
SendDriverMessage(HDRVR hDriver
, UINT message
,
112 LPARAM lParam1
, LPARAM lParam2
)
114 DRVR
* module
=(DRVR
*)hDriver
;
120 printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver
, message
, lParam1
, lParam2
);
122 if (!module
|| !module
->hDriverModule
|| !module
->DriverProc
) return -1;
124 __asm__
__volatile__ ("fsave (%0)\n\t": :"r"(&qw
));
132 result
=module
->DriverProc(module
->dwDriverID
, hDriver
, message
, lParam1
, lParam2
);
136 __asm__
__volatile__ ("frstor (%0)\n\t": :"r"(&qw
));
140 printf("\t\tResult: %X\n", result
);
145 void DrvClose(HDRVR hDriver
)
149 DRVR
* d
= (DRVR
*)hDriver
;
150 if (d
->hDriverModule
)
157 SendDriverMessage(hDriver
, DRV_CLOSE
, 0, 0);
159 SendDriverMessage(hDriver
, DRV_FREE
, 0, 0);
161 FreeLibrary(d
->hDriverModule
);
170 //DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
171 HDRVR
DrvOpen(LPARAM lParam2
)
176 const char* filename
= (const char*) ((ICOPEN
*) lParam2
)->pV1Reserved
;
182 printf("Loading codec DLL: '%s'\n",filename
);
185 hDriver
= (NPDRVR
) malloc(sizeof(DRVR
));
188 memset((void*)hDriver
, 0, sizeof(DRVR
));
195 hDriver
->hDriverModule
= LoadLibraryA(filename
);
196 if (!hDriver
->hDriverModule
)
198 printf("Can't open library %s\n", filename
);
199 DrvClose((HDRVR
)hDriver
);
203 hDriver
->DriverProc
= (DRIVERPROC
) GetProcAddress(hDriver
->hDriverModule
,
205 if (!hDriver
->DriverProc
)
207 printf("Library %s is not a valid VfW/ACM codec\n", filename
);
208 DrvClose((HDRVR
)hDriver
);
212 TRACE("DriverProc == %X\n", hDriver
->DriverProc
);
213 SendDriverMessage((HDRVR
)hDriver
, DRV_LOAD
, 0, 0);
214 TRACE("DRV_LOAD Ok!\n");
215 SendDriverMessage((HDRVR
)hDriver
, DRV_ENABLE
, 0, 0);
216 TRACE("DRV_ENABLE Ok!\n");
217 hDriver
->dwDriverID
= ++dwDrvID
; // generate new id
219 // open driver and remmeber proper DriverID
220 hDriver
->dwDriverID
= SendDriverMessage((HDRVR
)hDriver
, DRV_OPEN
, (LPARAM
) unknown
, lParam2
);
221 TRACE("DRV_OPEN Ok!(%X)\n", hDriver
->dwDriverID
);
223 printf("Loaded DLL driver %s at %x\n", filename
, hDriver
->hDriverModule
);
224 return (HDRVR
)hDriver
;