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