Enjoy,
Waldeck
PS: Eric: To preserve conciseness, I broke down that controversial patch into two parts, each one affecting a single source-code file. As you acknoledged this one seems to be correct. :-)
Index: wine/dlls/msacm/format.c =================================================================== RCS file: /home/wine/wine/dlls/msacm/format.c,v retrieving revision 1.20 diff -u -p -r1.20 format.c --- wine/dlls/msacm/format.c 2 Dec 2002 18:10:59 -0000 1.20 +++ wine/dlls/msacm/format.c 20 Jan 2003 20:02:45 -0000 @@ -758,36 +758,74 @@ MMRESULT WINAPI acmFormatTagEnumW(HACMDR if (paftd->cbStruct < sizeof(*paftd)) return MMSYSERR_INVALPARAM; - if (had) FIXME("had != NULL, not supported\n"); + /* (WS) MSDN info page says that if had != 0, then we should find + * the specific driver to get its tags from. Therefore I'm removing + * the FIXME call and adding a search block below. It also seems + * that the lack of this functionality was the responsible for + * codecs to be multiply and incorrectly listed. + */ + + /* if (had) FIXME("had != NULL, not supported\n"); */ + + if (had) { + + if (acmDriverID((HACMOBJ)had, (HACMDRIVERID *)&padid, 0) != MMSYSERR_NOERROR) + return MMSYSERR_INVALHANDLE; + + for (i = 0; i < padid->cFormatTags; i++) { + paftd->dwFormatTagIndex = i; + if (MSACM_Message(had, ACMDM_FORMATTAG_DETAILS, + (LPARAM)paftd, ACM_FORMATTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) { + if (paftd->dwFormatTag == WAVE_FORMAT_PCM) { + if (paftd->szFormatTag[0] == 0) + MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFormatTag, + sizeof(paftd->szFormatTag)/sizeof(WCHAR) ); + /* (WS) I'm preserving this PCM hack since it seems to be + * correct. Please notice this block was borrowed from + * below. + */ + if (bPcmDone) continue; + bPcmDone = TRUE; + } + if (!(fnCallback)((HACMDRIVERID)padid, paftd, dwInstance, padid->fdwSupport)) + return MMSYSERR_NOERROR; + } + } - for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { - /* should check for codec only */ - if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && - acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == MMSYSERR_NOERROR) { - for (i = 0; i < padid->cFormatTags; i++) { - paftd->dwFormatTagIndex = i; - if (MSACM_Message(had, ACMDM_FORMATTAG_DETAILS, - (LPARAM)paftd, ACM_FORMATTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) { - if (paftd->dwFormatTag == WAVE_FORMAT_PCM) { - if (paftd->szFormatTag[0] == 0) - MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFormatTag, - sizeof(paftd->szFormatTag)/sizeof(WCHAR) ); - /* FIXME (EPP): I'm not sure this is the correct - * algorithm (should make more sense to apply the same - * for all already loaded formats, but this will do - * for now - */ - if (bPcmDone) continue; - bPcmDone = TRUE; - } - if (!(fnCallback)((HACMDRIVERID)padid, paftd, dwInstance, padid->fdwSupport)) { - acmDriverClose(had, 0); - return MMSYSERR_NOERROR; - } - } - } - } - acmDriverClose(had, 0); + } + + /* if had==0 then search for the first suitable driver */ + else { + for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { + /* should check for codec only */ + if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && + acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == MMSYSERR_NOERROR) { + for (i = 0; i < padid->cFormatTags; i++) { + paftd->dwFormatTagIndex = i; + if (MSACM_Message(had, ACMDM_FORMATTAG_DETAILS, + (LPARAM)paftd, ACM_FORMATTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) { + if (paftd->dwFormatTag == WAVE_FORMAT_PCM) { + if (paftd->szFormatTag[0] == 0) + MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFormatTag, + sizeof(paftd->szFormatTag)/sizeof(WCHAR) ); + /* FIXME (EPP): I'm not sure this is the correct + * algorithm (should make more sense to apply the same + * for all already loaded formats, but this will do + * for now + */ + if (bPcmDone) continue; + bPcmDone = TRUE; + } + if (!(fnCallback)((HACMDRIVERID)padid, paftd, dwInstance, padid->fdwSupport)) { + acmDriverClose(had, 0); + return MMSYSERR_NOERROR; + } + } + } + } + acmDriverClose(had, 0); + } } return MMSYSERR_NOERROR; } +