1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1998 Patrik Stridvall
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msacm);
39 /***********************************************************************
40 * acmFilterChooseA (MSACM32.@)
42 MMRESULT WINAPI acmFilterChooseA(PACMFILTERCHOOSEA pafltrc)
44 FIXME("(%p): stub\n", pafltrc);
45 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
46 return MMSYSERR_ERROR;
49 /***********************************************************************
50 * acmFilterChooseW (MSACM32.@)
52 MMRESULT WINAPI acmFilterChooseW(PACMFILTERCHOOSEW pafltrc)
54 FIXME("(%p): stub\n", pafltrc);
55 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
56 return MMSYSERR_ERROR;
59 /***********************************************************************
60 * acmFilterDetailsA (MSACM32.@)
62 MMRESULT WINAPI acmFilterDetailsA(HACMDRIVER had, PACMFILTERDETAILSA pafd,
65 ACMFILTERDETAILSW afdw;
68 memset(&afdw, 0, sizeof(afdw));
69 afdw.cbStruct = sizeof(afdw);
70 afdw.dwFilterIndex = pafd->dwFilterIndex;
71 afdw.dwFilterTag = pafd->dwFilterTag;
72 afdw.pwfltr = pafd->pwfltr;
73 afdw.cbwfltr = pafd->cbwfltr;
75 mmr = acmFilterDetailsW(had, &afdw, fdwDetails);
76 if (mmr == MMSYSERR_NOERROR) {
77 pafd->dwFilterTag = afdw.dwFilterTag;
78 pafd->fdwSupport = afdw.fdwSupport;
79 WideCharToMultiByte( CP_ACP, 0, afdw.szFilter, -1, pafd->szFilter,
80 sizeof(pafd->szFilter), NULL, NULL );
85 /***********************************************************************
86 * acmFilterDetailsW (MSACM32.@)
88 MMRESULT WINAPI acmFilterDetailsW(HACMDRIVER had, PACMFILTERDETAILSW pafd,
92 ACMFILTERTAGDETAILSA aftd;
94 TRACE("(%p, %p, %d)\n", had, pafd, fdwDetails);
96 memset(&aftd, 0, sizeof(aftd));
97 aftd.cbStruct = sizeof(aftd);
99 if (pafd->cbStruct < sizeof(*pafd)) return MMSYSERR_INVALPARAM;
101 switch (fdwDetails) {
102 case ACM_FILTERDETAILSF_FILTER:
103 if (pafd->dwFilterTag != pafd->pwfltr->dwFilterTag) {
104 mmr = MMSYSERR_INVALPARAM;
108 PWINE_ACMDRIVERID padid;
110 mmr = ACMERR_NOTPOSSIBLE;
111 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
112 /* should check for codec only */
113 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
114 acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
115 mmr = MSACM_Message(had, ACMDM_FILTER_DETAILS,
116 (LPARAM)pafd, (LPARAM)fdwDetails);
117 acmDriverClose(had, 0);
118 if (mmr == MMSYSERR_NOERROR) break;
122 mmr = MSACM_Message(had, ACMDM_FILTER_DETAILS, (LPARAM)pafd, fdwDetails);
125 case ACM_FILTERDETAILSF_INDEX:
126 /* should check pafd->dwFilterIndex < aftd->cStandardFilters */
127 mmr = MSACM_Message(had, ACMDM_FILTER_DETAILS, (LPARAM)pafd, fdwDetails);
130 WARN("Unknown fdwDetails %08x\n", fdwDetails);
131 mmr = MMSYSERR_INVALFLAG;
135 TRACE("=> %d\n", mmr);
139 struct MSACM_FilterEnumWtoA_Instance {
140 PACMFILTERDETAILSA pafda;
142 ACMFILTERENUMCBA fnCallback;
145 static BOOL CALLBACK MSACM_FilterEnumCallbackWtoA(HACMDRIVERID hadid,
146 PACMFILTERDETAILSW pafdw,
147 DWORD_PTR dwInstance,
150 struct MSACM_FilterEnumWtoA_Instance* pafei;
152 pafei = (struct MSACM_FilterEnumWtoA_Instance*)dwInstance;
154 pafei->pafda->dwFilterIndex = pafdw->dwFilterIndex;
155 pafei->pafda->dwFilterTag = pafdw->dwFilterTag;
156 pafei->pafda->fdwSupport = pafdw->fdwSupport;
157 WideCharToMultiByte( CP_ACP, 0, pafdw->szFilter, -1, pafei->pafda->szFilter,
158 sizeof(pafei->pafda->szFilter), NULL, NULL );
160 return (pafei->fnCallback)(hadid, pafei->pafda,
161 pafei->dwInstance, fdwSupport);
164 /***********************************************************************
165 * acmFilterEnumA (MSACM32.@)
167 MMRESULT WINAPI acmFilterEnumA(HACMDRIVER had, PACMFILTERDETAILSA pafda,
168 ACMFILTERENUMCBA fnCallback,
169 DWORD_PTR dwInstance, DWORD fdwEnum)
171 ACMFILTERDETAILSW afdw;
172 struct MSACM_FilterEnumWtoA_Instance afei;
174 memset(&afdw, 0, sizeof(afdw));
175 afdw.cbStruct = sizeof(afdw);
176 afdw.dwFilterIndex = pafda->dwFilterIndex;
177 afdw.dwFilterTag = pafda->dwFilterTag;
178 afdw.pwfltr = pafda->pwfltr;
179 afdw.cbwfltr = pafda->cbwfltr;
182 afei.dwInstance = dwInstance;
183 afei.fnCallback = fnCallback;
185 return acmFilterEnumW(had, &afdw, MSACM_FilterEnumCallbackWtoA,
186 (DWORD)&afei, fdwEnum);
189 static BOOL MSACM_FilterEnumHelper(PWINE_ACMDRIVERID padid, HACMDRIVER had,
190 PACMFILTERDETAILSW pafd,
191 ACMFILTERENUMCBW fnCallback, DWORD dwInstance,
194 ACMFILTERTAGDETAILSW aftd;
197 for (i = 0; i < padid->cFilterTags; i++) {
198 memset(&aftd, 0, sizeof(aftd));
199 aftd.cbStruct = sizeof(aftd);
200 aftd.dwFilterTagIndex = i;
201 if (acmFilterTagDetailsW(had, &aftd, ACM_FILTERTAGDETAILSF_INDEX) != MMSYSERR_NOERROR)
204 if ((fdwEnum & ACM_FILTERENUMF_DWFILTERTAG) &&
205 aftd.dwFilterTag != pafd->pwfltr->dwFilterTag)
208 for (j = 0; j < aftd.cStandardFilters; j++) {
209 pafd->dwFilterIndex = j;
210 pafd->dwFilterTag = aftd.dwFilterTag;
211 if (acmFilterDetailsW(had, pafd, ACM_FILTERDETAILSF_INDEX) != MMSYSERR_NOERROR)
214 if (!(fnCallback)((HACMDRIVERID)padid, pafd, dwInstance, padid->fdwSupport))
221 /***********************************************************************
222 * acmFilterEnumW (MSACM32.@)
224 MMRESULT WINAPI acmFilterEnumW(HACMDRIVER had, PACMFILTERDETAILSW pafd,
225 ACMFILTERENUMCBW fnCallback,
226 DWORD_PTR dwInstance, DWORD fdwEnum)
228 PWINE_ACMDRIVERID padid;
231 TRACE("(%p, %p, %p, %ld, %d)\n",
232 had, pafd, fnCallback, dwInstance, fdwEnum);
234 if (pafd->cbStruct < sizeof(*pafd)) return MMSYSERR_INVALPARAM;
236 if (fdwEnum & ~(ACM_FILTERENUMF_DWFILTERTAG))
237 FIXME("Unsupported fdwEnum values\n");
242 if (acmDriverID((HACMOBJ)had, &hadid, 0) != MMSYSERR_NOERROR)
243 return MMSYSERR_INVALHANDLE;
244 MSACM_FilterEnumHelper(MSACM_GetDriverID(hadid), had, pafd,
245 fnCallback, dwInstance, fdwEnum);
246 return MMSYSERR_NOERROR;
248 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
249 /* should check for codec only */
250 if ((padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) ||
251 acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != MMSYSERR_NOERROR)
253 ret = MSACM_FilterEnumHelper(padid, had, pafd,
254 fnCallback, dwInstance, fdwEnum);
255 acmDriverClose(had, 0);
258 return MMSYSERR_NOERROR;
261 /***********************************************************************
262 * acmFilterTagDetailsA (MSACM32.@)
264 MMRESULT WINAPI acmFilterTagDetailsA(HACMDRIVER had, PACMFILTERTAGDETAILSA paftda,
267 ACMFILTERTAGDETAILSW aftdw;
270 memset(&aftdw, 0, sizeof(aftdw));
271 aftdw.cbStruct = sizeof(aftdw);
272 aftdw.dwFilterTagIndex = paftda->dwFilterTagIndex;
273 aftdw.dwFilterTag = paftda->dwFilterTag;
275 mmr = acmFilterTagDetailsW(had, &aftdw, fdwDetails);
276 if (mmr == MMSYSERR_NOERROR) {
277 paftda->dwFilterTag = aftdw.dwFilterTag;
278 paftda->dwFilterTagIndex = aftdw.dwFilterTagIndex;
279 paftda->cbFilterSize = aftdw.cbFilterSize;
280 paftda->fdwSupport = aftdw.fdwSupport;
281 paftda->cStandardFilters = aftdw.cStandardFilters;
282 WideCharToMultiByte( CP_ACP, 0, aftdw.szFilterTag, -1, paftda->szFilterTag,
283 sizeof(paftda->szFilterTag), NULL, NULL );
288 /***********************************************************************
289 * acmFilterTagDetailsW (MSACM32.@)
291 MMRESULT WINAPI acmFilterTagDetailsW(HACMDRIVER had, PACMFILTERTAGDETAILSW paftd,
294 PWINE_ACMDRIVERID padid;
297 TRACE("(%p, %p, %d)\n", had, paftd, fdwDetails);
299 if (fdwDetails & ~(ACM_FILTERTAGDETAILSF_FILTERTAG|ACM_FILTERTAGDETAILSF_INDEX|
300 ACM_FILTERTAGDETAILSF_LARGESTSIZE))
301 return MMSYSERR_INVALFLAG;
303 switch (fdwDetails) {
304 case ACM_FILTERTAGDETAILSF_FILTERTAG:
306 mmr = ACMERR_NOTPOSSIBLE;
307 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
308 /* should check for codec only */
309 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
310 acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
311 mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS, (LPARAM)paftd, fdwDetails);
312 acmDriverClose(had, 0);
313 if (mmr == MMSYSERR_NOERROR) break;
317 mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS, (LPARAM)paftd, fdwDetails);
321 case ACM_FILTERTAGDETAILSF_INDEX:
322 /* FIXME should check paftd->dwFilterTagIndex < add.cFilterTags */
323 mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS, (LPARAM)paftd, fdwDetails);
326 case ACM_FILTERTAGDETAILSF_LARGESTSIZE:
328 ACMFILTERTAGDETAILSW tmp;
329 DWORD ft = paftd->dwFilterTag;
331 mmr = ACMERR_NOTPOSSIBLE;
332 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
333 /* should check for codec only */
334 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
335 acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
337 memset(&tmp, 0, sizeof(tmp));
338 tmp.cbStruct = sizeof(tmp);
339 tmp.dwFilterTag = ft;
341 if (MSACM_Message(had, ACMDM_FILTERTAG_DETAILS,
342 (LPARAM)&tmp, fdwDetails) == MMSYSERR_NOERROR) {
343 if (mmr == ACMERR_NOTPOSSIBLE ||
344 paftd->cbFilterSize < tmp.cbFilterSize) {
346 mmr = MMSYSERR_NOERROR;
349 acmDriverClose(had, 0);
353 mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS, (LPARAM)paftd, fdwDetails);
358 WARN("Unsupported fdwDetails=%08x\n", fdwDetails);
359 mmr = MMSYSERR_ERROR;
362 if (mmr == MMSYSERR_NOERROR &&
363 paftd->dwFilterTag == WAVE_FORMAT_PCM && paftd->szFilterTag[0] == 0)
364 MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFilterTag,
365 sizeof(paftd->szFilterTag)/sizeof(WCHAR) );
370 struct MSACM_FilterTagEnumWtoA_Instance {
371 PACMFILTERTAGDETAILSA paftda;
373 ACMFILTERTAGENUMCBA fnCallback;
376 static BOOL CALLBACK MSACM_FilterTagEnumCallbackWtoA(HACMDRIVERID hadid,
377 PACMFILTERTAGDETAILSW paftdw,
378 DWORD_PTR dwInstance,
381 struct MSACM_FilterTagEnumWtoA_Instance* paftei;
383 paftei = (struct MSACM_FilterTagEnumWtoA_Instance*)dwInstance;
385 paftei->paftda->dwFilterTagIndex = paftdw->dwFilterTagIndex;
386 paftei->paftda->dwFilterTag = paftdw->dwFilterTag;
387 paftei->paftda->cbFilterSize = paftdw->cbFilterSize;
388 paftei->paftda->fdwSupport = paftdw->fdwSupport;
389 paftei->paftda->cStandardFilters = paftdw->cStandardFilters;
390 WideCharToMultiByte( CP_ACP, 0, paftdw->szFilterTag, -1, paftei->paftda->szFilterTag,
391 sizeof(paftei->paftda->szFilterTag), NULL, NULL );
393 return (paftei->fnCallback)(hadid, paftei->paftda,
394 paftei->dwInstance, fdwSupport);
397 /***********************************************************************
398 * acmFilterTagEnumA (MSACM32.@)
400 MMRESULT WINAPI acmFilterTagEnumA(HACMDRIVER had, PACMFILTERTAGDETAILSA paftda,
401 ACMFILTERTAGENUMCBA fnCallback,
402 DWORD_PTR dwInstance, DWORD fdwEnum)
404 ACMFILTERTAGDETAILSW aftdw;
405 struct MSACM_FilterTagEnumWtoA_Instance aftei;
407 memset(&aftdw, 0, sizeof(aftdw));
408 aftdw.cbStruct = sizeof(aftdw);
409 aftdw.dwFilterTagIndex = paftda->dwFilterTagIndex;
410 aftdw.dwFilterTag = paftda->dwFilterTag;
412 aftei.paftda = paftda;
413 aftei.dwInstance = dwInstance;
414 aftei.fnCallback = fnCallback;
416 return acmFilterTagEnumW(had, &aftdw, MSACM_FilterTagEnumCallbackWtoA,
417 (DWORD)&aftei, fdwEnum);
420 /***********************************************************************
421 * acmFilterTagEnumW (MSACM32.@)
423 MMRESULT WINAPI acmFilterTagEnumW(HACMDRIVER had, PACMFILTERTAGDETAILSW paftd,
424 ACMFILTERTAGENUMCBW fnCallback,
425 DWORD_PTR dwInstance, DWORD fdwEnum)
427 PWINE_ACMDRIVERID padid;
430 TRACE("(%p, %p, %p, %ld, %d)\n",
431 had, paftd, fnCallback, dwInstance, fdwEnum);
433 if (paftd->cbStruct < sizeof(*paftd)) return MMSYSERR_INVALPARAM;
435 if (had) FIXME("had != NULL, not supported\n");
437 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
438 /* should check for codec only */
439 if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
440 acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == MMSYSERR_NOERROR) {
442 for (i = 0; i < padid->cFilterTags; i++) {
443 paftd->dwFilterTagIndex = i;
444 if (acmFilterTagDetailsW(had, paftd, ACM_FILTERTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) {
445 if (!(fnCallback)((HACMDRIVERID)padid, paftd, dwInstance, padid->fdwSupport)) {
452 acmDriverClose(had, 0);
454 return MMSYSERR_NOERROR;