Mercurial > mplayer.hg
annotate loader/driver.c @ 13730:a45e901cc870
user selectable cutoff frequency
simplify resampling factor if possible, so more then one resampler can be used, libaf will still die if there are too many like it does with the default resampler (2 with sampling rates which are relative prime are too many ...)
author | michael |
---|---|
date | Thu, 21 Oct 2004 21:15:21 +0000 |
parents | d1d0b81f15c9 |
children | f5537cc95b02 |
rev | line source |
---|---|
7386 | 1 #include "config.h" |
2 | |
1 | 3 #include <stdio.h> |
4 #ifdef HAVE_MALLOC_H | |
5 #include <malloc.h> | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
6 #endif |
1 | 7 #include <stdlib.h> |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
8 #ifdef __FreeBSD__ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
9 #include <sys/time.h> |
1 | 10 #endif |
11 | |
2068
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
12 #include "win32.h" |
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
13 #include "wine/driver.h" |
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
14 #include "wine/pe_image.h" |
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
15 #include "wine/winreg.h" |
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
16 #include "wine/vfw.h" |
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
17 #include "registry.h" |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
18 #ifdef WIN32_LOADER |
2068
3189c317dfc1
using ldt_keeper instead of setup_fs, includes changed
arpi
parents:
1307
diff
changeset
|
19 #include "ldt_keeper.h" |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
20 #endif |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
21 #include "driver.h" |
9978 | 22 #ifndef __MINGW32__ |
8451 | 23 #include "ext.h" |
9978 | 24 #endif |
1 | 25 |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
26 #ifndef WIN32_LOADER |
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
27 char* def_path=WIN32_PATH; |
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
28 #else |
7386 | 29 extern char* def_path; |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
30 #endif |
1 | 31 |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
32 #if 1 |
7386 | 33 |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
34 /* |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
35 * 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
|
36 * WINAPI/no-WINAPI bustage. |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
37 * |
7386 | 38 * There should be no need for the STORE_ALL/REST_ALL hack once all |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
39 * 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
|
40 * 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
|
41 * prototype in scope. |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
42 */ |
7386 | 43 |
44 #define STORE_ALL | |
45 #define REST_ALL | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
46 #else |
7386 | 47 // this asm code is no longer needed |
1 | 48 #define STORE_ALL \ |
7386 | 49 __asm__ __volatile__ ( \ |
1 | 50 "push %%ebx\n\t" \ |
51 "push %%ecx\n\t" \ | |
52 "push %%edx\n\t" \ | |
53 "push %%esi\n\t" \ | |
54 "push %%edi\n\t"::) | |
55 | |
56 #define REST_ALL \ | |
7386 | 57 __asm__ __volatile__ ( \ |
1 | 58 "pop %%edi\n\t" \ |
59 "pop %%esi\n\t" \ | |
60 "pop %%edx\n\t" \ | |
61 "pop %%ecx\n\t" \ | |
62 "pop %%ebx\n\t"::) | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
340
diff
changeset
|
63 #endif |
1 | 64 |
7386 | 65 static int needs_free=0; |
66 void SetCodecPath(const char* path) | |
67 { | |
68 if(needs_free)free(def_path); | |
69 if(path==0) | |
70 { | |
71 def_path=WIN32_PATH; | |
72 needs_free=0; | |
73 return; | |
74 } | |
75 def_path = (char*) malloc(strlen(path)+1); | |
76 strcpy(def_path, path); | |
77 needs_free=1; | |
78 } | |
1 | 79 |
80 static DWORD dwDrvID = 0; | |
81 | |
7386 | 82 LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message, |
83 LPARAM lParam1, LPARAM lParam2) | |
1 | 84 { |
85 DRVR* module=(DRVR*)hDriver; | |
86 int result; | |
7386 | 87 #ifndef __svr4__ |
88 char qw[300]; | |
89 #endif | |
90 #ifdef DETAILED_OUT | |
1 | 91 printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2); |
92 #endif | |
7386 | 93 if (!module || !module->hDriverModule || !module->DriverProc) return -1; |
94 #ifndef __svr4__ | |
95 __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw)); | |
96 #endif | |
97 | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
98 #ifdef WIN32_LOADER |
7386 | 99 Setup_FS_Segment(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
100 #endif |
1 | 101 |
7386 | 102 STORE_ALL; |
103 result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2); | |
104 REST_ALL; | |
105 | |
106 #ifndef __svr4__ | |
107 __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw)); | |
108 #endif | |
109 | |
110 #ifdef DETAILED_OUT | |
111 printf("\t\tResult: %X\n", result); | |
112 #endif | |
113 return result; | |
1 | 114 } |
115 | |
7386 | 116 void DrvClose(HDRVR hDriver) |
1 | 117 { |
7386 | 118 if (hDriver) |
119 { | |
120 DRVR* d = (DRVR*)hDriver; | |
121 if (d->hDriverModule) | |
122 { | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
123 #ifdef WIN32_LOADER |
7386 | 124 Setup_FS_Segment(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
125 #endif |
7386 | 126 if (d->DriverProc) |
127 { | |
128 SendDriverMessage(hDriver, DRV_CLOSE, 0, 0); | |
129 d->dwDriverID = 0; | |
130 SendDriverMessage(hDriver, DRV_FREE, 0, 0); | |
131 } | |
132 FreeLibrary(d->hDriverModule); | |
133 } | |
134 free(d); | |
1 | 135 } |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
136 #ifdef WIN32_LOADER |
7386 | 137 CodecRelease(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
138 #endif |
1 | 139 } |
140 | |
7386 | 141 //DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2) |
142 HDRVR DrvOpen(LPARAM lParam2) | |
1 | 143 { |
7386 | 144 NPDRVR hDriver; |
145 int i; | |
146 char unknown[0x124]; | |
147 const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved; | |
1 | 148 |
7386 | 149 #ifdef MPLAYER |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
150 #ifdef WIN32_LOADER |
236 | 151 Setup_LDT_Keeper(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
152 #endif |
7386 | 153 printf("Loading codec DLL: '%s'\n",filename); |
154 #endif | |
236 | 155 |
7386 | 156 hDriver = (NPDRVR) malloc(sizeof(DRVR)); |
157 if (!hDriver) | |
1 | 158 return ((HDRVR) 0); |
7386 | 159 memset((void*)hDriver, 0, sizeof(DRVR)); |
1 | 160 |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
161 #ifdef WIN32_LOADER |
7386 | 162 CodecAlloc(); |
163 Setup_FS_Segment(); | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
164 #endif |
7386 | 165 |
166 hDriver->hDriverModule = LoadLibraryA(filename); | |
167 if (!hDriver->hDriverModule) | |
168 { | |
169 printf("Can't open library %s\n", filename); | |
170 DrvClose((HDRVR)hDriver); | |
171 return ((HDRVR) 0); | |
1 | 172 } |
173 | |
7386 | 174 hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule, |
175 "DriverProc"); | |
176 if (!hDriver->DriverProc) | |
1 | 177 { |
7386 | 178 printf("Library %s is not a valid VfW/ACM codec\n", filename); |
179 DrvClose((HDRVR)hDriver); | |
180 return ((HDRVR) 0); | |
1 | 181 } |
182 | |
7386 | 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 | |
1 | 189 |
7386 | 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); | |
1 | 193 |
12655 | 194 printf("Loaded DLL driver %s at %x\n", filename, hDriver->hDriverModule); |
7386 | 195 return (HDRVR)hDriver; |
1 | 196 } |