Mercurial > mplayer.hg
annotate loader/driver.c @ 1197:80ca716ce5e9
Made surface locks switchable via preprocessor.
author | atmosfear |
---|---|
date | Sat, 23 Jun 2001 10:18:23 +0000 |
parents | 1f7c824033fb |
children | d8c1b0b38edc |
rev | line source |
---|---|
1 | 1 #include <config.h> |
2 #include <stdio.h> | |
3 | |
4 #ifdef HAVE_MALLOC_H | |
5 #include <malloc.h> | |
6 #else | |
7 #include <stdlib.h> | |
8 #endif | |
9 | |
10 #include <wine/driver.h> | |
11 #include <wine/pe_image.h> | |
12 #include <wine/winreg.h> | |
13 #include <wine/vfw.h> | |
14 #include <registry.h> | |
15 | |
185
b2dfe79ffb9f
disabled DirectShow loader - use libDS_Filter instead
arpi_esp
parents:
128
diff
changeset
|
16 //#include "com.h" |
b2dfe79ffb9f
disabled DirectShow loader - use libDS_Filter instead
arpi_esp
parents:
128
diff
changeset
|
17 //typedef long STDCALL (*GETCLASS) (GUID*, GUID*, void**); |
1 | 18 |
19 | |
20 #ifdef __FreeBSD__ | |
21 #include <sys/time.h> | |
22 #endif | |
23 | |
24 | |
25 #define STORE_ALL \ | |
26 __asm__ ( \ | |
27 "push %%ebx\n\t" \ | |
28 "push %%ecx\n\t" \ | |
29 "push %%edx\n\t" \ | |
30 "push %%esi\n\t" \ | |
31 "push %%edi\n\t"::) | |
32 | |
33 #define REST_ALL \ | |
34 __asm__ ( \ | |
35 "pop %%edi\n\t" \ | |
36 "pop %%esi\n\t" \ | |
37 "pop %%edx\n\t" \ | |
38 "pop %%ecx\n\t" \ | |
39 "pop %%ebx\n\t"::) | |
40 | |
41 | |
42 | |
43 typedef struct { | |
44 UINT uDriverSignature; | |
45 HINSTANCE hDriverModule; | |
46 DRIVERPROC DriverProc; | |
47 DWORD dwDriverID; | |
48 } DRVR; | |
49 | |
50 typedef DRVR *PDRVR; | |
51 typedef DRVR *NPDRVR; | |
52 typedef DRVR *LPDRVR; | |
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; | |
236 | 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 | |
128 | 122 extern char* def_path; //=WIN32_PATH; // path to codecs |
1 | 123 char* win32_codec_name=NULL; // must be set before calling DrvOpen() !!! |
124 | |
125 HDRVR | |
126 DrvOpen(LPARAM lParam2) | |
127 { | |
128 ICOPEN *icopen=(ICOPEN *) lParam2; | |
129 UINT uDrvResult; | |
130 HDRVR hDriver; | |
131 NPDRVR npDriver; | |
132 char unknown[0x24]; | |
133 // char* codec_name=icopen->fccHandler; | |
134 | |
236 | 135 Setup_LDT_Keeper(); |
136 | |
1 | 137 if (!(npDriver = DrvAlloc(&hDriver, &uDrvResult))) |
138 return ((HDRVR) 0); | |
139 | |
140 if (!(npDriver->hDriverModule = expLoadLibraryA(win32_codec_name))) { | |
141 printf("Can't open library %s\n", win32_codec_name); | |
142 DrvFree(hDriver); | |
143 return ((HDRVR) 0); | |
144 } | |
145 | |
146 #if 0 | |
147 { | |
148 unsigned char *p=((char*)npDriver->hDriverModule); | |
149 double *dp; | |
150 int i; | |
151 p+=0x14c0; | |
152 for(i=0;i<16;i++)printf(" %02X",p[i]); printf("\n"); | |
153 dp=(double*)p; | |
154 printf("divx bitrate = %f\n",(float)(*dp)); | |
155 // *(double*)((char*)npDriver->hDriverModule+0x14c0)=bitrate; | |
156 } | |
157 #endif | |
158 | |
159 if (!(npDriver->DriverProc = (DRIVERPROC) | |
160 GetProcAddress(npDriver->hDriverModule, "DriverProc"))) { | |
185
b2dfe79ffb9f
disabled DirectShow loader - use libDS_Filter instead
arpi_esp
parents:
128
diff
changeset
|
161 #if 1 |
1 | 162 printf("Library %s is not a VfW/ACM valid codec\n", win32_codec_name); |
163 #else | |
164 // Try DirectShow... | |
165 GETCLASS func=(GETCLASS)GetProcAddress(npDriver->hDriverModule,"DllGetClassObject"); | |
166 if(!func) | |
167 printf("Library %s is not a valid VfW/ACM/DShow codec\n", win32_codec_name); | |
168 else { | |
169 HRESULT result; | |
170 struct IClassFactory* factory=0; | |
171 struct IUnknown* object=0; | |
172 GUID CLSID_Voxware={0x73f7a062, 0x8829, 0x11d1, | |
173 {0xb5, 0x50, 0x00, 0x60, 0x97, 0x24, 0x2d, 0x8d}}; | |
174 GUID* id=&CLSID_Voxware; | |
175 | |
176 result=func(id, &IID_IClassFactory, (void**)&factory); | |
340 | 177 if(result || (!factory)) printf("No such class object (wrong/missing GUID?)\n"); |
1 | 178 |
179 printf("Calling factory->vt->CreateInstance()\n"); | |
180 printf("addr = %X\n",(unsigned int)factory->vt->CreateInstance); | |
181 result=factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object); | |
182 printf("Calling factory->vt->Release()\n"); | |
183 factory->vt->Release((struct IUnknown*)factory); | |
184 if(result || (!object)) printf("Class factory failure\n"); | |
185 | |
186 printf("DirectShow codecs not yet supported...\n"); | |
187 } | |
188 #endif | |
189 | |
190 FreeLibrary(npDriver->hDriverModule); | |
191 DrvFree(hDriver); | |
192 return ((HDRVR) 0); | |
193 | |
194 } | |
195 | |
196 //TRACE("DriverProc == %X\n", npDriver->DriverProc); | |
197 npDriver->dwDriverID = ++dwDrvID; | |
198 | |
236 | 199 setup_FS_Segment(); |
200 | |
1 | 201 STORE_ALL; |
202 (npDriver->DriverProc)(0, hDriver, DRV_LOAD, 0, 0); | |
203 REST_ALL; | |
204 //TRACE("DRV_LOAD Ok!\n"); | |
205 STORE_ALL; | |
206 (npDriver->DriverProc)(0, hDriver, DRV_ENABLE, 0, 0); | |
207 REST_ALL; | |
208 //TRACE("DRV_ENABLE Ok!\n"); | |
209 | |
210 // open driver | |
211 STORE_ALL; | |
212 npDriver->dwDriverID=(npDriver->DriverProc)(npDriver->dwDriverID, hDriver, DRV_OPEN, | |
213 (LPARAM) (LPSTR) unknown, lParam2); | |
214 REST_ALL; | |
215 | |
216 //TRACE("DRV_OPEN Ok!(%X)\n", npDriver->dwDriverID); | |
217 | |
218 if (uDrvResult) | |
219 { | |
220 DrvFree(hDriver); | |
221 hDriver = (HDRVR) 0; | |
222 } | |
223 | |
340 | 224 // printf("Successfully loaded codec %s\n",win32_codec_name); |
1 | 225 |
226 return (hDriver); | |
227 } | |
228 |