Mercurial > mplayer.hg
annotate loader/driver.c @ 3927:b8e0fee75aec
some fixes
author | gabucino |
---|---|
date | Tue, 01 Jan 2002 17:35:09 +0000 |
parents | 4dad31e655b6 |
children | 174e2a58b4cd |
rev | line source |
---|---|
1 | 1 #include <config.h> |
2 #include <stdio.h> | |
3 #ifdef HAVE_MALLOC_H | |
4 #include <malloc.h> | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
5 #endif |
1 | 6 #include <stdlib.h> |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
7 #ifdef __FreeBSD__ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
8 #include <sys/time.h> |
1 | 9 #endif |
10 | |
2068
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
11 #include "win32.h" |
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
12 #include "wine/driver.h" |
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
13 #include "wine/pe_image.h" |
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
14 #include "wine/winreg.h" |
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
15 #include "wine/vfw.h" |
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
16 #include "registry.h" |
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
17 #include "ldt_keeper.h" |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
18 #include "driver.h" |
1 | 19 |
20 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
21 #if 1 |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
22 /* |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
23 * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
24 * WINAPI/no-WINAPI bustage. |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
25 * |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
26 * There should be no need for the STORE_ALL/REST_ALL hack once all |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
27 * function definitions agree with their prototypes (WINAPI-wise) and |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
28 * we make sure, that we do not call these functions without a proper |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
29 * prototype in scope. |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
30 */ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
31 #define STORE_ALL /**/ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
32 #define REST_ALL /**/ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
33 #else |
1 | 34 #define STORE_ALL \ |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
35 __asm__( \ |
1 | 36 "push %%ebx\n\t" \ |
37 "push %%ecx\n\t" \ | |
38 "push %%edx\n\t" \ | |
39 "push %%esi\n\t" \ | |
40 "push %%edi\n\t"::) | |
41 | |
42 #define REST_ALL \ | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
43 __asm__( \ |
1 | 44 "pop %%edi\n\t" \ |
45 "pop %%esi\n\t" \ | |
46 "pop %%edx\n\t" \ | |
47 "pop %%ecx\n\t" \ | |
48 "pop %%ebx\n\t"::) | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
49 #endif |
1 | 50 |
51 | |
52 | |
53 | |
54 static DWORD dwDrvID = 0; | |
55 | |
56 | |
57 LRESULT WINAPI SendDriverMessage( HDRVR hDriver, UINT message, | |
58 LPARAM lParam1, LPARAM lParam2 ) | |
59 { | |
60 DRVR* module=(DRVR*)hDriver; | |
61 int result; | |
62 #ifdef DETAILED_OUT | |
63 printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2); | |
64 #endif | |
65 if(module==0)return -1; | |
66 if(module->hDriverModule==0)return -1; | |
67 if(module->DriverProc==0)return -1; | |
68 STORE_ALL; | |
69 result=module->DriverProc(module->dwDriverID,1,message,lParam1,lParam2); | |
70 REST_ALL; | |
71 #ifdef DETAILED_OUT | |
72 printf("\t\tResult: %X\n", result); | |
73 #endif | |
74 return result; | |
75 } | |
76 | |
77 static NPDRVR DrvAlloc(HDRVR*lpDriver, LPUINT lpDrvResult) | |
78 { | |
79 NPDRVR npDriver; | |
80 /* allocate and lock handle */ | |
81 if (lpDriver) | |
82 { | |
83 if ( (*lpDriver = (HDRVR) malloc(sizeof(DRVR))) ) | |
84 { | |
85 if ((npDriver = (NPDRVR) *lpDriver)) | |
86 { | |
87 *lpDrvResult = MMSYSERR_NOERROR; | |
88 return (npDriver); | |
89 } | |
90 free((NPDRVR)*lpDriver); | |
91 } | |
92 return (*lpDrvResult = MMSYSERR_NOMEM, (NPDRVR) 0); | |
93 } | |
94 return (*lpDrvResult = MMSYSERR_INVALPARAM, (NPDRVR) 0); | |
95 } | |
96 | |
97 | |
98 static void DrvFree(HDRVR hDriver) | |
99 { | |
100 int i; | |
2068
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
101 Setup_FS_Segment(); |
1 | 102 if(hDriver) |
103 if(((DRVR*)hDriver)->hDriverModule) | |
104 if(((DRVR*)hDriver)->DriverProc) | |
105 (((DRVR*)hDriver)->DriverProc)(((DRVR*)hDriver)->dwDriverID, hDriver, DRV_CLOSE, 0, 0); | |
106 if(hDriver) { | |
107 if(((DRVR*)hDriver)->hDriverModule) | |
108 if(((DRVR*)hDriver)->DriverProc) | |
109 (((DRVR*)hDriver)->DriverProc)(0, hDriver, DRV_FREE, 0, 0); | |
110 FreeLibrary(((DRVR*)hDriver)->hDriverModule); | |
111 free((NPDRVR)hDriver); | |
112 return; | |
113 } | |
114 } | |
115 | |
116 void DrvClose(HDRVR hdrvr) | |
117 { | |
118 DrvFree(hdrvr); | |
119 } | |
120 | |
121 | |
122 char* win32_codec_name=NULL; // must be set before calling DrvOpen() !!! | |
123 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
124 HDRVR VFWAPI |
1 | 125 DrvOpen(LPARAM lParam2) |
126 { | |
127 ICOPEN *icopen=(ICOPEN *) lParam2; | |
128 UINT uDrvResult; | |
129 HDRVR hDriver; | |
130 NPDRVR npDriver; | |
131 char unknown[0x24]; | |
132 // char* codec_name=icopen->fccHandler; | |
133 | |
236 | 134 Setup_LDT_Keeper(); |
135 | |
1 | 136 if (!(npDriver = DrvAlloc(&hDriver, &uDrvResult))) |
137 return ((HDRVR) 0); | |
138 | |
3465 | 139 if (!(npDriver->hDriverModule = LoadLibraryA(win32_codec_name))) { |
1 | 140 printf("Can't open library %s\n", win32_codec_name); |
141 DrvFree(hDriver); | |
142 return ((HDRVR) 0); | |
143 } | |
144 | |
145 #if 0 | |
146 { | |
147 unsigned char *p=((char*)npDriver->hDriverModule); | |
148 double *dp; | |
149 int i; | |
150 p+=0x14c0; | |
151 for(i=0;i<16;i++)printf(" %02X",p[i]); printf("\n"); | |
152 dp=(double*)p; | |
153 printf("divx bitrate = %f\n",(float)(*dp)); | |
154 // *(double*)((char*)npDriver->hDriverModule+0x14c0)=bitrate; | |
155 } | |
156 #endif | |
157 | |
158 if (!(npDriver->DriverProc = (DRIVERPROC) | |
159 GetProcAddress(npDriver->hDriverModule, "DriverProc"))) { | |
185
b2dfe79ffb9f
disabled DirectShow loader - use libDS_Filter instead
arpi_esp
parents:
128
diff
changeset
|
160 #if 1 |
1 | 161 printf("Library %s is not a VfW/ACM valid codec\n", win32_codec_name); |
162 #else | |
163 // Try DirectShow... | |
164 GETCLASS func=(GETCLASS)GetProcAddress(npDriver->hDriverModule,"DllGetClassObject"); | |
165 if(!func) | |
166 printf("Library %s is not a valid VfW/ACM/DShow codec\n", win32_codec_name); | |
167 else { | |
168 HRESULT result; | |
169 struct IClassFactory* factory=0; | |
170 struct IUnknown* object=0; | |
171 GUID CLSID_Voxware={0x73f7a062, 0x8829, 0x11d1, | |
172 {0xb5, 0x50, 0x00, 0x60, 0x97, 0x24, 0x2d, 0x8d}}; | |
173 GUID* id=&CLSID_Voxware; | |
174 | |
175 result=func(id, &IID_IClassFactory, (void**)&factory); | |
340 | 176 if(result || (!factory)) printf("No such class object (wrong/missing GUID?)\n"); |
1 | 177 |
178 printf("Calling factory->vt->CreateInstance()\n"); | |
179 printf("addr = %X\n",(unsigned int)factory->vt->CreateInstance); | |
180 result=factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object); | |
181 printf("Calling factory->vt->Release()\n"); | |
182 factory->vt->Release((struct IUnknown*)factory); | |
183 if(result || (!object)) printf("Class factory failure\n"); | |
184 | |
185 printf("DirectShow codecs not yet supported...\n"); | |
186 } | |
187 #endif | |
188 | |
189 FreeLibrary(npDriver->hDriverModule); | |
190 DrvFree(hDriver); | |
191 return ((HDRVR) 0); | |
192 | |
193 } | |
194 | |
195 //TRACE("DriverProc == %X\n", npDriver->DriverProc); | |
196 npDriver->dwDriverID = ++dwDrvID; | |
197 | |
2068
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
198 Setup_FS_Segment(); |
236 | 199 |
1 | 200 STORE_ALL; |
201 (npDriver->DriverProc)(0, hDriver, DRV_LOAD, 0, 0); | |
202 REST_ALL; | |
203 //TRACE("DRV_LOAD Ok!\n"); | |
204 STORE_ALL; | |
205 (npDriver->DriverProc)(0, hDriver, DRV_ENABLE, 0, 0); | |
206 REST_ALL; | |
207 //TRACE("DRV_ENABLE Ok!\n"); | |
208 | |
209 // open driver | |
210 STORE_ALL; | |
211 npDriver->dwDriverID=(npDriver->DriverProc)(npDriver->dwDriverID, hDriver, DRV_OPEN, | |
212 (LPARAM) (LPSTR) unknown, lParam2); | |
213 REST_ALL; | |
214 | |
215 //TRACE("DRV_OPEN Ok!(%X)\n", npDriver->dwDriverID); | |
216 | |
217 if (uDrvResult) | |
218 { | |
219 DrvFree(hDriver); | |
220 hDriver = (HDRVR) 0; | |
221 } | |
222 | |
340 | 223 // printf("Successfully loaded codec %s\n",win32_codec_name); |
1 | 224 |
225 return (hDriver); | |
226 } | |
227 |