Mercurial > mplayer.hg
annotate loader/afl.c @ 30529:6ef41a766a74
GUI: #include associated .h files in .c files.
author | diego |
---|---|
date | Sun, 14 Feb 2010 12:31:24 +0000 |
parents | 0f1b5b68af32 |
children | 601319a3523e |
rev | line source |
---|---|
1 | 1 /************************************************************************** |
2 | |
3 | |
4 This file will contain an interface to ACM drivers. | |
5 Its content will be based mainly on wine/dlls/msacm32 | |
6 actually, for audio decompression only the following functions | |
7 are needed: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
8 |
1 | 9 acmStreamOpen ( takes formats of src and dest, returns stream handle ) |
10 acmStreamPrepareHeader ( takes stream handler and info on data ) | |
11 acmStreamConvert ( the same as PrepareHeader ) | |
12 acmStreamUnprepareHeader | |
13 acmStreamClose | |
14 acmStreamSize | |
15 maybe acmStreamReset | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
16 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
17 In future I'll also add functions for format enumeration, |
1 | 18 but not right now. |
19 | |
18783 | 20 Modified for use with MPlayer, detailed changelog at |
21 http://svn.mplayerhq.hu/mplayer/trunk/ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
22 |
1 | 23 ***************************************************************************/ |
2069 | 24 #include "config.h" |
21261
a2e02e6b6379
Rename config.h --> debug.h and include config.h explicitly.
diego
parents:
18878
diff
changeset
|
25 #include "debug.h" |
1 | 26 |
2069 | 27 #include "wine/winbase.h" |
28 #include "wine/windef.h" | |
29 #include "wine/winuser.h" | |
30 #include "wine/vfw.h" | |
31 #include "wine/winestring.h" | |
32 #include "wine/driver.h" | |
33 #include "wine/winerror.h" | |
34 #include "wine/msacm.h" | |
35 #include "wine/msacmdrv.h" | |
1 | 36 #include "wineacm.h" |
9978 | 37 #ifndef __MINGW32__ |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1
diff
changeset
|
38 #include "ext.h" |
9978 | 39 #endif |
26999
0b21ffa03b9c
Rename loader/driver.[ch] to loader/drv.[ch], otherwise loader/driver.h can
diego
parents:
25849
diff
changeset
|
40 #include "drv.h" |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1
diff
changeset
|
41 |
7386 | 42 #include <stdio.h> |
43 #include <stdlib.h> | |
44 #include <string.h> | |
45 #pragma pack(1) | |
1 | 46 #define OpenDriverA DrvOpen |
47 #define CloseDriver DrvClose | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1
diff
changeset
|
48 |
7386 | 49 static inline PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has) |
1 | 50 { |
51 return (PWINE_ACMSTREAM)has; | |
52 } | |
53 | |
54 /*********************************************************************** | |
55 * acmDriverAddA (MSACM32.2) | |
56 */ | |
57 MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule, | |
58 LPARAM lParam, DWORD dwPriority, DWORD fdwAdd) | |
59 { | |
60 if (!phadid) | |
61 return MMSYSERR_INVALPARAM; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
62 |
1 | 63 /* Check if any unknown flags */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
64 if (fdwAdd & |
1 | 65 ~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND| |
66 ACM_DRIVERADDF_GLOBAL)) | |
67 return MMSYSERR_INVALFLAG; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
68 |
1 | 69 /* Check if any incompatible flags */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
70 if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) && |
1 | 71 (fdwAdd & ACM_DRIVERADDF_NOTIFYHWND)) |
72 return MMSYSERR_INVALFLAG; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
73 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
74 /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a |
1 | 75 * LoadDriver on it, to be sure we can call SendDriverMessage on the |
76 * hDrvr handle. | |
77 */ | |
7386 | 78 *phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, 0, hinstModule); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
79 |
1 | 80 /* FIXME: lParam, dwPriority and fdwAdd ignored */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
81 |
1 | 82 return MMSYSERR_NOERROR; |
83 } | |
84 | |
85 /*********************************************************************** | |
86 * acmDriverClose (MSACM32.4) | |
87 */ | |
88 MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose) | |
89 { | |
90 PWINE_ACMDRIVER p; | |
91 PWINE_ACMDRIVER* tp; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
92 |
1 | 93 if (fdwClose) |
94 return MMSYSERR_INVALFLAG; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
95 |
1 | 96 p = MSACM_GetDriver(had); |
97 if (!p) | |
98 return MMSYSERR_INVALHANDLE; | |
99 | |
100 for (tp = &(p->obj.pACMDriverID->pACMDriverList); *tp; *tp = (*tp)->pNextACMDriver) { | |
101 if (*tp == p) { | |
102 *tp = (*tp)->pNextACMDriver; | |
103 break; | |
104 } | |
105 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
106 |
1 | 107 if (p->hDrvr && !p->obj.pACMDriverID->pACMDriverList) |
108 CloseDriver(p->hDrvr); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
109 |
1 | 110 HeapFree(MSACM_hHeap, 0, p); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
111 |
1 | 112 return MMSYSERR_NOERROR; |
113 } | |
114 | |
115 /*********************************************************************** | |
116 * acmDriverEnum (MSACM32.7) | |
117 */ | |
118 MMRESULT WINAPI acmDriverEnum(ACMDRIVERENUMCB fnCallback, DWORD dwInstance, DWORD fdwEnum) | |
119 { | |
120 PWINE_ACMDRIVERID p; | |
121 DWORD fdwSupport; | |
122 | |
123 if (!fnCallback) { | |
124 return MMSYSERR_INVALPARAM; | |
125 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
126 |
1 | 127 if (fdwEnum && ~(ACM_DRIVERENUMF_NOLOCAL|ACM_DRIVERENUMF_DISABLED)) { |
128 return MMSYSERR_INVALFLAG; | |
129 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
130 |
1 | 131 for (p = MSACM_pFirstACMDriverID; p; p = p->pNextACMDriverID) { |
132 fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC; | |
133 if (!p->bEnabled) { | |
134 if (fdwEnum & ACM_DRIVERENUMF_DISABLED) | |
135 fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED; | |
136 else | |
137 continue; | |
138 } | |
139 (*fnCallback)((HACMDRIVERID) p, dwInstance, fdwSupport); | |
140 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
141 |
1 | 142 return MMSYSERR_NOERROR; |
143 } | |
144 | |
145 /*********************************************************************** | |
146 * acmDriverID (MSACM32.8) | |
147 */ | |
148 MMRESULT WINAPI acmDriverID(HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID) | |
149 { | |
150 PWINE_ACMOBJ pao; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
151 |
1 | 152 pao = MSACM_GetObj(hao); |
153 if (!pao) | |
154 return MMSYSERR_INVALHANDLE; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
155 |
1 | 156 if (!phadid) |
157 return MMSYSERR_INVALPARAM; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
158 |
1 | 159 if (fdwDriverID) |
160 return MMSYSERR_INVALFLAG; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
161 |
1 | 162 *phadid = (HACMDRIVERID) pao->pACMDriverID; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
163 |
1 | 164 return MMSYSERR_NOERROR; |
165 } | |
166 | |
167 /*********************************************************************** | |
168 * acmDriverMessage (MSACM32.9) | |
169 * FIXME | |
170 * Not implemented | |
171 */ | |
172 LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2) | |
173 { | |
174 PWINE_ACMDRIVER pad = MSACM_GetDriver(had); | |
175 if (!pad) | |
176 return MMSYSERR_INVALPARAM; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
177 |
1 | 178 /* FIXME: Check if uMsg legal */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
179 |
1 | 180 if (!SendDriverMessage(pad->hDrvr, uMsg, lParam1, lParam2)) |
181 return MMSYSERR_NOTSUPPORTED; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
182 |
1 | 183 return MMSYSERR_NOERROR; |
184 } | |
185 | |
186 | |
187 /*********************************************************************** | |
188 * acmDriverOpen (MSACM32.10) | |
189 */ | |
190 MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen) | |
191 { | |
192 PWINE_ACMDRIVERID padid; | |
193 PWINE_ACMDRIVER pad; | |
194 ICOPEN icopen; | |
195 | |
196 | |
197 TRACE("(%p, %x, %08lu)\n", phad, hadid, fdwOpen); | |
198 | |
199 if (!phad) | |
200 return MMSYSERR_INVALPARAM; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
201 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
202 padid = MSACM_GetDriverID(hadid); |
1 | 203 if (!padid) |
204 return MMSYSERR_INVALHANDLE; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
205 |
1 | 206 if (fdwOpen) |
207 return MMSYSERR_INVALFLAG; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
208 |
7386 | 209 pad = (PWINE_ACMDRIVER) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER)); |
210 if (!pad) | |
211 return MMSYSERR_NOMEM; | |
1 | 212 |
213 pad->obj.pACMDriverID = padid; | |
214 icopen.fccType = mmioFOURCC('a', 'u', 'd', 'c'); | |
215 icopen.fccHandler = (long)padid->pszFileName; | |
216 icopen.dwSize = sizeof(ICOPEN); | |
217 icopen.dwFlags = 0; | |
218 | |
7386 | 219 icopen.pV1Reserved = padid->pszFileName; |
220 if (!padid->hInstModule) | |
1 | 221 pad->hDrvr = OpenDriverA((long)&icopen); |
222 else | |
223 pad->hDrvr = padid->hInstModule; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
224 |
1 | 225 if (!pad->hDrvr) { |
226 HeapFree(MSACM_hHeap, 0, pad); | |
227 return MMSYSERR_ERROR; | |
228 } | |
7386 | 229 |
1 | 230 pad->pfnDriverProc = GetProcAddress(pad->hDrvr, "DriverProc"); |
231 | |
232 /* insert new pad at beg of list */ | |
233 pad->pNextACMDriver = padid->pACMDriverList; | |
234 padid->pACMDriverList = pad; | |
235 | |
236 /* FIXME: Create a WINE_ACMDRIVER32 */ | |
237 *phad = (HACMDRIVER)pad; | |
7386 | 238 |
1 | 239 return MMSYSERR_NOERROR; |
240 } | |
241 | |
242 /*********************************************************************** | |
243 * acmDriverRemove (MSACM32.12) | |
244 */ | |
245 MMRESULT WINAPI acmDriverRemove(HACMDRIVERID hadid, DWORD fdwRemove) | |
246 { | |
247 PWINE_ACMDRIVERID padid; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
248 |
1 | 249 padid = MSACM_GetDriverID(hadid); |
250 if (!padid) | |
251 return MMSYSERR_INVALHANDLE; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
252 |
1 | 253 if (fdwRemove) |
254 return MMSYSERR_INVALFLAG; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
255 |
1 | 256 MSACM_UnregisterDriver(padid); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
257 |
1 | 258 return MMSYSERR_NOERROR; |
259 } | |
260 | |
261 | |
262 | |
263 /**********************************************************************/ | |
264 | |
265 HANDLE MSACM_hHeap = (HANDLE) NULL; | |
266 PWINE_ACMDRIVERID MSACM_pFirstACMDriverID = NULL; | |
267 PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL; | |
268 | |
269 /*********************************************************************** | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
270 * MSACM_RegisterDriver32() |
1 | 271 */ |
7386 | 272 PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName, |
273 WORD wFormatTag, | |
1 | 274 HINSTANCE hinstModule) |
7386 | 275 { |
1 | 276 PWINE_ACMDRIVERID padid; |
277 | |
7386 | 278 TRACE("('%s', '%x', 0x%08x)\n", pszFileName, wFormatTag, hinstModule); |
1 | 279 |
9961 | 280 #ifndef WIN32_LOADER |
281 MSACM_hHeap = GetProcessHeap(); | |
282 #endif | |
1 | 283 padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID)); |
18878 | 284 padid->pszFileName = malloc(strlen(pszFileName)+1); |
7386 | 285 strcpy(padid->pszFileName, pszFileName); |
1 | 286 // 1~strdup(pszDriverAlias); |
7386 | 287 padid->wFormatTag = wFormatTag; |
1 | 288 padid->hInstModule = hinstModule; |
289 padid->bEnabled = TRUE; | |
290 padid->pACMDriverList = NULL; | |
291 padid->pNextACMDriverID = NULL; | |
292 padid->pPrevACMDriverID = MSACM_pLastACMDriverID; | |
293 if (MSACM_pLastACMDriverID) | |
294 MSACM_pLastACMDriverID->pNextACMDriverID = padid; | |
295 MSACM_pLastACMDriverID = padid; | |
296 if (!MSACM_pFirstACMDriverID) | |
297 MSACM_pFirstACMDriverID = padid; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
298 |
1 | 299 return padid; |
300 } | |
301 | |
302 | |
303 /*********************************************************************** | |
304 * MSACM_UnregisterDriver32() | |
305 */ | |
306 PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p) | |
307 { | |
308 PWINE_ACMDRIVERID pNextACMDriverID; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
309 |
1 | 310 while (p->pACMDriverList) |
311 acmDriverClose((HACMDRIVER) p->pACMDriverList, 0); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
312 |
7386 | 313 if (p->pszFileName) |
314 free(p->pszFileName); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
315 |
1 | 316 if (p == MSACM_pFirstACMDriverID) |
317 MSACM_pFirstACMDriverID = p->pNextACMDriverID; | |
318 if (p == MSACM_pLastACMDriverID) | |
319 MSACM_pLastACMDriverID = p->pPrevACMDriverID; | |
320 | |
321 if (p->pPrevACMDriverID) | |
322 p->pPrevACMDriverID->pNextACMDriverID = p->pNextACMDriverID; | |
323 if (p->pNextACMDriverID) | |
324 p->pNextACMDriverID->pPrevACMDriverID = p->pPrevACMDriverID; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
325 |
1 | 326 pNextACMDriverID = p->pNextACMDriverID; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
327 |
1 | 328 HeapFree(MSACM_hHeap, 0, p); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
329 |
1 | 330 return pNextACMDriverID; |
331 } | |
332 | |
333 /*********************************************************************** | |
334 * MSACM_UnregisterAllDrivers32() | |
335 * FIXME | |
336 * Where should this function be called? | |
337 */ | |
338 void MSACM_UnregisterAllDrivers(void) | |
339 { | |
340 PWINE_ACMDRIVERID p; | |
341 | |
342 for (p = MSACM_pFirstACMDriverID; p; p = MSACM_UnregisterDriver(p)); | |
343 } | |
344 | |
345 /*********************************************************************** | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
346 * MSACM_GetDriverID32() |
1 | 347 */ |
348 PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID) | |
349 { | |
350 return (PWINE_ACMDRIVERID)hDriverID; | |
351 } | |
352 | |
353 /*********************************************************************** | |
354 * MSACM_GetDriver32() | |
355 */ | |
356 PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver) | |
357 { | |
358 return (PWINE_ACMDRIVER)hDriver; | |
359 } | |
360 | |
361 /*********************************************************************** | |
362 * MSACM_GetObj32() | |
363 */ | |
364 PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj) | |
365 { | |
366 return (PWINE_ACMOBJ)hObj; | |
367 } | |
368 | |
369 | |
370 | |
371 /*********************************************************************** | |
372 * acmStreamOpen (MSACM32.40) | |
373 */ | |
374 MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pwfxSrc, | |
375 PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD dwCallback, | |
376 DWORD dwInstance, DWORD fdwOpen) | |
377 { | |
378 PWINE_ACMSTREAM was; | |
379 PWINE_ACMDRIVER wad; | |
380 MMRESULT ret; | |
381 int wfxSrcSize; | |
382 int wfxDstSize; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
383 |
1 | 384 TRACE("(%p, 0x%08x, %p, %p, %p, %ld, %ld, %ld)\n", |
385 phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen); | |
386 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
387 TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
388 pwfxSrc->wFormatTag, pwfxSrc->nChannels, pwfxSrc->nSamplesPerSec, pwfxSrc->nAvgBytesPerSec, |
1 | 389 pwfxSrc->nBlockAlign, pwfxSrc->wBitsPerSample, pwfxSrc->cbSize); |
390 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
391 TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
392 pwfxDst->wFormatTag, pwfxDst->nChannels, pwfxDst->nSamplesPerSec, pwfxDst->nAvgBytesPerSec, |
1 | 393 pwfxDst->nBlockAlign, pwfxDst->wBitsPerSample, pwfxDst->cbSize); |
394 | |
395 #define SIZEOF_WFX(wfx) (sizeof(WAVEFORMATEX) + ((wfx->wFormatTag == WAVE_FORMAT_PCM) ? 0 : wfx->cbSize)) | |
396 wfxSrcSize = SIZEOF_WFX(pwfxSrc); | |
397 wfxDstSize = SIZEOF_WFX(pwfxDst); | |
398 #undef SIZEOF_WFX | |
399 | |
7386 | 400 was = (PWINE_ACMSTREAM) HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0)); |
1 | 401 if (was == NULL) |
402 return MMSYSERR_NOMEM; | |
403 was->drvInst.cbStruct = sizeof(was->drvInst); | |
404 was->drvInst.pwfxSrc = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was)); | |
405 memcpy(was->drvInst.pwfxSrc, pwfxSrc, wfxSrcSize); | |
7386 | 406 // LHACM is checking for 0x1 |
407 // but if this will not help | |
408 // was->drvInst.pwfxSrc->wFormatTag = 1; | |
1 | 409 was->drvInst.pwfxDst = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was) + wfxSrcSize); |
410 memcpy(was->drvInst.pwfxDst, pwfxDst, wfxDstSize); | |
411 if (pwfltr) { | |
412 was->drvInst.pwfltr = (PWAVEFILTER)((LPSTR)was + sizeof(*was) + wfxSrcSize + wfxDstSize); | |
413 memcpy(was->drvInst.pwfltr, pwfltr, sizeof(WAVEFILTER)); | |
414 } else { | |
415 was->drvInst.pwfltr = NULL; | |
416 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
417 was->drvInst.dwCallback = dwCallback; |
1 | 418 was->drvInst.dwInstance = dwInstance; |
419 was->drvInst.fdwOpen = fdwOpen; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
420 was->drvInst.fdwDriver = 0L; |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
421 was->drvInst.dwDriver = 0L; |
1 | 422 was->drvInst.has = (HACMSTREAM)was; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
423 |
1 | 424 if (had) { |
425 if (!(wad = MSACM_GetDriver(had))) { | |
426 ret = MMSYSERR_INVALPARAM; | |
427 goto errCleanUp; | |
428 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
429 |
1 | 430 was->obj.pACMDriverID = wad->obj.pACMDriverID; |
431 was->pDrv = wad; | |
432 was->hAcmDriver = 0; /* not to close it in acmStreamClose */ | |
433 | |
434 ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L); | |
435 if (ret != MMSYSERR_NOERROR) | |
436 goto errCleanUp; | |
437 } else { | |
438 PWINE_ACMDRIVERID wadi; | |
24380 | 439 //short drv_tag; |
1 | 440 ret = ACMERR_NOTPOSSIBLE; |
441 /* if(pwfxSrc->wFormatTag==1)//compression | |
442 drv_tag=pwfxDst->wFormatTag; | |
443 else | |
444 if(pwfxDst->wFormatTag==1)//decompression | |
445 drv_tag=pwfxSrc->wFormatTag; | |
446 else | |
447 goto errCleanUp; | |
448 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
449 ret=acmDriverOpen2(drv_tag); |
1 | 450 if (ret == MMSYSERR_NOERROR) { |
451 if ((wad = MSACM_GetDriver(had)) != 0) { | |
452 was->obj.pACMDriverID = wad->obj.pACMDriverID; | |
453 was->pDrv = wad; | |
454 was->hAcmDriver = had; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
455 |
1 | 456 ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L); |
457 if (ret == MMSYSERR_NOERROR) { | |
458 if (fdwOpen & ACM_STREAMOPENF_QUERY) { | |
459 acmDriverClose(had, 0L); | |
460 } | |
461 break; | |
462 } | |
463 } | |
464 acmDriverClose(had, 0L);*/ | |
7386 | 465 //if(MSACM_pFirstACMDriverID==NULL) |
466 // MSACM_RegisterAllDrivers(); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
467 |
7386 | 468 for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID) |
469 { | |
470 /* Check Format */ | |
471 if ((int)wadi->wFormatTag != (int)pwfxSrc->wFormatTag) continue; | |
472 | |
1 | 473 ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L); |
474 if (ret == MMSYSERR_NOERROR) { | |
475 if ((wad = MSACM_GetDriver(had)) != 0) { | |
476 was->obj.pACMDriverID = wad->obj.pACMDriverID; | |
477 was->pDrv = wad; | |
478 was->hAcmDriver = had; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
479 |
1 | 480 ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L); |
7386 | 481 //lhacm - crash printf("RETOPEN %d\n", ret); |
482 //ret = 0; | |
1 | 483 if (ret == MMSYSERR_NOERROR) { |
484 if (fdwOpen & ACM_STREAMOPENF_QUERY) { | |
485 acmDriverClose(had, 0L); | |
486 } | |
487 break; | |
488 } | |
489 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
490 // no match, close this acm driver and try next one |
1 | 491 acmDriverClose(had, 0L); |
492 } | |
493 } | |
494 if (ret != MMSYSERR_NOERROR) { | |
495 ret = ACMERR_NOTPOSSIBLE; | |
496 goto errCleanUp; | |
497 } | |
498 } | |
499 ret = MMSYSERR_NOERROR; | |
500 if (!(fdwOpen & ACM_STREAMOPENF_QUERY)) { | |
501 if (phas) | |
502 *phas = (HACMSTREAM)was; | |
503 TRACE("=> (%d)\n", ret); | |
9961 | 504 #ifdef WIN32_LOADER |
7386 | 505 CodecAlloc(); |
9961 | 506 #endif |
1 | 507 return ret; |
508 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
509 errCleanUp: |
1 | 510 if (phas) |
511 *phas = (HACMSTREAM)0; | |
512 HeapFree(MSACM_hHeap, 0, was); | |
513 TRACE("=> (%d)\n", ret); | |
514 return ret; | |
515 } | |
516 | |
517 | |
518 MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose) | |
519 { | |
520 PWINE_ACMSTREAM was; | |
521 MMRESULT ret; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
522 |
1 | 523 TRACE("(0x%08x, %ld)\n", has, fdwClose); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
524 |
1 | 525 if ((was = ACM_GetStream(has)) == NULL) { |
526 return MMSYSERR_INVALHANDLE; | |
527 } | |
528 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CLOSE, (DWORD)&was->drvInst, 0); | |
529 if (ret == MMSYSERR_NOERROR) { | |
530 if (was->hAcmDriver) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
531 acmDriverClose(was->hAcmDriver, 0L); |
1 | 532 HeapFree(MSACM_hHeap, 0, was); |
9961 | 533 #ifdef WIN32_LOADER |
7386 | 534 CodecRelease(); |
9961 | 535 #endif |
1 | 536 } |
537 TRACE("=> (%d)\n", ret); | |
538 return ret; | |
539 } | |
540 | |
541 /*********************************************************************** | |
542 * acmStreamConvert (MSACM32.38) | |
543 */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
544 MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash, |
1 | 545 DWORD fdwConvert) |
546 { | |
547 PWINE_ACMSTREAM was; | |
548 MMRESULT ret = MMSYSERR_NOERROR; | |
549 PACMDRVSTREAMHEADER padsh; | |
550 | |
551 TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwConvert); | |
7386 | 552 |
1 | 553 if ((was = ACM_GetStream(has)) == NULL) |
554 return MMSYSERR_INVALHANDLE; | |
555 if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) | |
556 return MMSYSERR_INVALPARAM; | |
557 | |
558 if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED)) | |
559 return ACMERR_UNPREPARED; | |
560 | |
561 /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same | |
562 * size. some fields are private to msacm internals, and are exposed | |
563 * in ACMSTREAMHEADER in the dwReservedDriver array | |
564 */ | |
565 padsh = (PACMDRVSTREAMHEADER)pash; | |
566 | |
567 /* check that pointers have not been modified */ | |
568 if (padsh->pbPreparedSrc != padsh->pbSrc || | |
569 padsh->cbPreparedSrcLength < padsh->cbSrcLength || | |
570 padsh->pbPreparedDst != padsh->pbDst || | |
571 padsh->cbPreparedDstLength < padsh->cbDstLength) { | |
572 return MMSYSERR_INVALPARAM; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
573 } |
1 | 574 |
575 padsh->fdwConvert = fdwConvert; | |
576 | |
577 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CONVERT, (DWORD)&was->drvInst, (DWORD)padsh); | |
578 if (ret == MMSYSERR_NOERROR) { | |
579 padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_DONE; | |
580 } | |
581 TRACE("=> (%d)\n", ret); | |
582 return ret; | |
583 } | |
584 | |
585 | |
586 /*********************************************************************** | |
587 * acmStreamPrepareHeader (MSACM32.41) | |
588 */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
589 MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, |
1 | 590 DWORD fdwPrepare) |
591 { | |
592 PWINE_ACMSTREAM was; | |
593 MMRESULT ret = MMSYSERR_NOERROR; | |
594 PACMDRVSTREAMHEADER padsh; | |
595 | |
596 TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwPrepare); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
597 |
1 | 598 if ((was = ACM_GetStream(has)) == NULL) |
599 return MMSYSERR_INVALHANDLE; | |
600 if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) | |
601 return MMSYSERR_INVALPARAM; | |
602 if (fdwPrepare) | |
603 ret = MMSYSERR_INVALFLAG; | |
604 | |
605 if (pash->fdwStatus & ACMSTREAMHEADER_STATUSF_DONE) | |
606 return MMSYSERR_NOERROR; | |
607 | |
608 /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same | |
609 * size. some fields are private to msacm internals, and are exposed | |
610 * in ACMSTREAMHEADER in the dwReservedDriver array | |
611 */ | |
612 padsh = (PACMDRVSTREAMHEADER)pash; | |
613 | |
614 padsh->fdwConvert = fdwPrepare; | |
615 padsh->padshNext = NULL; | |
616 padsh->fdwDriver = padsh->dwDriver = 0L; | |
617 | |
618 padsh->fdwPrepared = 0; | |
619 padsh->dwPrepared = 0; | |
620 padsh->pbPreparedSrc = 0; | |
621 padsh->cbPreparedSrcLength = 0; | |
622 padsh->pbPreparedDst = 0; | |
623 padsh->cbPreparedDstLength = 0; | |
624 | |
625 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_PREPARE, (DWORD)&was->drvInst, (DWORD)padsh); | |
626 if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) { | |
627 ret = MMSYSERR_NOERROR; | |
628 padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE); | |
629 padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_PREPARED; | |
630 padsh->fdwPrepared = padsh->fdwStatus; | |
631 padsh->dwPrepared = 0; | |
632 padsh->pbPreparedSrc = padsh->pbSrc; | |
633 padsh->cbPreparedSrcLength = padsh->cbSrcLength; | |
634 padsh->pbPreparedDst = padsh->pbDst; | |
635 padsh->cbPreparedDstLength = padsh->cbDstLength; | |
636 } else { | |
637 padsh->fdwPrepared = 0; | |
638 padsh->dwPrepared = 0; | |
639 padsh->pbPreparedSrc = 0; | |
640 padsh->cbPreparedSrcLength = 0; | |
641 padsh->pbPreparedDst = 0; | |
642 padsh->cbPreparedDstLength = 0; | |
643 } | |
644 TRACE("=> (%d)\n", ret); | |
645 return ret; | |
646 } | |
647 | |
648 /*********************************************************************** | |
649 * acmStreamReset (MSACM32.42) | |
650 */ | |
651 MMRESULT WINAPI acmStreamReset(HACMSTREAM has, DWORD fdwReset) | |
652 { | |
653 PWINE_ACMSTREAM was; | |
654 MMRESULT ret = MMSYSERR_NOERROR; | |
655 | |
656 TRACE("(0x%08x, %ld)\n", has, fdwReset); | |
657 | |
658 if (fdwReset) { | |
659 ret = MMSYSERR_INVALFLAG; | |
660 } else if ((was = ACM_GetStream(has)) == NULL) { | |
661 return MMSYSERR_INVALHANDLE; | |
662 } else if (was->drvInst.fdwOpen & ACM_STREAMOPENF_ASYNC) { | |
663 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_RESET, (DWORD)&was->drvInst, 0); | |
664 } | |
665 TRACE("=> (%d)\n", ret); | |
666 return ret; | |
667 } | |
668 | |
669 /*********************************************************************** | |
670 * acmStreamSize (MSACM32.43) | |
671 */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
672 MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput, |
1 | 673 LPDWORD pdwOutputBytes, DWORD fdwSize) |
674 { | |
675 PWINE_ACMSTREAM was; | |
676 ACMDRVSTREAMSIZE adss; | |
677 MMRESULT ret; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
678 |
1 | 679 TRACE("(0x%08x, %ld, %p, %ld)\n", has, cbInput, pdwOutputBytes, fdwSize); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
680 |
1 | 681 if ((was = ACM_GetStream(has)) == NULL) { |
682 return MMSYSERR_INVALHANDLE; | |
683 } | |
684 if ((fdwSize & ~ACM_STREAMSIZEF_QUERYMASK) != 0) { | |
685 return MMSYSERR_INVALFLAG; | |
686 } | |
687 | |
688 *pdwOutputBytes = 0L; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
689 |
1 | 690 switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) { |
691 case ACM_STREAMSIZEF_DESTINATION: | |
692 adss.cbDstLength = cbInput; | |
693 adss.cbSrcLength = 0; | |
694 break; | |
695 case ACM_STREAMSIZEF_SOURCE: | |
696 adss.cbSrcLength = cbInput; | |
697 adss.cbDstLength = 0; | |
698 break; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
699 default: |
1 | 700 return MMSYSERR_INVALFLAG; |
701 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
702 |
1 | 703 adss.cbStruct = sizeof(adss); |
704 adss.fdwSize = fdwSize; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
705 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_SIZE, |
1 | 706 (DWORD)&was->drvInst, (DWORD)&adss); |
707 if (ret == MMSYSERR_NOERROR) { | |
708 switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) { | |
709 case ACM_STREAMSIZEF_DESTINATION: | |
710 *pdwOutputBytes = adss.cbSrcLength; | |
711 break; | |
712 case ACM_STREAMSIZEF_SOURCE: | |
713 *pdwOutputBytes = adss.cbDstLength; | |
714 break; | |
715 } | |
716 } | |
717 TRACE("=> (%d) [%lu]\n", ret, *pdwOutputBytes); | |
718 return ret; | |
719 } | |
720 | |
721 /*********************************************************************** | |
722 * acmStreamUnprepareHeader (MSACM32.44) | |
723 */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
724 MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, |
1 | 725 DWORD fdwUnprepare) |
726 { | |
727 PWINE_ACMSTREAM was; | |
728 MMRESULT ret = MMSYSERR_NOERROR; | |
729 PACMDRVSTREAMHEADER padsh; | |
730 | |
731 TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwUnprepare); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
732 |
1 | 733 if ((was = ACM_GetStream(has)) == NULL) |
734 return MMSYSERR_INVALHANDLE; | |
735 if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) | |
736 return MMSYSERR_INVALPARAM; | |
737 | |
738 if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED)) | |
739 return ACMERR_UNPREPARED; | |
740 | |
741 /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same | |
742 * size. some fields are private to msacm internals, and are exposed | |
743 * in ACMSTREAMHEADER in the dwReservedDriver array | |
744 */ | |
745 padsh = (PACMDRVSTREAMHEADER)pash; | |
746 | |
747 /* check that pointers have not been modified */ | |
748 if (padsh->pbPreparedSrc != padsh->pbSrc || | |
749 padsh->cbPreparedSrcLength < padsh->cbSrcLength || | |
750 padsh->pbPreparedDst != padsh->pbDst || | |
751 padsh->cbPreparedDstLength < padsh->cbDstLength) { | |
752 return MMSYSERR_INVALPARAM; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26999
diff
changeset
|
753 } |
1 | 754 |
755 padsh->fdwConvert = fdwUnprepare; | |
756 | |
757 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_UNPREPARE, (DWORD)&was->drvInst, (DWORD)padsh); | |
758 if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) { | |
759 ret = MMSYSERR_NOERROR; | |
760 padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE|ACMSTREAMHEADER_STATUSF_PREPARED); | |
761 } | |
762 TRACE("=> (%d)\n", ret); | |
763 return ret; | |
764 } |