Changeset 6712 for trunk/src/msacm32
- Timestamp:
- Sep 15, 2001, 11:47:44 AM (24 years ago)
- Location:
- trunk/src/msacm32
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/msacm32/driver.c
r6648 r6712 1 1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */ 2 /* $Id: driver.c,v 1.2 2001-09-05 13:11:25 bird Exp $ */ 2 3 3 /* 4 4 * MSACM32 library 5 5 * 6 6 * Copyright 1998 Patrik Stridvall 7 * 1999Eric Pouech7 * 1999 Eric Pouech 8 8 */ 9 9 … … 29 29 30 30 DEFAULT_DEBUG_CHANNEL(msacm); 31 31 32 32 /*********************************************************************** 33 33 * acmDriverAddA (MSACM32.2) 34 34 */ 35 35 MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule, 36 36 LPARAM lParam, DWORD dwPriority, DWORD fdwAdd) 37 37 { 38 38 if (!phadid) 39 40 39 return MMSYSERR_INVALPARAM; 40 41 41 /* Check if any unknown flags */ 42 if (fdwAdd & 43 44 45 46 42 if (fdwAdd & 43 ~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND| 44 ACM_DRIVERADDF_GLOBAL)) 45 return MMSYSERR_INVALFLAG; 46 47 47 /* Check if any incompatible flags */ 48 if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) && 49 50 51 52 /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a 48 if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) && 49 (fdwAdd & ACM_DRIVERADDF_NOTIFYHWND)) 50 return MMSYSERR_INVALFLAG; 51 52 /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a 53 53 * LoadDriver on it, to be sure we can call SendDriverMessage on the 54 54 * hDrvr handle. 55 55 */ 56 56 *phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, NULL, hinstModule); 57 57 58 58 /* FIXME: lParam, dwPriority and fdwAdd ignored */ 59 59 60 60 return MMSYSERR_NOERROR; 61 61 } … … 67 67 */ 68 68 MMRESULT WINAPI acmDriverAddW(PHACMDRIVERID phadid, HINSTANCE hinstModule, 69 69 LPARAM lParam, DWORD dwPriority, DWORD fdwAdd) 70 70 { 71 71 FIXME("(%p, 0x%08x, %ld, %ld, %ld): stub\n", 72 73 72 phadid, hinstModule, lParam, dwPriority, fdwAdd); 73 74 74 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 75 75 return MMSYSERR_ERROR; … … 81 81 MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose) 82 82 { 83 PWINE_ACMDRIVER 84 PWINE_ACMDRIVERID 85 PWINE_ACMDRIVER* 83 PWINE_ACMDRIVER pad; 84 PWINE_ACMDRIVERID padid; 85 PWINE_ACMDRIVER* tpad; 86 86 87 87 if (fdwClose) 88 89 88 return MMSYSERR_INVALFLAG; 89 90 90 pad = MSACM_GetDriver(had); 91 91 if (!pad) 92 92 return MMSYSERR_INVALHANDLE; 93 93 94 94 padid = pad->obj.pACMDriverID; … … 96 96 /* remove driver from list */ 97 97 for (tpad = &(padid->pACMDriverList); *tpad; *tpad = (*tpad)->pNextACMDriver) { 98 99 100 101 102 } 103 98 if (*tpad == pad) { 99 *tpad = (*tpad)->pNextACMDriver; 100 break; 101 } 102 } 103 104 104 /* close driver if it has been opened */ 105 105 if (pad->hDrvr && !padid->hInstModule) 106 107 106 CloseDriver(pad->hDrvr, 0, 0); 107 108 108 HeapFree(MSACM_hHeap, 0, pad); 109 109 110 110 return MMSYSERR_NOERROR; 111 111 } … … 117 117 { 118 118 MMRESULT mmr; 119 ACMDRIVERDETAILSW 120 119 ACMDRIVERDETAILSW addw; 120 121 121 addw.cbStruct = sizeof(addw); 122 122 mmr = acmDriverDetailsW(hadid, &addw, fdwDetails); 123 123 if (mmr == 0) { 124 padd->fccType = addw.fccType; 125 padd->fccComp = addw.fccComp; 126 padd->wMid = addw.wMid; 127 padd->wPid = addw.wPid; 128 padd->vdwACM = addw.vdwACM; 129 padd->vdwDriver = addw.vdwDriver; 130 padd->fdwSupport = addw.fdwSupport; 131 padd->cFormatTags = addw.cFormatTags; 132 padd->cFilterTags = addw.cFilterTags; 133 padd->hicon = addw.hicon; 124 padd->fccType = addw.fccType; 125 padd->fccComp = addw.fccComp; 126 padd->wMid = addw.wMid; 127 padd->wPid = addw.wPid; 128 padd->vdwACM = addw.vdwACM; 129 padd->vdwDriver = addw.vdwDriver; 130 padd->fdwSupport = addw.fdwSupport; 131 padd->cFormatTags = addw.cFormatTags; 132 padd->cFilterTags = addw.cFilterTags; 133 padd->hicon = addw.hicon; 134 134 WideCharToMultiByte( CP_ACP, 0, addw.szShortName, -1, padd->szShortName, 135 135 sizeof(padd->szShortName), NULL, NULL ); … … 153 153 HACMDRIVER acmDrvr; 154 154 MMRESULT mmr; 155 155 156 156 if (fdwDetails) 157 158 157 return MMSYSERR_INVALFLAG; 158 159 159 mmr = acmDriverOpen(&acmDrvr, hadid, 0); 160 160 if (mmr == MMSYSERR_NOERROR) { 161 162 163 164 } 165 161 mmr = (MMRESULT)MSACM_Message(acmDrvr, ACMDM_DRIVER_DETAILS, (LPARAM)padd, 0); 162 163 acmDriverClose(acmDrvr, 0); 164 } 165 166 166 return mmr; 167 167 } … … 172 172 MMRESULT WINAPI acmDriverEnum(ACMDRIVERENUMCB fnCallback, DWORD dwInstance, DWORD fdwEnum) 173 173 { 174 PWINE_ACMDRIVERID 175 ACMDRIVERDETAILSW 174 PWINE_ACMDRIVERID p; 175 ACMDRIVERDETAILSW add; 176 176 177 177 if (!fnCallback) return MMSYSERR_INVALPARAM; 178 178 179 179 if (fdwEnum && ~(ACM_DRIVERENUMF_NOLOCAL|ACM_DRIVERENUMF_DISABLED)) 180 181 180 return MMSYSERR_INVALFLAG; 181 182 182 add.cbStruct = sizeof(add); 183 183 for (p = MSACM_pFirstACMDriverID; p; p = p->pNextACMDriverID) { 184 185 186 187 188 189 190 191 192 193 194 } 195 184 if (acmDriverDetailsW((HACMDRIVERID)p, &add, 0) != MMSYSERR_NOERROR) 185 continue; 186 if (!p->bEnabled) { 187 if (fdwEnum & ACM_DRIVERENUMF_DISABLED) 188 add.fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED; 189 else 190 continue; 191 } 192 if (!(*fnCallback)((HACMDRIVERID)p, dwInstance, add.fdwSupport)) 193 break; 194 } 195 196 196 return MMSYSERR_NOERROR; 197 197 } … … 203 203 { 204 204 PWINE_ACMOBJ pao; 205 205 206 206 if (!phadid) 207 208 207 return MMSYSERR_INVALPARAM; 208 209 209 if (fdwDriverID) 210 211 210 return MMSYSERR_INVALFLAG; 211 212 212 pao = MSACM_GetObj(hao, WINE_ACMOBJ_DONTCARE); 213 213 if (!pao) 214 215 214 return MMSYSERR_INVALHANDLE; 215 216 216 *phadid = (HACMDRIVERID) pao->pACMDriverID; 217 217 218 218 return MMSYSERR_NOERROR; 219 219 } … … 226 226 { 227 227 if ((uMsg >= ACMDM_USER && uMsg < ACMDM_RESERVED_LOW) || 228 229 230 231 228 uMsg == ACMDM_DRIVER_ABOUT || 229 uMsg == DRV_QUERYCONFIGURE || 230 uMsg == DRV_CONFIGURE) 231 return MSACM_Message(had, uMsg, lParam1, lParam2); 232 232 return MMSYSERR_INVALPARAM; 233 233 } … … 239 239 MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen) 240 240 { 241 PWINE_ACMDRIVERID 242 PWINE_ACMDRIVER 241 PWINE_ACMDRIVERID padid; 242 PWINE_ACMDRIVER pad; 243 243 244 244 TRACE("(%p, %x, %08lu)\n", phad, hadid, fdwOpen); 245 245 246 246 if (!phad) 247 248 247 return MMSYSERR_INVALPARAM; 248 249 249 if (fdwOpen) 250 251 252 padid = MSACM_GetDriverID(hadid); 250 return MMSYSERR_INVALFLAG; 251 252 padid = MSACM_GetDriverID(hadid); 253 253 if (!padid) 254 255 254 return MMSYSERR_INVALHANDLE; 255 256 256 pad = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER)); 257 257 if (!pad) return MMSYSERR_NOMEM; … … 259 259 pad->obj.dwType = WINE_ACMOBJ_DRIVER; 260 260 pad->obj.pACMDriverID = padid; 261 261 262 262 if (!(pad->hDrvr = padid->hInstModule) && padid->pszDriverAlias) 263 263 pad->hDrvr = OpenDriverA(padid->pszDriverAlias, NULL, 0); 264 264 if (!pad->hDrvr) { 265 266 265 HeapFree(MSACM_hHeap, 0, pad); 266 return MMSYSERR_ERROR; 267 267 } 268 268 … … 289 289 HKEY hPriorityKey; 290 290 DWORD dwPriorityCounter; 291 291 292 292 padid = MSACM_GetDriverID(hadid); 293 293 if (!padid) 294 295 294 return MMSYSERR_INVALHANDLE; 295 296 296 /* Check for unknown flags */ 297 if (fdwPriority & 298 299 300 301 297 if (fdwPriority & 298 ~(ACM_DRIVERPRIORITYF_ENABLE|ACM_DRIVERPRIORITYF_DISABLE| 299 ACM_DRIVERPRIORITYF_BEGIN|ACM_DRIVERPRIORITYF_END)) 300 return MMSYSERR_INVALFLAG; 301 302 302 /* Check for incompatible flags */ 303 303 if ((fdwPriority & ACM_DRIVERPRIORITYF_ENABLE) && 304 305 306 304 (fdwPriority & ACM_DRIVERPRIORITYF_DISABLE)) 305 return MMSYSERR_INVALFLAG; 306 307 307 /* Check for incompatible flags */ 308 308 if ((fdwPriority & ACM_DRIVERPRIORITYF_BEGIN) && 309 310 311 312 lError = RegOpenKeyA(HKEY_CURRENT_USER, 313 314 315 316 309 (fdwPriority & ACM_DRIVERPRIORITYF_END)) 310 return MMSYSERR_INVALFLAG; 311 312 lError = RegOpenKeyA(HKEY_CURRENT_USER, 313 "Software\\Microsoft\\Multimedia\\" 314 "Audio Compression Manager\\Priority v4.00", 315 &hPriorityKey 316 ); 317 317 /* FIXME: Create key */ 318 318 if (lError != ERROR_SUCCESS) 319 return MMSYSERR_ERROR; 320 321 for (dwPriorityCounter = 1; ; dwPriorityCounter++) { 322 snprintf(szSubKey, 17, "Priorty%ld", dwPriorityCounter); 323 lError = RegQueryValueA(hPriorityKey, szSubKey, szBuffer, &lBufferLength); 324 if (lError != ERROR_SUCCESS) 325 break; 326 327 FIXME("(0x%08x, %ld, %ld): stub (partial)\n", 328 hadid, dwPriority, fdwPriority); 329 break; 330 } 331 332 RegCloseKey(hPriorityKey); 333 319 334 return MMSYSERR_ERROR; 320 321 for (dwPriorityCounter = 1; ; dwPriorityCounter++) {322 snprintf(szSubKey, 17, "Priorty%ld", dwPriorityCounter);323 lError = RegQueryValueA(hPriorityKey, szSubKey, szBuffer, &lBufferLength);324 if (lError != ERROR_SUCCESS)325 break;326 327 FIXME("(0x%08x, %ld, %ld): stub (partial)\n",328 hadid, dwPriority, fdwPriority);329 break;330 }331 332 RegCloseKey(hPriorityKey);333 334 return MMSYSERR_ERROR;335 335 } 336 336 … … 341 341 { 342 342 PWINE_ACMDRIVERID padid; 343 343 344 344 padid = MSACM_GetDriverID(hadid); 345 345 if (!padid) 346 347 346 return MMSYSERR_INVALHANDLE; 347 348 348 if (fdwRemove) 349 350 349 return MMSYSERR_INVALFLAG; 350 351 351 MSACM_UnregisterDriver(padid); 352 353 return MMSYSERR_NOERROR; 354 } 355 352 353 return MMSYSERR_NOERROR; 354 } 355 -
trunk/src/msacm32/filter.c
r6648 r6712 1 1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */ 2 /* $Id: filter.c,v 1.2 2001-09-05 13:11:25 bird Exp $ */ 2 3 3 /* 4 4 * MSACM32 library … … 42 42 * acmFilterDetailsA (MSACM32.15) 43 43 */ 44 MMRESULT WINAPI acmFilterDetailsA(HACMDRIVER had, PACMFILTERDETAILSA pafd, 45 46 { 47 ACMFILTERDETAILSW 48 MMRESULT 44 MMRESULT WINAPI acmFilterDetailsA(HACMDRIVER had, PACMFILTERDETAILSA pafd, 45 DWORD fdwDetails) 46 { 47 ACMFILTERDETAILSW afdw; 48 MMRESULT mmr; 49 49 50 50 memset(&afdw, 0, sizeof(afdw)); 51 51 afdw.cbStruct = sizeof(afdw); 52 52 afdw.dwFilterIndex = pafd->dwFilterIndex; 53 afdw.dwFilterTag = pafd->dwFilterTag; 53 afdw.dwFilterTag = pafd->dwFilterTag; 54 54 afdw.pwfltr = pafd->pwfltr; 55 55 afdw.cbwfltr = pafd->cbwfltr; … … 57 57 mmr = acmFilterDetailsW(had, &afdw, fdwDetails); 58 58 if (mmr == MMSYSERR_NOERROR) { 59 pafd->dwFilterTag = afdw.dwFilterTag; 60 pafd->fdwSupport = afdw.fdwSupport; 59 pafd->dwFilterTag = afdw.dwFilterTag; 60 pafd->fdwSupport = afdw.fdwSupport; 61 61 WideCharToMultiByte( CP_ACP, 0, afdw.szFilter, -1, pafd->szFilter, 62 62 sizeof(pafd->szFilter), NULL, NULL ); … … 68 68 * acmFilterDetailsW (MSACM32.16) 69 69 */ 70 MMRESULT WINAPI acmFilterDetailsW(HACMDRIVER had, PACMFILTERDETAILSW pafd, 71 72 { 73 MMRESULT 74 ACMFILTERTAGDETAILSA 70 MMRESULT WINAPI acmFilterDetailsW(HACMDRIVER had, PACMFILTERDETAILSW pafd, 71 DWORD fdwDetails) 72 { 73 MMRESULT mmr; 74 ACMFILTERTAGDETAILSA aftd; 75 75 76 76 TRACE("(0x%08x, %p, %ld)\n", had, pafd, fdwDetails); … … 80 80 81 81 if (pafd->cbStruct < sizeof(*pafd)) return MMSYSERR_INVALPARAM; 82 82 83 83 switch (fdwDetails) { 84 84 case ACM_FILTERDETAILSF_FILTER: 85 86 87 88 89 90 PWINE_ACMDRIVERIDpadid;91 92 93 94 95 if (padid->bEnabled && 96 97 98 99 100 101 102 } 103 104 105 106 107 85 if (pafd->dwFilterTag != pafd->pwfltr->dwFilterTag) { 86 mmr = MMSYSERR_INVALPARAM; 87 break; 88 } 89 if (had == (HACMDRIVER)NULL) { 90 PWINE_ACMDRIVERID padid; 91 92 mmr = ACMERR_NOTPOSSIBLE; 93 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { 94 /* should check for codec only */ 95 if (padid->bEnabled && 96 acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) { 97 mmr = MSACM_Message(had, ACMDM_FILTER_DETAILS, 98 (LPARAM)pafd, (LPARAM)fdwDetails); 99 acmDriverClose(had, 0); 100 if (mmr == MMSYSERR_NOERROR) break; 101 } 102 } 103 } else { 104 mmr = MSACM_Message(had, ACMDM_FILTER_DETAILS, 105 (LPARAM)pafd, (LPARAM)fdwDetails); 106 } 107 break; 108 108 case ACM_FILTERDETAILSF_INDEX: 109 110 111 112 109 /* should check pafd->dwFilterIndex < aftd->cStandardFilters */ 110 mmr = MSACM_Message(had, ACMDM_FILTER_DETAILS, 111 (LPARAM)pafd, (LPARAM)fdwDetails); 112 break; 113 113 default: 114 115 116 114 WARN("Unknown fdwDetails %08lx\n", fdwDetails); 115 mmr = MMSYSERR_INVALFLAG; 116 break; 117 117 } 118 118 … … 122 122 123 123 struct MSACM_FilterEnumWtoA_Instance { 124 PACMFILTERDETAILSA 125 DWORD 126 ACMFILTERENUMCBA 124 PACMFILTERDETAILSA pafda; 125 DWORD dwInstance; 126 ACMFILTERENUMCBA fnCallback; 127 127 }; 128 128 129 129 static BOOL CALLBACK MSACM_FilterEnumCallbackWtoA(HACMDRIVERID hadid, 130 PACMFILTERDETAILSW pafdw, 131 DWORD dwInstance, 132 130 PACMFILTERDETAILSW pafdw, 131 DWORD dwInstance, 132 DWORD fdwSupport) 133 133 { 134 134 struct MSACM_FilterEnumWtoA_Instance* pafei; … … 136 136 pafei = (struct MSACM_FilterEnumWtoA_Instance*)dwInstance; 137 137 138 pafei->pafda->dwFilterIndex = pafdw->dwFilterIndex; 139 pafei->pafda->dwFilterTag = pafdw->dwFilterTag; 140 pafei->pafda->fdwSupport = pafdw->fdwSupport; 138 pafei->pafda->dwFilterIndex = pafdw->dwFilterIndex; 139 pafei->pafda->dwFilterTag = pafdw->dwFilterTag; 140 pafei->pafda->fdwSupport = pafdw->fdwSupport; 141 141 WideCharToMultiByte( CP_ACP, 0, pafdw->szFilter, -1, pafei->pafda->szFilter, 142 142 sizeof(pafei->pafda->szFilter), NULL, NULL ); 143 143 144 return (pafei->fnCallback)(hadid, pafei->pafda, 145 144 return (pafei->fnCallback)(hadid, pafei->pafda, 145 pafei->dwInstance, fdwSupport); 146 146 } 147 147 … … 149 149 * acmFilterEnumA (MSACM32.17) 150 150 */ 151 MMRESULT WINAPI acmFilterEnumA(HACMDRIVER had, PACMFILTERDETAILSA pafda, 152 ACMFILTERENUMCBA fnCallback, DWORD dwInstance, 153 154 { 155 ACMFILTERDETAILSW 151 MMRESULT WINAPI acmFilterEnumA(HACMDRIVER had, PACMFILTERDETAILSA pafda, 152 ACMFILTERENUMCBA fnCallback, DWORD dwInstance, 153 DWORD fdwEnum) 154 { 155 ACMFILTERDETAILSW afdw; 156 156 struct MSACM_FilterEnumWtoA_Instance afei; 157 157 … … 167 167 afei.fnCallback = fnCallback; 168 168 169 return acmFilterEnumW(had, &afdw, MSACM_FilterEnumCallbackWtoA, 170 171 } 172 173 static BOOL MSACM_FilterEnumHelper(PWINE_ACMDRIVERID padid, HACMDRIVER had, 174 PACMFILTERDETAILSW pafd, 175 ACMFILTERENUMCBW fnCallback, DWORD dwInstance, 176 177 { 178 ACMDRIVERDETAILSW 179 ACMFILTERTAGDETAILSW 180 int 169 return acmFilterEnumW(had, &afdw, MSACM_FilterEnumCallbackWtoA, 170 (DWORD)&afei, fdwEnum); 171 } 172 173 static BOOL MSACM_FilterEnumHelper(PWINE_ACMDRIVERID padid, HACMDRIVER had, 174 PACMFILTERDETAILSW pafd, 175 ACMFILTERENUMCBW fnCallback, DWORD dwInstance, 176 DWORD fdwEnum) 177 { 178 ACMDRIVERDETAILSW add; 179 ACMFILTERTAGDETAILSW aftd; 180 int i, j; 181 181 182 182 add.cbStruct = sizeof(add); 183 183 184 184 if (acmDriverDetailsW((HACMDRIVERID)padid, &add, 0) != MMSYSERR_NOERROR) return FALSE; 185 185 186 186 for (i = 0; i < add.cFilterTags; i++) { 187 188 189 190 191 192 193 if ((fdwEnum & ACM_FILTERENUMF_DWFILTERTAG) && 194 195 196 197 198 199 200 if (acmFilterDetailsW(had, pafd, ACM_FILTERDETAILSF_INDEX) != MMSYSERR_NOERROR) 201 202 203 204 return FALSE; 205 187 memset(&aftd, 0, sizeof(aftd)); 188 aftd.cbStruct = sizeof(aftd); 189 aftd.dwFilterTagIndex = i; 190 if (acmFilterTagDetailsW(had, &aftd, ACM_FILTERTAGDETAILSF_INDEX) != MMSYSERR_NOERROR) 191 continue; 192 193 if ((fdwEnum & ACM_FILTERENUMF_DWFILTERTAG) && 194 aftd.dwFilterTag != pafd->pwfltr->dwFilterTag) 195 continue; 196 197 for (j = 0; j < aftd.cStandardFilters; j++) { 198 pafd->dwFilterIndex = j; 199 pafd->dwFilterTag = aftd.dwFilterTag; 200 if (acmFilterDetailsW(had, pafd, ACM_FILTERDETAILSF_INDEX) != MMSYSERR_NOERROR) 201 continue; 202 203 if (!(fnCallback)((HACMDRIVERID)padid, pafd, dwInstance, add.fdwSupport)) 204 return FALSE; 205 } 206 206 } 207 207 return TRUE; … … 211 211 * acmFilterEnumW (MSACM32.18) 212 212 */ 213 MMRESULT WINAPI acmFilterEnumW(HACMDRIVER had, PACMFILTERDETAILSW pafd, 214 ACMFILTERENUMCBW fnCallback, DWORD dwInstance, 215 216 { 217 PWINE_ACMDRIVERID 218 BOOL 213 MMRESULT WINAPI acmFilterEnumW(HACMDRIVER had, PACMFILTERDETAILSW pafd, 214 ACMFILTERENUMCBW fnCallback, DWORD dwInstance, 215 DWORD fdwEnum) 216 { 217 PWINE_ACMDRIVERID padid; 218 BOOL ret; 219 219 220 220 TRACE("(0x%08x, %p, %p, %ld, %ld)\n", 221 221 had, pafd, fnCallback, dwInstance, fdwEnum); 222 222 223 223 if (pafd->cbStruct < sizeof(*pafd)) return MMSYSERR_INVALPARAM; 224 224 225 225 if (fdwEnum & ~(ACM_FILTERENUMF_DWFILTERTAG)) 226 226 FIXME("Unsupported fdwEnum values\n"); 227 227 228 228 if (had) { 229 HACMDRIVERID hadid; 230 231 if (acmDriverID(had, &hadid, 0) != MMSYSERR_NOERROR) 232 return MMSYSERR_INVALHANDLE; 233 MSACM_FilterEnumHelper(MSACM_GetDriverID(hadid), had, pafd, 234 fnCallback, dwInstance, fdwEnum); 229 HACMDRIVERID hadid; 230 231 if (acmDriverID(had, &hadid, 0) != MMSYSERR_NOERROR) 232 return MMSYSERR_INVALHANDLE; 233 MSACM_FilterEnumHelper(MSACM_GetDriverID(hadid), had, pafd, 234 fnCallback, dwInstance, fdwEnum); 235 return MMSYSERR_NOERROR; 236 } 237 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { 238 /* should check for codec only */ 239 if (!padid->bEnabled || acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != MMSYSERR_NOERROR) 240 continue; 241 ret = MSACM_FilterEnumHelper(padid, had, pafd, 242 fnCallback, dwInstance, fdwEnum); 243 acmDriverClose(had, 0); 244 if (!ret) break; 245 } 235 246 return MMSYSERR_NOERROR; 236 }237 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {238 /* should check for codec only */239 if (!padid->bEnabled || acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != MMSYSERR_NOERROR)240 continue;241 ret = MSACM_FilterEnumHelper(padid, had, pafd,242 fnCallback, dwInstance, fdwEnum);243 acmDriverClose(had, 0);244 if (!ret) break;245 }246 return MMSYSERR_NOERROR;247 247 } 248 248 … … 250 250 * acmFilterTagDetailsA (MSACM32.19) 251 251 */ 252 MMRESULT WINAPI acmFilterTagDetailsA(HACMDRIVER had, PACMFILTERTAGDETAILSA paftda, 253 254 { 255 ACMFILTERTAGDETAILSW 256 MMRESULT 252 MMRESULT WINAPI acmFilterTagDetailsA(HACMDRIVER had, PACMFILTERTAGDETAILSA paftda, 253 DWORD fdwDetails) 254 { 255 ACMFILTERTAGDETAILSW aftdw; 256 MMRESULT mmr; 257 257 258 258 memset(&aftdw, 0, sizeof(aftdw)); … … 263 263 mmr = acmFilterTagDetailsW(had, &aftdw, fdwDetails); 264 264 if (mmr == MMSYSERR_NOERROR) { 265 paftda->dwFilterTag = aftdw.dwFilterTag; 266 267 paftda->cbFilterSize = aftdw.cbFilterSize; 268 paftda->fdwSupport = aftdw.fdwSupport; 269 paftda->cStandardFilters = aftdw.cStandardFilters; 265 paftda->dwFilterTag = aftdw.dwFilterTag; 266 paftda->dwFilterTagIndex = aftdw.dwFilterTagIndex; 267 paftda->cbFilterSize = aftdw.cbFilterSize; 268 paftda->fdwSupport = aftdw.fdwSupport; 269 paftda->cStandardFilters = aftdw.cStandardFilters; 270 270 WideCharToMultiByte( CP_ACP, 0, aftdw.szFilterTag, -1, paftda->szFilterTag, 271 271 sizeof(paftda->szFilterTag), NULL, NULL ); … … 277 277 * acmFilterTagDetailsW (MSACM32.20) 278 278 */ 279 MMRESULT WINAPI acmFilterTagDetailsW(HACMDRIVER had, PACMFILTERTAGDETAILSW paftd, 280 281 { 282 PWINE_ACMDRIVERID 283 MMRESULT 279 MMRESULT WINAPI acmFilterTagDetailsW(HACMDRIVER had, PACMFILTERTAGDETAILSW paftd, 280 DWORD fdwDetails) 281 { 282 PWINE_ACMDRIVERID padid; 283 MMRESULT mmr; 284 284 285 285 TRACE("(0x%08x, %p, %ld)\n", had, paftd, fdwDetails); 286 286 287 287 if (fdwDetails & ~(ACM_FILTERTAGDETAILSF_FILTERTAG|ACM_FILTERTAGDETAILSF_INDEX| 288 289 288 ACM_FILTERTAGDETAILSF_LARGESTSIZE)) 289 return MMSYSERR_INVALFLAG; 290 290 291 291 switch (fdwDetails) { 292 292 case ACM_FILTERTAGDETAILSF_FILTERTAG: 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 293 if (had == (HACMDRIVER)NULL) { 294 mmr = ACMERR_NOTPOSSIBLE; 295 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { 296 /* should check for codec only */ 297 if (padid->bEnabled && acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) { 298 mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS, 299 (LPARAM)paftd, (LPARAM)fdwDetails); 300 acmDriverClose(had, 0); 301 if (mmr == MMSYSERR_NOERROR) break; 302 } 303 } 304 } else { 305 mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS, 306 (LPARAM)paftd, (LPARAM)fdwDetails); 307 } 308 break; 309 309 310 310 case ACM_FILTERTAGDETAILSF_INDEX: 311 312 313 314 311 /* FIXME should check paftd->dwFilterTagIndex < add.cFilterTags */ 312 mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS, 313 (LPARAM)paftd, (LPARAM)fdwDetails); 314 break; 315 315 316 316 case ACM_FILTERTAGDETAILSF_LARGESTSIZE: 317 318 ACMFILTERTAGDETAILSWtmp;319 DWORDft = paftd->dwFilterTag;320 321 322 323 324 if (padid->bEnabled && 325 326 327 328 329 330 331 332 (LPARAM)&tmp, 333 334 335 336 337 338 } 339 340 341 342 343 344 345 346 347 317 if (had == (HACMDRIVER)NULL) { 318 ACMFILTERTAGDETAILSW tmp; 319 DWORD ft = paftd->dwFilterTag; 320 321 mmr = ACMERR_NOTPOSSIBLE; 322 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { 323 /* should check for codec only */ 324 if (padid->bEnabled && 325 acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) { 326 327 memset(&tmp, 0, sizeof(tmp)); 328 tmp.cbStruct = sizeof(tmp); 329 tmp.dwFilterTag = ft; 330 331 if (MSACM_Message(had, ACMDM_FILTERTAG_DETAILS, 332 (LPARAM)&tmp, 333 (LPARAM)fdwDetails) == MMSYSERR_NOERROR) { 334 if (mmr == ACMERR_NOTPOSSIBLE || 335 paftd->cbFilterSize < tmp.cbFilterSize) { 336 *paftd = tmp; 337 mmr = MMSYSERR_NOERROR; 338 } 339 } 340 acmDriverClose(had, 0); 341 } 342 } 343 } else { 344 mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS, 345 (LPARAM)paftd, (LPARAM)fdwDetails); 346 } 347 break; 348 348 349 349 default: 350 351 352 } 353 354 if (mmr == MMSYSERR_NOERROR && 355 350 WARN("Unsupported fdwDetails=%08lx\n", fdwDetails); 351 mmr = MMSYSERR_ERROR; 352 } 353 354 if (mmr == MMSYSERR_NOERROR && 355 paftd->dwFilterTag == WAVE_FORMAT_PCM && paftd->szFilterTag[0] == 0) 356 356 MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFilterTag, 357 357 sizeof(paftd->szFilterTag)/sizeof(WCHAR) ); … … 361 361 362 362 struct MSACM_FilterTagEnumWtoA_Instance { 363 PACMFILTERTAGDETAILSA 364 DWORD 365 ACMFILTERTAGENUMCBA 363 PACMFILTERTAGDETAILSA paftda; 364 DWORD dwInstance; 365 ACMFILTERTAGENUMCBA fnCallback; 366 366 }; 367 367 368 368 static BOOL CALLBACK MSACM_FilterTagEnumCallbackWtoA(HACMDRIVERID hadid, 369 PACMFILTERTAGDETAILSW paftdw, 370 DWORD dwInstance, 371 369 PACMFILTERTAGDETAILSW paftdw, 370 DWORD dwInstance, 371 DWORD fdwSupport) 372 372 { 373 373 struct MSACM_FilterTagEnumWtoA_Instance* paftei; … … 375 375 paftei = (struct MSACM_FilterTagEnumWtoA_Instance*)dwInstance; 376 376 377 paftei->paftda->dwFilterTagIndex = paftdw->dwFilterTagIndex; 378 paftei->paftda->dwFilterTag = paftdw->dwFilterTag; 379 paftei->paftda->cbFilterSize = paftdw->cbFilterSize; 380 paftei->paftda->fdwSupport = paftdw->fdwSupport; 381 paftei->paftda->cStandardFilters = paftdw->cStandardFilters; 377 paftei->paftda->dwFilterTagIndex = paftdw->dwFilterTagIndex; 378 paftei->paftda->dwFilterTag = paftdw->dwFilterTag; 379 paftei->paftda->cbFilterSize = paftdw->cbFilterSize; 380 paftei->paftda->fdwSupport = paftdw->fdwSupport; 381 paftei->paftda->cStandardFilters = paftdw->cStandardFilters; 382 382 WideCharToMultiByte( CP_ACP, 0, paftdw->szFilterTag, -1, paftei->paftda->szFilterTag, 383 383 sizeof(paftei->paftda->szFilterTag), NULL, NULL ); 384 384 385 return (paftei->fnCallback)(hadid, paftei->paftda, 386 385 return (paftei->fnCallback)(hadid, paftei->paftda, 386 paftei->dwInstance, fdwSupport); 387 387 } 388 388 … … 391 391 */ 392 392 MMRESULT WINAPI acmFilterTagEnumA(HACMDRIVER had, PACMFILTERTAGDETAILSA paftda, 393 ACMFILTERTAGENUMCBA fnCallback, DWORD dwInstance, 394 395 { 396 ACMFILTERTAGDETAILSW 393 ACMFILTERTAGENUMCBA fnCallback, DWORD dwInstance, 394 DWORD fdwEnum) 395 { 396 ACMFILTERTAGDETAILSW aftdw; 397 397 struct MSACM_FilterTagEnumWtoA_Instance aftei; 398 398 … … 406 406 aftei.fnCallback = fnCallback; 407 407 408 return acmFilterTagEnumW(had, &aftdw, MSACM_FilterTagEnumCallbackWtoA, 409 408 return acmFilterTagEnumW(had, &aftdw, MSACM_FilterTagEnumCallbackWtoA, 409 (DWORD)&aftei, fdwEnum); 410 410 } 411 411 … … 414 414 */ 415 415 MMRESULT WINAPI acmFilterTagEnumW(HACMDRIVER had, PACMFILTERTAGDETAILSW paftd, 416 ACMFILTERTAGENUMCBW fnCallback, DWORD dwInstance, 417 418 { 419 PWINE_ACMDRIVERID 420 ACMDRIVERDETAILSW 421 int 416 ACMFILTERTAGENUMCBW fnCallback, DWORD dwInstance, 417 DWORD fdwEnum) 418 { 419 PWINE_ACMDRIVERID padid; 420 ACMDRIVERDETAILSW add; 421 int i; 422 422 423 423 TRACE("(0x%08x, %p, %p, %ld, %ld)\n", 424 had, paftd, fnCallback, dwInstance, fdwEnum); 424 had, paftd, fnCallback, dwInstance, fdwEnum); 425 425 426 426 if (paftd->cbStruct < sizeof(*paftd)) return MMSYSERR_INVALPARAM; 427 427 428 428 if (had) FIXME("had != NULL, not supported\n"); 429 429 430 430 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { 431 432 433 434 435 436 437 438 439 if (!(fnCallback)((HACMDRIVERID)padid, paftd, dwInstance, 440 441 442 443 444 445 446 447 448 431 /* should check for codec only */ 432 if (padid->bEnabled && acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == MMSYSERR_NOERROR) { 433 add.cbStruct = sizeof(add); 434 435 if (acmDriverDetailsW((HACMDRIVERID)padid, &add, 0) == MMSYSERR_NOERROR) { 436 for (i = 0; i < add.cFilterTags; i++) { 437 paftd->dwFilterTagIndex = i; 438 if (acmFilterTagDetailsW(had, paftd, ACM_FILTERTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) { 439 if (!(fnCallback)((HACMDRIVERID)padid, paftd, dwInstance, 440 add.fdwSupport)) { 441 padid = NULL; 442 break; 443 } 444 } 445 } 446 } 447 } 448 acmDriverClose(had, 0); 449 449 } 450 450 return MMSYSERR_NOERROR; -
trunk/src/msacm32/format.c
r6648 r6712 1 1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */ 2 /* $Id: format.c,v 1.2 2001-09-05 13:11:25 bird Exp $ */ 2 3 3 /* 4 4 * MSACM32 library 5 5 * 6 6 * Copyright 1998 Patrik Stridvall 7 * 2000Eric Pouech7 * 2000 Eric Pouech 8 8 */ 9 9 … … 24 24 DEFAULT_DEBUG_CHANNEL(msacm); 25 25 26 static PACMFORMATCHOOSEAafc;26 static PACMFORMATCHOOSEA afc; 27 27 28 28 struct MSACM_FillFormatData { 29 HWND 30 #define WINE_ACMFF_TAG 31 #define WINE_ACMFF_FORMAT 32 #define WINE_ACMFF_WFX 33 int 34 char 35 PACMFORMATCHOOSEA 36 DWORD 29 HWND hWnd; 30 #define WINE_ACMFF_TAG 0 31 #define WINE_ACMFF_FORMAT 1 32 #define WINE_ACMFF_WFX 2 33 int mode; 34 char szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS]; 35 PACMFORMATCHOOSEA afc; 36 DWORD ret; 37 37 }; 38 38 39 static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid, 40 41 42 { 43 struct MSACM_FillFormatData* 39 static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid, 40 PACMFORMATTAGDETAILSA paftd, 41 DWORD dwInstance, DWORD fdwSupport) 42 { 43 struct MSACM_FillFormatData* affd = (struct MSACM_FillFormatData*)dwInstance; 44 44 45 45 switch (affd->mode) { 46 46 case WINE_ACMFF_TAG: 47 if (SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, 48 CB_FINDSTRINGEXACT, 49 50 SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, 51 52 47 if (SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, 48 CB_FINDSTRINGEXACT, 49 (WPARAM)-1, (LPARAM)paftd->szFormatTag) == CB_ERR) 50 SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, 51 CB_ADDSTRING, 0, (DWORD)paftd->szFormatTag); 52 break; 53 53 case WINE_ACMFF_FORMAT: 54 55 HACMDRIVERhad;56 57 58 ACMFORMATDETAILSAafd;59 inti, idx;60 MMRESULTmmr;61 charbuffer[64];62 63 64 65 66 67 68 69 70 71 72 73 74 75 for (idx = strlen(buffer); 76 77 78 wsprintfA(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS, 79 "%d Ko/s", 80 81 SendDlgItemMessageA(affd->hWnd, 82 IDD_ACMFORMATCHOOSE_CMB_FORMAT, 83 84 85 86 87 SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, 88 89 } 90 91 54 if (strcmp(affd->szFormatTag, paftd->szFormatTag) == 0) { 55 HACMDRIVER had; 56 57 if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) { 58 ACMFORMATDETAILSA afd; 59 int i, idx; 60 MMRESULT mmr; 61 char buffer[64]; 62 63 afd.cbStruct = sizeof(afd); 64 afd.dwFormatTag = paftd->dwFormatTag; 65 afd.pwfx = HeapAlloc(GetProcessHeap(), 0, paftd->cbFormatSize); 66 afd.pwfx->wFormatTag = paftd->dwFormatTag; 67 afd.pwfx->cbSize = paftd->cbFormatSize; 68 afd.cbwfx = paftd->cbFormatSize; 69 70 for (i = 0; i < paftd->cStandardFormats; i++) { 71 afd.dwFormatIndex = i; 72 mmr = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX); 73 if (mmr == MMSYSERR_NOERROR) { 74 strcpy(buffer, afd.szFormat); 75 for (idx = strlen(buffer); 76 idx < ACMFORMATTAGDETAILS_FORMATTAG_CHARS; idx++) 77 buffer[idx] = ' '; 78 wsprintfA(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS, 79 "%d Ko/s", 80 (afd.pwfx->nAvgBytesPerSec + 512) / 1024); 81 SendDlgItemMessageA(affd->hWnd, 82 IDD_ACMFORMATCHOOSE_CMB_FORMAT, 83 CB_ADDSTRING, 0, (DWORD)buffer); 84 } 85 } 86 acmDriverClose(had, 0); 87 SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, 88 CB_SETCURSEL, 0, 0); 89 } 90 } 91 break; 92 92 case WINE_ACMFF_WFX: 93 94 HACMDRIVERhad;95 96 97 ACMFORMATDETAILSAafd;98 99 100 101 102 103 104 105 106 107 108 } 109 110 93 if (strcmp(affd->szFormatTag, paftd->szFormatTag) == 0) { 94 HACMDRIVER had; 95 96 if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) { 97 ACMFORMATDETAILSA afd; 98 99 afd.cbStruct = sizeof(afd); 100 afd.dwFormatTag = paftd->dwFormatTag; 101 afd.pwfx = affd->afc->pwfx; 102 afd.cbwfx = affd->afc->cbwfx; 103 104 afd.dwFormatIndex = SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_GETCURSEL, 0, 0);; 105 affd->ret = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX); 106 acmDriverClose(had, 0); 107 return TRUE; 108 } 109 } 110 break; 111 111 default: 112 113 112 FIXME("Unknown mode (%d)\n", affd->mode); 113 break; 114 114 } 115 115 return TRUE; … … 118 118 static BOOL MSACM_FillFormatTags(HWND hWnd) 119 119 { 120 ACMFORMATTAGDETAILSA 121 struct MSACM_FillFormatData 120 ACMFORMATTAGDETAILSA aftd; 121 struct MSACM_FillFormatData affd; 122 122 123 123 memset(&aftd, 0, sizeof(aftd)); … … 134 134 static BOOL MSACM_FillFormat(HWND hWnd) 135 135 { 136 ACMFORMATTAGDETAILSA 137 struct MSACM_FillFormatData 136 ACMFORMATTAGDETAILSA aftd; 137 struct MSACM_FillFormatData affd; 138 138 139 139 SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_RESETCONTENT, 0, 0); … … 144 144 affd.hWnd = hWnd; 145 145 affd.mode = WINE_ACMFF_FORMAT; 146 SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, 147 148 SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, 149 150 151 146 SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, 147 CB_GETLBTEXT, 148 SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, 149 CB_GETCURSEL, 0, 0), 150 (DWORD)affd.szFormatTag); 151 152 152 acmFormatTagEnumA((HACMDRIVER)0, &aftd, MSACM_FillFormatTagsCB, (DWORD)&affd, 0); 153 153 SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_SETCURSEL, 0, 0); … … 157 157 static MMRESULT MSACM_GetWFX(HWND hWnd, PACMFORMATCHOOSEA afc) 158 158 { 159 ACMFORMATTAGDETAILSA 160 struct MSACM_FillFormatData 159 ACMFORMATTAGDETAILSA aftd; 160 struct MSACM_FillFormatData affd; 161 161 162 162 memset(&aftd, 0, sizeof(aftd)); … … 172 172 } 173 173 174 static BOOL WINAPI FormatChooseDlgProc(HWND hWnd, UINT msg, 175 176 { 177 174 static BOOL WINAPI FormatChooseDlgProc(HWND hWnd, UINT msg, 175 WPARAM wParam, LPARAM lParam) 176 { 177 178 178 TRACE("hwnd=%i msg=%i 0x%08x 0x%08lx\n", hWnd, msg, wParam, lParam ); 179 179 180 180 switch (msg) { 181 181 case WM_INITDIALOG: 182 183 184 185 186 187 188 189 190 191 182 afc = (PACMFORMATCHOOSEA)lParam; 183 MSACM_FillFormatTags(hWnd); 184 MSACM_FillFormat(hWnd); 185 if ((afc->fdwStyle & ~(ACMFORMATCHOOSE_STYLEF_CONTEXTHELP| 186 ACMFORMATCHOOSE_STYLEF_SHOWHELP)) != 0) 187 FIXME("Unsupported style %08lx\n", ((PACMFORMATCHOOSEA)lParam)->fdwStyle); 188 if (!(afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_SHOWHELP)) 189 ShowWindow(GetDlgItem(hWnd, IDD_ACMFORMATCHOOSE_BTN_HELP), SW_HIDE); 190 return TRUE; 191 192 192 case WM_COMMAND: 193 194 195 196 197 198 199 200 201 202 203 204 205 206 TRACE("Dropped dlgNotif (fmtTag): 0x%08x 0x%08lx\n", 207 208 209 210 211 212 213 SendMessageA(afc->hwndOwner, 214 215 216 217 218 TRACE("Dropped dlgCmd: ctl=%d ntf=0x%04x 0x%08lx\n", 219 220 221 222 193 switch (LOWORD(wParam)) { 194 case IDOK: 195 EndDialog(hWnd, MSACM_GetWFX(hWnd, afc)); 196 return TRUE; 197 case IDCANCEL: 198 EndDialog(hWnd, ACMERR_CANCELED); 199 return TRUE; 200 case IDD_ACMFORMATCHOOSE_CMB_FORMATTAG: 201 switch (HIWORD(wParam)) { 202 case CBN_SELCHANGE: 203 MSACM_FillFormat(hWnd); 204 break; 205 default: 206 TRACE("Dropped dlgNotif (fmtTag): 0x%08x 0x%08lx\n", 207 HIWORD(wParam), lParam); 208 break; 209 } 210 break; 211 case IDD_ACMFORMATCHOOSE_BTN_HELP: 212 if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_SHOWHELP) 213 SendMessageA(afc->hwndOwner, 214 RegisterWindowMessageA(ACMHELPMSGSTRINGA), 0L, 0L); 215 break; 216 217 default: 218 TRACE("Dropped dlgCmd: ctl=%d ntf=0x%04x 0x%08lx\n", 219 LOWORD(wParam), HIWORD(wParam), lParam); 220 break; 221 } 222 break; 223 223 case WM_CONTEXTMENU: 224 225 SendMessageA(afc->hwndOwner, 226 RegisterWindowMessageA(ACMHELPMSGCONTEXTMENUA), 227 228 224 if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_CONTEXTHELP) 225 SendMessageA(afc->hwndOwner, 226 RegisterWindowMessageA(ACMHELPMSGCONTEXTMENUA), 227 wParam, lParam); 228 break; 229 229 #if defined(WM_CONTEXTHELP) 230 230 case WM_CONTEXTHELP: 231 232 SendMessageA(afc->hwndOwner, 233 RegisterWindowMessageA(ACMHELPMSGCONTEXTHELPA), 234 235 236 #endif 231 if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_CONTEXTHELP) 232 SendMessageA(afc->hwndOwner, 233 RegisterWindowMessageA(ACMHELPMSGCONTEXTHELPA), 234 wParam, lParam); 235 break; 236 #endif 237 237 default: 238 TRACE("Dropped dlgMsg: hwnd=%i msg=%i 0x%08x 0x%08lx\n", 239 240 238 TRACE("Dropped dlgMsg: hwnd=%i msg=%i 0x%08x 0x%08lx\n", 239 hWnd, msg, wParam, lParam ); 240 break; 241 241 } 242 242 return FALSE; … … 249 249 { 250 250 return DialogBoxParamA(MSACM_hInstance32, MAKEINTRESOURCEA(DLG_ACMFORMATCHOOSE_ID), 251 251 pafmtc->hwndOwner, FormatChooseDlgProc, (INT)pafmtc); 252 252 } 253 253 … … 265 265 * acmFormatDetailsA (MSACM32.25) 266 266 */ 267 MMRESULT WINAPI acmFormatDetailsA(HACMDRIVER had, PACMFORMATDETAILSA pafd, 268 269 { 270 ACMFORMATDETAILSW 271 MMRESULT 267 MMRESULT WINAPI acmFormatDetailsA(HACMDRIVER had, PACMFORMATDETAILSA pafd, 268 DWORD fdwDetails) 269 { 270 ACMFORMATDETAILSW afdw; 271 MMRESULT mmr; 272 272 273 273 memset(&afdw, 0, sizeof(afdw)); 274 274 afdw.cbStruct = sizeof(afdw); 275 275 afdw.dwFormatIndex = pafd->dwFormatIndex; 276 afdw.dwFormatTag = pafd->dwFormatTag; 277 afdw.pwfx = pafd->pwfx; 278 afdw.cbwfx = pafd->cbwfx; 276 afdw.dwFormatTag = pafd->dwFormatTag; 277 afdw.pwfx = pafd->pwfx; 278 afdw.cbwfx = pafd->cbwfx; 279 279 280 280 mmr = acmFormatDetailsW(had, &afdw, fdwDetails); 281 281 if (mmr == MMSYSERR_NOERROR) { 282 pafd->dwFormatTag = afdw.dwFormatTag; 283 pafd->fdwSupport = afdw.fdwSupport; 282 pafd->dwFormatTag = afdw.dwFormatTag; 283 pafd->fdwSupport = afdw.fdwSupport; 284 284 WideCharToMultiByte( CP_ACP, 0, afdw.szFormat, -1, 285 285 pafd->szFormat, sizeof(pafd->szFormat), NULL, NULL ); … … 291 291 * acmFormatDetailsW (MSACM32.26) 292 292 */ 293 MMRESULT WINAPI acmFormatDetailsW(HACMDRIVER had, PACMFORMATDETAILSW pafd, 294 295 { 296 MMRESULT 297 static WCHAR 298 static WCHAR 299 ACMFORMATTAGDETAILSA 293 MMRESULT WINAPI acmFormatDetailsW(HACMDRIVER had, PACMFORMATDETAILSW pafd, 294 DWORD fdwDetails) 295 { 296 MMRESULT mmr; 297 static WCHAR fmt1[] = {'%','d',' ','H','z',0}; 298 static WCHAR fmt2[] = {';',' ','%','d',' ','b','i','t','s',0}; 299 ACMFORMATTAGDETAILSA aftd; 300 300 301 301 TRACE("(0x%08x, %p, %ld)\n", had, pafd, fdwDetails); … … 305 305 306 306 if (pafd->cbStruct < sizeof(*pafd)) return MMSYSERR_INVALPARAM; 307 307 308 308 switch (fdwDetails) { 309 309 case ACM_FORMATDETAILSF_FORMAT: 310 311 312 313 314 315 PWINE_ACMDRIVERIDpadid;316 317 318 319 320 if (padid->bEnabled && 321 322 323 324 325 326 327 } 328 329 330 331 332 310 if (pafd->dwFormatTag != pafd->pwfx->wFormatTag) { 311 mmr = MMSYSERR_INVALPARAM; 312 break; 313 } 314 if (had == (HACMDRIVER)NULL) { 315 PWINE_ACMDRIVERID padid; 316 317 mmr = ACMERR_NOTPOSSIBLE; 318 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { 319 /* should check for codec only */ 320 if (padid->bEnabled && 321 acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) { 322 mmr = MSACM_Message(had, ACMDM_FORMAT_DETAILS, 323 (LPARAM)pafd, (LPARAM)fdwDetails); 324 acmDriverClose(had, 0); 325 if (mmr == MMSYSERR_NOERROR) break; 326 } 327 } 328 } else { 329 mmr = MSACM_Message(had, ACMDM_FORMAT_DETAILS, 330 (LPARAM)pafd, (LPARAM)fdwDetails); 331 } 332 break; 333 333 case ACM_FORMATDETAILSF_INDEX: 334 335 336 337 334 /* should check pafd->dwFormatIndex < aftd->cStandardFormats */ 335 mmr = MSACM_Message(had, ACMDM_FORMAT_DETAILS, 336 (LPARAM)pafd, (LPARAM)fdwDetails); 337 break; 338 338 default: 339 340 341 339 WARN("Unknown fdwDetails %08lx\n", fdwDetails); 340 mmr = MMSYSERR_INVALFLAG; 341 break; 342 342 } 343 343 344 344 if (mmr == MMSYSERR_NOERROR && pafd->szFormat[0] == (WCHAR)0) { 345 346 347 wsprintfW(pafd->szFormat + lstrlenW(pafd->szFormat), fmt2, 348 349 345 wsprintfW(pafd->szFormat, fmt1, pafd->pwfx->nSamplesPerSec); 346 if (pafd->pwfx->wBitsPerSample) { 347 wsprintfW(pafd->szFormat + lstrlenW(pafd->szFormat), fmt2, 348 pafd->pwfx->wBitsPerSample); 349 } 350 350 MultiByteToWideChar( CP_ACP, 0, (pafd->pwfx->nChannels == 1) ? "; Mono" : "; Stereo", -1, 351 351 pafd->szFormat + strlenW(pafd->szFormat), … … 358 358 359 359 struct MSACM_FormatEnumWtoA_Instance { 360 PACMFORMATDETAILSA 361 DWORD 362 ACMFORMATENUMCBA 360 PACMFORMATDETAILSA pafda; 361 DWORD dwInstance; 362 ACMFORMATENUMCBA fnCallback; 363 363 }; 364 364 365 365 static BOOL CALLBACK MSACM_FormatEnumCallbackWtoA(HACMDRIVERID hadid, 366 PACMFORMATDETAILSW pafdw, 367 DWORD dwInstance, 368 366 PACMFORMATDETAILSW pafdw, 367 DWORD dwInstance, 368 DWORD fdwSupport) 369 369 { 370 370 struct MSACM_FormatEnumWtoA_Instance* pafei; … … 372 372 pafei = (struct MSACM_FormatEnumWtoA_Instance*)dwInstance; 373 373 374 pafei->pafda->dwFormatIndex = pafdw->dwFormatIndex; 375 pafei->pafda->dwFormatTag = pafdw->dwFormatTag; 376 pafei->pafda->fdwSupport = pafdw->fdwSupport; 374 pafei->pafda->dwFormatIndex = pafdw->dwFormatIndex; 375 pafei->pafda->dwFormatTag = pafdw->dwFormatTag; 376 pafei->pafda->fdwSupport = pafdw->fdwSupport; 377 377 WideCharToMultiByte( CP_ACP, 0, pafdw->szFormat, -1, 378 378 pafei->pafda->szFormat, sizeof(pafei->pafda->szFormat), NULL, NULL ); 379 379 380 return (pafei->fnCallback)(hadid, pafei->pafda, 381 380 return (pafei->fnCallback)(hadid, pafei->pafda, 381 pafei->dwInstance, fdwSupport); 382 382 } 383 383 … … 386 386 */ 387 387 MMRESULT WINAPI acmFormatEnumA(HACMDRIVER had, PACMFORMATDETAILSA pafda, 388 ACMFORMATENUMCBA fnCallback, DWORD dwInstance, 389 390 { 391 ACMFORMATDETAILSW 388 ACMFORMATENUMCBA fnCallback, DWORD dwInstance, 389 DWORD fdwEnum) 390 { 391 ACMFORMATDETAILSW afdw; 392 392 struct MSACM_FormatEnumWtoA_Instance afei; 393 393 … … 403 403 afei.fnCallback = fnCallback; 404 404 405 return acmFormatEnumW(had, &afdw, MSACM_FormatEnumCallbackWtoA, 406 405 return acmFormatEnumW(had, &afdw, MSACM_FormatEnumCallbackWtoA, 406 (DWORD)&afei, fdwEnum); 407 407 } 408 408 … … 410 410 * acmFormatEnumW (MSACM32.28) 411 411 */ 412 static BOOL MSACM_FormatEnumHelper(PWINE_ACMDRIVERID padid, HACMDRIVER had, 413 PACMFORMATDETAILSW pafd, PWAVEFORMATEX pwfxRef, 414 ACMFORMATENUMCBW fnCallback, DWORD dwInstance, 415 416 { 417 ACMDRIVERDETAILSW 418 ACMFORMATTAGDETAILSW 419 int 412 static BOOL MSACM_FormatEnumHelper(PWINE_ACMDRIVERID padid, HACMDRIVER had, 413 PACMFORMATDETAILSW pafd, PWAVEFORMATEX pwfxRef, 414 ACMFORMATENUMCBW fnCallback, DWORD dwInstance, 415 DWORD fdwEnum) 416 { 417 ACMDRIVERDETAILSW add; 418 ACMFORMATTAGDETAILSW aftd; 419 int i, j; 420 420 421 421 add.cbStruct = sizeof(add); 422 422 423 423 if (acmDriverDetailsW((HACMDRIVERID)padid, &add, 0) != MMSYSERR_NOERROR) return FALSE; 424 424 425 425 for (i = 0; i < add.cFormatTags; i++) { 426 427 428 429 430 431 432 433 434 435 436 437 438 if (acmFormatDetailsW(had, pafd, ACM_FORMATDETAILSF_INDEX) != MMSYSERR_NOERROR) 439 440 441 if ((fdwEnum & ACM_FORMATENUMF_NCHANNELS) && 442 443 444 if ((fdwEnum & ACM_FORMATENUMF_NSAMPLESPERSEC) && 445 446 447 if ((fdwEnum & ACM_FORMATENUMF_WBITSPERSAMPLE) && 448 449 450 451 452 453 454 455 456 457 return FALSE; 458 459 426 memset(&aftd, 0, sizeof(aftd)); 427 aftd.cbStruct = sizeof(aftd); 428 aftd.dwFormatTagIndex = i; 429 if (acmFormatTagDetailsW(had, &aftd, ACM_FORMATTAGDETAILSF_INDEX) != MMSYSERR_NOERROR) 430 continue; 431 432 if ((fdwEnum & ACM_FORMATENUMF_WFORMATTAG) && aftd.dwFormatTag != pwfxRef->wFormatTag) 433 continue; 434 435 for (j = 0; j < aftd.cStandardFormats; j++) { 436 pafd->dwFormatIndex = j; 437 pafd->dwFormatTag = aftd.dwFormatTag; 438 if (acmFormatDetailsW(had, pafd, ACM_FORMATDETAILSF_INDEX) != MMSYSERR_NOERROR) 439 continue; 440 441 if ((fdwEnum & ACM_FORMATENUMF_NCHANNELS) && 442 pafd->pwfx->nChannels != pwfxRef->nChannels) 443 continue; 444 if ((fdwEnum & ACM_FORMATENUMF_NSAMPLESPERSEC) && 445 pafd->pwfx->nSamplesPerSec != pwfxRef->nSamplesPerSec) 446 continue; 447 if ((fdwEnum & ACM_FORMATENUMF_WBITSPERSAMPLE) && 448 pafd->pwfx->wBitsPerSample != pwfxRef->wBitsPerSample) 449 continue; 450 if ((fdwEnum & ACM_FORMATENUMF_HARDWARE) && 451 !(pafd->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_HARDWARE)) 452 continue; 453 454 /* more checks to be done on fdwEnum */ 455 456 if (!(fnCallback)((HACMDRIVERID)padid, pafd, dwInstance, add.fdwSupport)) 457 return FALSE; 458 } 459 /* the "formats" used by the filters are also reported */ 460 460 } 461 461 return TRUE; … … 465 465 466 466 MMRESULT WINAPI acmFormatEnumW(HACMDRIVER had, PACMFORMATDETAILSW pafd, 467 ACMFORMATENUMCBW fnCallback, DWORD dwInstance, 468 469 { 470 PWINE_ACMDRIVERID 471 WAVEFORMATEX 472 BOOL 467 ACMFORMATENUMCBW fnCallback, DWORD dwInstance, 468 DWORD fdwEnum) 469 { 470 PWINE_ACMDRIVERID padid; 471 WAVEFORMATEX wfxRef; 472 BOOL ret; 473 473 474 474 TRACE("(0x%08x, %p, %p, %ld, %ld)\n", 475 475 had, pafd, fnCallback, dwInstance, fdwEnum); 476 476 477 477 if (pafd->cbStruct < sizeof(*pafd)) return MMSYSERR_INVALPARAM; 478 478 479 479 if (fdwEnum & (ACM_FORMATENUMF_WFORMATTAG|ACM_FORMATENUMF_NCHANNELS| 480 481 480 ACM_FORMATENUMF_NSAMPLESPERSEC|ACM_FORMATENUMF_WBITSPERSAMPLE| 481 ACM_FORMATENUMF_CONVERT|ACM_FORMATENUMF_SUGGEST)) 482 482 wfxRef = *pafd->pwfx; 483 483 484 if ((fdwEnum & ACM_FORMATENUMF_HARDWARE) && 485 486 484 if ((fdwEnum & ACM_FORMATENUMF_HARDWARE) && 485 !(fdwEnum & (ACM_FORMATENUMF_INPUT|ACM_FORMATENUMF_OUTPUT))) 486 return MMSYSERR_INVALPARAM; 487 487 488 488 if ((fdwEnum & ACM_FORMATENUMF_WFORMATTAG) && 489 490 489 (pafd->dwFormatTag != pafd->pwfx->wFormatTag)) 490 return MMSYSERR_INVALPARAM; 491 491 492 492 if (fdwEnum & (ACM_FORMATENUMF_CONVERT|ACM_FORMATENUMF_SUGGEST| 493 494 493 ACM_FORMATENUMF_INPUT|ACM_FORMATENUMF_OUTPUT)) 494 FIXME("Unsupported fdwEnum values %08lx\n", fdwEnum); 495 495 496 496 if (had) { 497 HACMDRIVERID hadid; 498 499 if (acmDriverID(had, &hadid, 0) != MMSYSERR_NOERROR) 500 return MMSYSERR_INVALHANDLE; 501 MSACM_FormatEnumHelper(MSACM_GetDriverID(hadid), had, pafd, &wfxRef, 502 fnCallback, dwInstance, fdwEnum); 497 HACMDRIVERID hadid; 498 499 if (acmDriverID(had, &hadid, 0) != MMSYSERR_NOERROR) 500 return MMSYSERR_INVALHANDLE; 501 MSACM_FormatEnumHelper(MSACM_GetDriverID(hadid), had, pafd, &wfxRef, 502 fnCallback, dwInstance, fdwEnum); 503 return MMSYSERR_NOERROR; 504 } 505 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { 506 /* should check for codec only */ 507 if (!padid->bEnabled || acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != MMSYSERR_NOERROR) 508 continue; 509 ret = MSACM_FormatEnumHelper(padid, had, pafd, &wfxRef, 510 fnCallback, dwInstance, fdwEnum); 511 acmDriverClose(had, 0); 512 if (!ret) break; 513 } 503 514 return MMSYSERR_NOERROR; 504 }505 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {506 /* should check for codec only */507 if (!padid->bEnabled || acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != MMSYSERR_NOERROR)508 continue;509 ret = MSACM_FormatEnumHelper(padid, had, pafd, &wfxRef,510 fnCallback, dwInstance, fdwEnum);511 acmDriverClose(had, 0);512 if (!ret) break;513 }514 return MMSYSERR_NOERROR;515 515 } 516 516 … … 518 518 * acmFormatSuggest (MSACM32.29) 519 519 */ 520 MMRESULT WINAPI acmFormatSuggest(HACMDRIVER had, PWAVEFORMATEX pwfxSrc, 521 522 { 523 ACMDRVFORMATSUGGEST 524 MMRESULT 525 526 TRACE("(0x%08x, %p, %p, %ld, %ld)\n", 527 520 MMRESULT WINAPI acmFormatSuggest(HACMDRIVER had, PWAVEFORMATEX pwfxSrc, 521 PWAVEFORMATEX pwfxDst, DWORD cbwfxDst, DWORD fdwSuggest) 522 { 523 ACMDRVFORMATSUGGEST adfg; 524 MMRESULT mmr; 525 526 TRACE("(0x%08x, %p, %p, %ld, %ld)\n", 527 had, pwfxSrc, pwfxDst, cbwfxDst, fdwSuggest); 528 528 529 529 if (fdwSuggest & ~(ACM_FORMATSUGGESTF_NCHANNELS|ACM_FORMATSUGGESTF_NSAMPLESPERSEC| 530 531 530 ACM_FORMATSUGGESTF_WBITSPERSAMPLE|ACM_FORMATSUGGESTF_WFORMATTAG)) 531 return MMSYSERR_INVALFLAG; 532 532 533 533 adfg.cbStruct = sizeof(adfg); … … 535 535 adfg.pwfxSrc = pwfxSrc; 536 536 adfg.cbwfxSrc = (pwfxSrc->wFormatTag == WAVE_FORMAT_PCM) ? 537 537 sizeof(WAVEFORMATEX) : pwfxSrc->cbSize; 538 538 adfg.pwfxDst = pwfxDst; 539 539 adfg.cbwfxDst = cbwfxDst; 540 540 541 541 if (had == (HACMDRIVER)NULL) { 542 PWINE_ACMDRIVERIDpadid;543 544 /* MS doc says: ACM finds the best suggestion. 545 546 547 548 549 550 551 552 553 554 if (MSACM_Message(had, ACMDM_FORMAT_SUGGEST, 555 556 557 558 559 560 542 PWINE_ACMDRIVERID padid; 543 544 /* MS doc says: ACM finds the best suggestion. 545 * Well, first found will be the "best" 546 */ 547 mmr = ACMERR_NOTPOSSIBLE; 548 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { 549 /* should check for codec only */ 550 if (!padid->bEnabled || 551 acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != MMSYSERR_NOERROR) 552 continue; 553 554 if (MSACM_Message(had, ACMDM_FORMAT_SUGGEST, 555 (LPARAM)&adfg, 0L) == MMSYSERR_NOERROR) { 556 mmr = MMSYSERR_NOERROR; 557 break; 558 } 559 acmDriverClose(had, 0); 560 } 561 561 } else { 562 562 mmr = MSACM_Message(had, ACMDM_FORMAT_SUGGEST, (LPARAM)&adfg, 0L); 563 563 } 564 564 return mmr; … … 568 568 * acmFormatTagDetailsA (MSACM32.30) 569 569 */ 570 MMRESULT WINAPI acmFormatTagDetailsA(HACMDRIVER had, PACMFORMATTAGDETAILSA paftda, 571 572 { 573 ACMFORMATTAGDETAILSW 574 MMRESULT 570 MMRESULT WINAPI acmFormatTagDetailsA(HACMDRIVER had, PACMFORMATTAGDETAILSA paftda, 571 DWORD fdwDetails) 572 { 573 ACMFORMATTAGDETAILSW aftdw; 574 MMRESULT mmr; 575 575 576 576 memset(&aftdw, 0, sizeof(aftdw)); … … 581 581 mmr = acmFormatTagDetailsW(had, &aftdw, fdwDetails); 582 582 if (mmr == MMSYSERR_NOERROR) { 583 paftda->dwFormatTag = aftdw.dwFormatTag; 584 585 paftda->cbFormatSize = aftdw.cbFormatSize; 586 paftda->fdwSupport = aftdw.fdwSupport; 587 paftda->cStandardFormats = aftdw.cStandardFormats; 583 paftda->dwFormatTag = aftdw.dwFormatTag; 584 paftda->dwFormatTagIndex = aftdw.dwFormatTagIndex; 585 paftda->cbFormatSize = aftdw.cbFormatSize; 586 paftda->fdwSupport = aftdw.fdwSupport; 587 paftda->cStandardFormats = aftdw.cStandardFormats; 588 588 WideCharToMultiByte( CP_ACP, 0, aftdw.szFormatTag, -1, paftda->szFormatTag, 589 589 sizeof(paftda->szFormatTag), NULL, NULL ); … … 595 595 * acmFormatTagDetailsW (MSACM32.31) 596 596 */ 597 MMRESULT WINAPI acmFormatTagDetailsW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd, 598 599 { 600 PWINE_ACMDRIVERID 601 MMRESULT 597 MMRESULT WINAPI acmFormatTagDetailsW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd, 598 DWORD fdwDetails) 599 { 600 PWINE_ACMDRIVERID padid; 601 MMRESULT mmr; 602 602 603 603 TRACE("(0x%08x, %p, %ld)\n", had, paftd, fdwDetails); 604 604 605 605 if (fdwDetails & ~(ACM_FORMATTAGDETAILSF_FORMATTAG|ACM_FORMATTAGDETAILSF_INDEX| 606 607 606 ACM_FORMATTAGDETAILSF_LARGESTSIZE)) 607 return MMSYSERR_INVALFLAG; 608 608 609 609 switch (fdwDetails) { 610 610 case ACM_FORMATTAGDETAILSF_FORMATTAG: 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 611 if (had == (HACMDRIVER)NULL) { 612 mmr = ACMERR_NOTPOSSIBLE; 613 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { 614 /* should check for codec only */ 615 if (padid->bEnabled && acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) { 616 mmr = MSACM_Message(had, ACMDM_FORMATTAG_DETAILS, 617 (LPARAM)paftd, (LPARAM)fdwDetails); 618 acmDriverClose(had, 0); 619 if (mmr == MMSYSERR_NOERROR) break; 620 } 621 } 622 } else { 623 mmr = MSACM_Message(had, ACMDM_FORMATTAG_DETAILS, 624 (LPARAM)paftd, (LPARAM)fdwDetails); 625 } 626 break; 627 627 628 628 case ACM_FORMATTAGDETAILSF_INDEX: 629 630 631 632 629 /* FIXME should check paftd->dwFormatTagIndex < add.cFormatTags */ 630 mmr = MSACM_Message(had, ACMDM_FORMATTAG_DETAILS, 631 (LPARAM)paftd, (LPARAM)fdwDetails); 632 break; 633 633 634 634 case ACM_FORMATTAGDETAILSF_LARGESTSIZE: 635 636 ACMFORMATTAGDETAILSWtmp;637 DWORDft = paftd->dwFormatTag;638 639 640 641 642 if (padid->bEnabled && 643 644 645 646 647 648 649 650 (LPARAM)&tmp, 651 652 653 654 655 656 } 657 658 659 660 661 662 663 664 665 635 if (had == (HACMDRIVER)NULL) { 636 ACMFORMATTAGDETAILSW tmp; 637 DWORD ft = paftd->dwFormatTag; 638 639 mmr = ACMERR_NOTPOSSIBLE; 640 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { 641 /* should check for codec only */ 642 if (padid->bEnabled && 643 acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) { 644 645 memset(&tmp, 0, sizeof(tmp)); 646 tmp.cbStruct = sizeof(tmp); 647 tmp.dwFormatTag = ft; 648 649 if (MSACM_Message(had, ACMDM_FORMATTAG_DETAILS, 650 (LPARAM)&tmp, 651 (LPARAM)fdwDetails) == MMSYSERR_NOERROR) { 652 if (mmr == ACMERR_NOTPOSSIBLE || 653 paftd->cbFormatSize < tmp.cbFormatSize) { 654 *paftd = tmp; 655 mmr = MMSYSERR_NOERROR; 656 } 657 } 658 acmDriverClose(had, 0); 659 } 660 } 661 } else { 662 mmr = MSACM_Message(had, ACMDM_FORMATTAG_DETAILS, 663 (LPARAM)paftd, (LPARAM)fdwDetails); 664 } 665 break; 666 666 667 667 default: 668 669 670 } 671 672 if (mmr == MMSYSERR_NOERROR && 673 668 WARN("Unsupported fdwDetails=%08lx\n", fdwDetails); 669 mmr = MMSYSERR_ERROR; 670 } 671 672 if (mmr == MMSYSERR_NOERROR && 673 paftd->dwFormatTag == WAVE_FORMAT_PCM && paftd->szFormatTag[0] == 0) 674 674 MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFormatTag, 675 675 sizeof(paftd->szFormatTag)/sizeof(WCHAR) ); … … 679 679 680 680 struct MSACM_FormatTagEnumWtoA_Instance { 681 PACMFORMATTAGDETAILSA 682 DWORD 683 ACMFORMATTAGENUMCBA 681 PACMFORMATTAGDETAILSA paftda; 682 DWORD dwInstance; 683 ACMFORMATTAGENUMCBA fnCallback; 684 684 }; 685 685 686 686 static BOOL CALLBACK MSACM_FormatTagEnumCallbackWtoA(HACMDRIVERID hadid, 687 PACMFORMATTAGDETAILSW paftdw, 688 DWORD dwInstance, 689 687 PACMFORMATTAGDETAILSW paftdw, 688 DWORD dwInstance, 689 DWORD fdwSupport) 690 690 { 691 691 struct MSACM_FormatTagEnumWtoA_Instance* paftei; … … 693 693 paftei = (struct MSACM_FormatTagEnumWtoA_Instance*)dwInstance; 694 694 695 paftei->paftda->dwFormatTagIndex = paftdw->dwFormatTagIndex; 696 paftei->paftda->dwFormatTag = paftdw->dwFormatTag; 697 paftei->paftda->cbFormatSize = paftdw->cbFormatSize; 698 paftei->paftda->fdwSupport = paftdw->fdwSupport; 699 paftei->paftda->cStandardFormats = paftdw->cStandardFormats; 695 paftei->paftda->dwFormatTagIndex = paftdw->dwFormatTagIndex; 696 paftei->paftda->dwFormatTag = paftdw->dwFormatTag; 697 paftei->paftda->cbFormatSize = paftdw->cbFormatSize; 698 paftei->paftda->fdwSupport = paftdw->fdwSupport; 699 paftei->paftda->cStandardFormats = paftdw->cStandardFormats; 700 700 WideCharToMultiByte( CP_ACP, 0, paftdw->szFormatTag, -1, paftei->paftda->szFormatTag, 701 701 sizeof(paftei->paftda->szFormatTag), NULL, NULL ); 702 702 703 return (paftei->fnCallback)(hadid, paftei->paftda, 704 703 return (paftei->fnCallback)(hadid, paftei->paftda, 704 paftei->dwInstance, fdwSupport); 705 705 } 706 706 … … 709 709 */ 710 710 MMRESULT WINAPI acmFormatTagEnumA(HACMDRIVER had, PACMFORMATTAGDETAILSA paftda, 711 ACMFORMATTAGENUMCBA fnCallback, DWORD dwInstance, 712 713 { 714 ACMFORMATTAGDETAILSW 711 ACMFORMATTAGENUMCBA fnCallback, DWORD dwInstance, 712 DWORD fdwEnum) 713 { 714 ACMFORMATTAGDETAILSW aftdw; 715 715 struct MSACM_FormatTagEnumWtoA_Instance aftei; 716 716 … … 724 724 aftei.fnCallback = fnCallback; 725 725 726 return acmFormatTagEnumW(had, &aftdw, MSACM_FormatTagEnumCallbackWtoA, 727 726 return acmFormatTagEnumW(had, &aftdw, MSACM_FormatTagEnumCallbackWtoA, 727 (DWORD)&aftei, fdwEnum); 728 728 } 729 729 … … 732 732 */ 733 733 MMRESULT WINAPI acmFormatTagEnumW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd, 734 ACMFORMATTAGENUMCBW fnCallback, DWORD dwInstance, 735 736 { 737 PWINE_ACMDRIVERID 738 ACMDRIVERDETAILSW 739 int 740 BOOL 734 ACMFORMATTAGENUMCBW fnCallback, DWORD dwInstance, 735 DWORD fdwEnum) 736 { 737 PWINE_ACMDRIVERID padid; 738 ACMDRIVERDETAILSW add; 739 int i; 740 BOOL bPcmDone = FALSE; 741 741 742 742 TRACE("(0x%08x, %p, %p, %ld, %ld)\n", 743 had, paftd, fnCallback, dwInstance, fdwEnum); 743 had, paftd, fnCallback, dwInstance, fdwEnum); 744 744 745 745 if (paftd->cbStruct < sizeof(*paftd)) return MMSYSERR_INVALPARAM; 746 746 747 747 if (had) FIXME("had != NULL, not supported\n"); 748 748 749 749 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { 750 751 752 753 754 755 756 757 758 759 /* FIXME (EPP): I'm not sure this is the correct 760 761 * for all already loaded formats, but this will do 762 763 764 765 766 767 if (!(fnCallback)((HACMDRIVERID)padid, paftd, dwInstance, 768 769 770 771 772 773 774 775 776 750 /* should check for codec only */ 751 if (padid->bEnabled && acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == MMSYSERR_NOERROR) { 752 add.cbStruct = sizeof(add); 753 754 if (acmDriverDetailsW((HACMDRIVERID)padid, &add, 0) == MMSYSERR_NOERROR) { 755 for (i = 0; i < add.cFormatTags; i++) { 756 paftd->dwFormatTagIndex = i; 757 if (acmFormatTagDetailsW(had, paftd, ACM_FORMATTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) { 758 if (paftd->dwFormatTag == WAVE_FORMAT_PCM) { 759 /* FIXME (EPP): I'm not sure this is the correct 760 * algorithm (should make more sense to apply the same 761 * for all already loaded formats, but this will do 762 * for now 763 */ 764 if (bPcmDone) continue; 765 bPcmDone = TRUE; 766 } 767 if (!(fnCallback)((HACMDRIVERID)padid, paftd, dwInstance, 768 add.fdwSupport)) { 769 padid = NULL; 770 break; 771 } 772 } 773 } 774 } 775 } 776 acmDriverClose(had, 0); 777 777 } 778 778 return MMSYSERR_NOERROR; -
trunk/src/msacm32/initterm.cpp
r6648 r6712 1 /* $Id: initterm.cpp,v 1.7 2001-09-05 13:11:25 bird Exp $ 2 * 1 /* 3 2 * DLL entry point 4 3 * … … 54 53 case DLL_THREAD_ATTACH: 55 54 case DLL_THREAD_DETACH: 56 55 return MSACM32_LibMain(hinstDLL, fdwReason, fImpLoad); 57 56 58 57 case DLL_PROCESS_DETACH: 59 60 61 58 MSACM32_LibMain(hinstDLL, fdwReason, fImpLoad); 59 ctordtorTerm(); 60 return TRUE; 62 61 } 63 62 return FALSE; … … 89 88 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/ 90 89 91 92 if(dllHandle == 0) 93 90 dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab); 91 if(dllHandle == 0) 92 return 0UL; 94 93 95 94 break; 96 95 case 1 : 97 96 if(dllHandle) { 98 97 UnregisterLxDll(dllHandle); 99 98 } 100 99 break; -
trunk/src/msacm32/internal.c
r6648 r6712 1 1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */ 2 /* $Id: internal.c,v 1.2 2001-09-05 13:11:26 bird Exp $ */ 2 3 3 /* 4 4 * MSACM32 library 5 5 * 6 6 * Copyright 1998 Patrik Stridvall 7 * 1999Eric Pouech7 * 1999 Eric Pouech 8 8 */ 9 9 … … 34 34 35 35 /*********************************************************************** 36 * MSACM_RegisterDriver() 36 * MSACM_RegisterDriver() 37 37 */ 38 38 PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName, 39 40 { 39 HINSTANCE hinstModule) 40 { 41 41 PWINE_ACMDRIVERID padid; 42 42 … … 64 64 padid->pPrevACMDriverID = MSACM_pLastACMDriverID; 65 65 if (MSACM_pLastACMDriverID) 66 66 MSACM_pLastACMDriverID->pNextACMDriverID = padid; 67 67 MSACM_pLastACMDriverID = padid; 68 68 if (!MSACM_pFirstACMDriverID) 69 70 69 MSACM_pFirstACMDriverID = padid; 70 71 71 return padid; 72 72 } 73 73 74 74 /*********************************************************************** 75 * MSACM_RegisterAllDrivers() 75 * MSACM_RegisterAllDrivers() 76 76 */ 77 77 void MSACM_RegisterAllDrivers(void) … … 80 80 DWORD dwBufferLength; 81 81 82 /* FIXME 82 /* FIXME 83 83 * What if the user edits system.ini while the program is running? 84 84 * Does Windows handle that? 85 85 */ 86 86 if (MSACM_pFirstACMDriverID) 87 88 87 return; 88 89 89 /* FIXME: Do not work! How do I determine the section length? */ 90 90 dwBufferLength = 1024; 91 /* EPP 92 91 /* EPP GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */ 92 93 93 pszBuffer = (LPSTR) HeapAlloc(MSACM_hHeap, 0, dwBufferLength); 94 94 if (GetPrivateProfileSectionA("drivers32", pszBuffer, dwBufferLength, "system.ini")) { 95 char* s = pszBuffer; 96 while (*s) { 97 if (!strncasecmp("MSACM.", s, 6)) { 98 char *s2 = s; 99 while (*s2 != '\0' && *s2 != '=') s2++; 100 if (*s2) { 101 *s2 = '\0'; 102 MSACM_RegisterDriver(s, s2 + 1, 0); 103 *s2 = '='; 104 } 105 } 106 s += strlen(s) + 1; /* Either next char or \0 */ 95 char* s = pszBuffer; 96 while (*s) { 97 if (!strncasecmp("MSACM.", s, 6)) { 98 char *s2 = s; 99 while (*s2 != '\0' && *s2 != '=') s2++; 100 if (*s2) { 101 *s2 = '\0'; 102 MSACM_RegisterDriver(s, s2 + 1, 0); 103 *s2 = '='; 104 } 105 } 106 s += strlen(s) + 1; /* Either next char or \0 */ 107 } 107 108 } 108 } 109 109 110 110 HeapFree(MSACM_hHeap, 0, pszBuffer); 111 111 … … 119 119 { 120 120 PWINE_ACMDRIVERID pNextACMDriverID; 121 121 122 122 while (p->pACMDriverList) 123 124 123 acmDriverClose((HACMDRIVER) p->pACMDriverList, 0); 124 125 125 if (p->pszDriverAlias) 126 126 HeapFree(MSACM_hHeap, 0, p->pszDriverAlias); 127 127 if (p->pszFileName) 128 129 128 HeapFree(MSACM_hHeap, 0, p->pszFileName); 129 130 130 if (p == MSACM_pFirstACMDriverID) 131 131 MSACM_pFirstACMDriverID = p->pNextACMDriverID; 132 132 if (p == MSACM_pLastACMDriverID) 133 133 MSACM_pLastACMDriverID = p->pPrevACMDriverID; 134 134 135 135 if (p->pPrevACMDriverID) 136 136 p->pPrevACMDriverID->pNextACMDriverID = p->pNextACMDriverID; 137 137 if (p->pNextACMDriverID) 138 139 138 p->pNextACMDriverID->pPrevACMDriverID = p->pPrevACMDriverID; 139 140 140 pNextACMDriverID = p->pNextACMDriverID; 141 141 142 142 HeapFree(MSACM_hHeap, 0, p); 143 143 144 144 return pNextACMDriverID; 145 145 } … … 162 162 PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj, DWORD type) 163 163 { 164 PWINE_ACMOBJ 164 PWINE_ACMOBJ pao = (PWINE_ACMOBJ)hObj; 165 165 166 166 if (pao == NULL || IsBadReadPtr(pao, sizeof(WINE_ACMOBJ)) || 167 168 167 ((type != WINE_ACMOBJ_DONTCARE) && (type != pao->dwType))) 168 return NULL; 169 169 return pao; 170 170 } 171 171 172 172 /*********************************************************************** 173 * MSACM_GetDriverID() 173 * MSACM_GetDriverID() 174 174 */ 175 175 PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID) … … 191 191 MMRESULT MSACM_Message(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2) 192 192 { 193 PWINE_ACMDRIVER 193 PWINE_ACMDRIVER pad = MSACM_GetDriver(had); 194 194 195 195 return pad ? SendDriverMessage(pad->hDrvr, uMsg, lParam1, lParam2) : MMSYSERR_INVALHANDLE; -
trunk/src/msacm32/msacm32_main.c
r6648 r6712 1 1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */ 2 /* $Id: msacm32_main.c,v 1.2 2001-09-05 13:11:26 bird Exp $ */ 2 3 3 /* 4 4 * MSACM32 library 5 5 * 6 6 * Copyright 1998 Patrik Stridvall 7 * 1999Eric Pouech7 * 1999 Eric Pouech 8 8 */ 9 9 … … 17 17 18 18 DEFAULT_DEBUG_CHANNEL(msacm); 19 19 20 20 /**********************************************************************/ 21 22 HINSTANCE 21 22 HINSTANCE MSACM_hInstance32 = 0; 23 23 24 24 /*********************************************************************** 25 * MSACM_LibMain (MSACM32.init) 25 * MSACM_LibMain (MSACM32.init) 26 26 */ 27 27 BOOL WINAPI MSACM32_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) … … 34 34 MSACM_hInstance32 = hInstDLL; 35 35 MSACM_RegisterAllDrivers(); 36 36 break; 37 37 case DLL_PROCESS_DETACH: 38 38 MSACM_UnregisterAllDrivers(); … … 40 40 MSACM_hHeap = (HANDLE) NULL; 41 41 MSACM_hInstance32 = (HINSTANCE)NULL; 42 42 break; 43 43 case DLL_THREAD_ATTACH: 44 44 break; 45 45 case DLL_THREAD_DETACH: 46 46 break; 47 47 default: 48 48 break; 49 49 } 50 50 return TRUE; … … 67 67 { 68 68 case VER_PLATFORM_WIN32_NT: 69 69 return 0x04000565; /* 4.0.1381 */ 70 70 default: 71 71 FIXME("%ld not supported",version.dwPlatformId); 72 72 case VER_PLATFORM_WIN32_WINDOWS: 73 73 return 0x04000000; /* 4.0.0 */ 74 74 } 75 75 } … … 86 86 MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric) 87 87 { 88 PWINE_ACMOBJ 89 BOOL 90 PWINE_ACMDRIVERID 91 DWORD 92 MMRESULT 88 PWINE_ACMOBJ pao = MSACM_GetObj(hao, WINE_ACMOBJ_DONTCARE); 89 BOOL bLocal = TRUE; 90 PWINE_ACMDRIVERID padid; 91 DWORD val = 0; 92 MMRESULT mmr = MMSYSERR_NOERROR; 93 93 94 94 TRACE("(0x%08x, %d, %p);\n", hao, uMetric, pMetric); 95 95 96 96 switch (uMetric) { 97 97 case ACM_METRIC_COUNT_DRIVERS: 98 99 98 bLocal = FALSE; 99 /* fall thru */ 100 100 case ACM_METRIC_COUNT_LOCAL_DRIVERS: 101 102 103 104 105 106 107 101 if (!pao) 102 return MMSYSERR_INVALHANDLE; 103 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) 104 if (padid->bEnabled /* && (local(padid) || !bLocal) */) 105 val++; 106 *(LPDWORD)pMetric = val; 107 break; 108 108 109 109 case ACM_METRIC_COUNT_CODECS: 110 111 112 113 110 if (!pao) 111 return MMSYSERR_INVALHANDLE; 112 bLocal = FALSE; 113 /* fall thru */ 114 114 case ACM_METRIC_COUNT_LOCAL_CODECS: 115 116 117 118 119 120 115 /* FIXME: don't know how to differentiate codec, converters & filters yet */ 116 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) 117 if (padid->bEnabled /* && (local(padid) || !bLocal) */) 118 val++; 119 *(LPDWORD)pMetric = val; 120 break; 121 121 122 122 case ACM_METRIC_COUNT_CONVERTERS: 123 124 123 bLocal = FALSE; 124 /* fall thru */ 125 125 case ACM_METRIC_COUNT_LOCAL_CONVERTERS: 126 127 128 129 130 131 126 /* FIXME: don't know how to differentiate codec, converters & filters yet */ 127 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) 128 if (padid->bEnabled /* && (local(padid) || !bLocal) */) 129 val++; 130 *(LPDWORD)pMetric = val; 131 break; 132 132 133 133 case ACM_METRIC_COUNT_FILTERS: 134 135 134 bLocal = FALSE; 135 /* fall thru */ 136 136 case ACM_METRIC_COUNT_LOCAL_FILTERS: 137 138 139 140 141 142 137 /* FIXME: don't know how to differentiate codec, converters & filters yet */ 138 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) 139 if (padid->bEnabled /* && (local(padid) || !bLocal) */) 140 val++; 141 *(LPDWORD)pMetric = val; 142 break; 143 143 144 144 case ACM_METRIC_COUNT_DISABLED: 145 146 145 bLocal = FALSE; 146 /* fall thru */ 147 147 case ACM_METRIC_COUNT_LOCAL_DISABLED: 148 if (!pao) 149 return MMSYSERR_INVALHANDLE; 150 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) 151 if (!padid->bEnabled /* && (local(padid) || !bLocal) */) 152 val++; 153 *(LPDWORD)pMetric = val; 154 break; 148 if (!pao) 149 return MMSYSERR_INVALHANDLE; 150 for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) 151 if (!padid->bEnabled /* && (local(padid) || !bLocal) */) 152 val++; 153 *(LPDWORD)pMetric = val; 154 break; 155 156 case ACM_METRIC_MAX_SIZE_FORMAT: 157 { 158 ACMFORMATTAGDETAILSW aftd; 155 159 156 case ACM_METRIC_MAX_SIZE_FORMAT: 157 { 158 ACMFORMATTAGDETAILSW aftd; 160 aftd.cbStruct = sizeof(aftd); 161 aftd.dwFormatTag = WAVE_FORMAT_UNKNOWN; 159 162 160 aftd.cbStruct = sizeof(aftd); 161 aftd.dwFormatTag = WAVE_FORMAT_UNKNOWN; 162 163 if (hao == (HACMOBJ)NULL) { 164 mmr = acmFormatTagDetailsW((HACMDRIVER)NULL, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE); 165 } else if (MSACM_GetObj(hao, WINE_ACMOBJ_DRIVER)) { 166 mmr = acmFormatTagDetailsW((HACMDRIVER)hao, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE); 167 } else if (MSACM_GetObj(hao, WINE_ACMOBJ_DRIVERID)) { 168 HACMDRIVER had; 169 170 if (acmDriverOpen(&had, (HACMDRIVERID)hao, 0) == 0) { 171 mmr = acmFormatTagDetailsW((HACMDRIVER)hao, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE); 172 acmDriverClose(had, 0); 173 } 174 } else { 175 mmr = MMSYSERR_INVALHANDLE; 176 } 177 if (mmr == MMSYSERR_NOERROR) *(LPDWORD)pMetric = aftd.cbFormatSize; 178 } 163 if (hao == (HACMOBJ)NULL) { 164 mmr = acmFormatTagDetailsW((HACMDRIVER)NULL, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE); 165 } else if (MSACM_GetObj(hao, WINE_ACMOBJ_DRIVER)) { 166 mmr = acmFormatTagDetailsW((HACMDRIVER)hao, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE); 167 } else if (MSACM_GetObj(hao, WINE_ACMOBJ_DRIVERID)) { 168 HACMDRIVER had; 169 170 if (acmDriverOpen(&had, (HACMDRIVERID)hao, 0) == 0) { 171 mmr = acmFormatTagDetailsW((HACMDRIVER)hao, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE); 172 acmDriverClose(had, 0); 173 } 174 } else { 175 mmr = MMSYSERR_INVALHANDLE; 176 } 177 if (mmr == MMSYSERR_NOERROR) *(LPDWORD)pMetric = aftd.cbFormatSize; 178 } 179 179 break; 180 180 … … 186 186 case ACM_METRIC_DRIVER_PRIORITY: 187 187 default: 188 189 188 FIXME("(0x%08x, %d, %p): stub\n", hao, uMetric, pMetric); 189 mmr = MMSYSERR_NOTSUPPORTED; 190 190 } 191 191 return mmr; -
trunk/src/msacm32/pcmconverter.c
r6648 r6712 1 1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */ 2 /* $Id: pcmconverter.c,v 1.2 2001-09-05 13:11:26 bird Exp $ */ 2 3 3 /* 4 4 * MSACM32 library 5 5 * 6 * Copyright 2000 7 * 8 * 9 * + most of the computation should be done in fixed point arithmetic10 * 11 * 12 * 13 * 14 * 15 * 6 * Copyright 2000 Eric Pouech 7 * 8 * FIXME / TODO list 9 * + most of the computation should be done in fixed point arithmetic 10 * instead of floating point (16 bits for integral part, and 16 bits 11 * for fractional part for example) 12 * + implement PCM_FormatSuggest function 13 * + get rid of hack for PCM_DriverProc (msacm32.dll shouldn't export 14 * a DriverProc, but this would require implementing a generic 15 * embedded driver handling scheme in msacm32.dll which isn't done yet 16 16 */ 17 17 … … 35 35 * PCM_drvOpen 36 36 */ 37 static DWORDPCM_drvOpen(LPCSTR str)37 static DWORD PCM_drvOpen(LPCSTR str) 38 38 { 39 39 return 1; … … 43 43 * PCM_drvClose 44 44 */ 45 static DWORDPCM_drvClose(DWORD dwDevID)45 static DWORD PCM_drvClose(DWORD dwDevID) 46 46 { 47 47 return 1; 48 48 } 49 49 50 #define NUM_PCM_FORMATS(sizeof(PCM_Formats) / sizeof(PCM_Formats[0]))51 #define NUM_OF(a,b)(((a)+(b)-1)/(b))50 #define NUM_PCM_FORMATS (sizeof(PCM_Formats) / sizeof(PCM_Formats[0])) 51 #define NUM_OF(a,b) (((a)+(b)-1)/(b)) 52 52 53 53 /* flags for fdwDriver */ 54 #define PCM_RESAMPLE 54 #define PCM_RESAMPLE 1 55 55 56 56 /* data used while converting */ … … 58 58 /* conversion routine, depending if rate conversion is required */ 59 59 union { 60 61 void (*cvtChangeRate)(struct tagAcmPcmData*, const unsigned char*, 62 60 void (*cvtKeepRate)(const unsigned char*, int, unsigned char*); 61 void (*cvtChangeRate)(struct tagAcmPcmData*, const unsigned char*, 62 LPDWORD, unsigned char*, LPDWORD); 63 63 } cvt; 64 64 /* the following fields are used only with rate conversion) */ 65 DWORD srcPos;/* position in source stream */66 double dstPos;/* position in destination stream */67 double dstIncr; /* value to increment dst stream when src stream68 65 DWORD srcPos; /* position in source stream */ 66 double dstPos; /* position in destination stream */ 67 double dstIncr; /* value to increment dst stream when src stream 68 is incremented by 1 */ 69 69 /* last source stream value read */ 70 70 union { 71 unsigned char b;/* 8 bit value */72 short s;/* 16 bit value */71 unsigned char b; /* 8 bit value */ 72 short s; /* 16 bit value */ 73 73 } last[2]; /* two channels max (stereo) */ 74 74 } AcmPcmData; … … 77 77 * also helps given a unique index to each of the supported formats 78 78 */ 79 static 80 int 81 int 82 int 79 static struct { 80 int nChannels; 81 int nBits; 82 int rate; 83 83 } PCM_Formats[] = { 84 84 {1, 8, 8000}, {2, 8, 8000}, {1, 16, 8000}, {2, 16, 8000}, … … 91 91 * PCM_GetFormatIndex 92 92 */ 93 static DWORDPCM_GetFormatIndex(LPWAVEFORMATEX wfx)93 static DWORD PCM_GetFormatIndex(LPWAVEFORMATEX wfx) 94 94 { 95 95 int i; 96 96 97 97 for (i = 0; i < NUM_PCM_FORMATS; i++) { 98 99 100 101 98 if (wfx->nChannels == PCM_Formats[i].nChannels && 99 wfx->nSamplesPerSec == PCM_Formats[i].rate && 100 wfx->wBitsPerSample == PCM_Formats[i].nBits) 101 return i; 102 102 } 103 103 return 0xFFFFFFFF; … … 107 107 * 108 108 * parameters: 109 * 110 * 111 * 112 * 109 * + 8 bit unsigned vs 16 bit signed 110 * + mono vs stereo (1 or 2 channels) 111 * + sampling rate (8.0, 11.025, 22.05, 44.1 kHz are defined, but algo shall work 112 * in all cases) 113 113 * 114 114 * mono => stereo: copy the same sample on Left & Right channels 115 115 * stereo =) mono: use the average value of samples from Left & Right channels 116 116 * resampling; we lookup for each destination sample the two source adjacent samples 117 * were src <= dst < src+1 (dst is increased by a fractional value which is118 * 119 * 117 * were src <= dst < src+1 (dst is increased by a fractional value which is 118 * equivalent to the increment by one on src); then we use a linear 119 * interpolation between src and src+1 120 120 */ 121 121 … … 125 125 * Converts a 8 bit sample to a 16 bit one 126 126 */ 127 static inline short C816(unsigned char b) 127 static inline short C816(unsigned char b) 128 128 { 129 129 return (short)(b ^ 0x80) * 256; … … 135 135 * Converts a 16 bit sample to a 8 bit one (data loss !!) 136 136 */ 137 static inline unsigned char C168(short s) 137 static inline unsigned char C168(short s) 138 138 { 139 139 return HIBYTE(s) ^ (unsigned char)0x80; … … 164 164 * M16 165 165 * 166 * Convert the (l,r) 16 bit stereo sample into a 16 bit mono 166 * Convert the (l,r) 16 bit stereo sample into a 16 bit mono 167 167 * (takes the mid-point of the two values) 168 168 */ … … 175 175 * M8 176 176 * 177 * Convert the (l,r) 8 bit stereo sample into a 8 bit mono 177 * Convert the (l,r) 8 bit stereo sample into a 8 bit mono 178 178 * (takes the mid-point of the two values) 179 179 */ … … 194 194 */ 195 195 196 static 196 static void cvtMM88K(const unsigned char* src, int ns, unsigned char* dst) 197 197 { 198 198 memcpy(dst, src, ns); 199 199 } 200 200 201 static 201 static void cvtSS88K(const unsigned char* src, int ns, unsigned char* dst) 202 202 { 203 203 memcpy(dst, src, ns * 2); 204 204 } 205 205 206 static 206 static void cvtMM1616K(const unsigned char* src, int ns, unsigned char* dst) 207 207 { 208 208 memcpy(dst, src, ns * 2); 209 209 } 210 210 211 static 211 static void cvtSS1616K(const unsigned char* src, int ns, unsigned char* dst) 212 212 { 213 213 memcpy(dst, src, ns * 4); 214 214 } 215 215 216 static 217 { 218 while (ns--) { 219 220 221 } 222 } 223 224 static 225 { 226 short 227 228 while (ns--) { 229 230 W16(dst, v);dst += 2;231 W16(dst, v);dst += 2;232 } 233 } 234 235 static 216 static void cvtMS88K(const unsigned char* src, int ns, unsigned char* dst) 217 { 218 while (ns--) { 219 *dst++ = *src; 220 *dst++ = *src++; 221 } 222 } 223 224 static void cvtMS816K(const unsigned char* src, int ns, unsigned char* dst) 225 { 226 short v; 227 228 while (ns--) { 229 v = C816(*src++); 230 W16(dst, v); dst += 2; 231 W16(dst, v); dst += 2; 232 } 233 } 234 235 static void cvtMS168K(const unsigned char* src, int ns, unsigned char* dst) 236 236 { 237 237 unsigned char v; 238 239 while (ns--) { 240 v = C168(R16(src));src += 2;241 242 243 } 244 } 245 246 static 247 { 248 short 249 250 while (ns--) { 251 v = R16(src);src += 2;252 W16(dst, v);dst += 2;253 W16(dst, v);dst += 2;254 } 255 } 256 257 static 258 { 259 while (ns--) { 260 261 262 } 263 } 264 265 static 266 { 267 short 268 269 while (ns--) { 270 271 272 W16(dst, v);dst += 2;273 } 274 } 275 276 static 277 { 278 while (ns--) { 279 280 281 } 282 } 283 284 static 285 { 286 while (ns--) { 287 W16(dst, M16(R16(src),R16(src+2)));dst += 2;288 289 } 290 } 291 292 static 293 { 294 while (ns--) { 295 W16(dst, C816(*src++));dst += 2;296 } 297 } 298 299 static 300 { 301 while (ns--) { 302 W16(dst, C816(*src++));dst += 2;303 W16(dst, C816(*src++));dst += 2;304 } 305 } 306 307 static 308 { 309 while (ns--) { 310 *dst++ = C168(R16(src));src += 2;311 } 312 } 313 314 static 315 { 316 while (ns--) { 317 *dst++ = C168(R16(src));src += 2;318 *dst++ = C168(R16(src));src += 2;319 } 320 } 321 322 static 323 cvtSS88K, 324 cvtSS816K, 325 cvtSS168K, 238 239 while (ns--) { 240 v = C168(R16(src)); src += 2; 241 *dst++ = v; 242 *dst++ = v; 243 } 244 } 245 246 static void cvtMS1616K(const unsigned char* src, int ns, unsigned char* dst) 247 { 248 short v; 249 250 while (ns--) { 251 v = R16(src); src += 2; 252 W16(dst, v); dst += 2; 253 W16(dst, v); dst += 2; 254 } 255 } 256 257 static void cvtSM88K(const unsigned char* src, int ns, unsigned char* dst) 258 { 259 while (ns--) { 260 *dst++ = M8(src[0], src[1]); 261 src += 2; 262 } 263 } 264 265 static void cvtSM816K(const unsigned char* src, int ns, unsigned char* dst) 266 { 267 short v; 268 269 while (ns--) { 270 v = M16(C816(src[0]), C816(src[1])); 271 src += 2; 272 W16(dst, v); dst += 2; 273 } 274 } 275 276 static void cvtSM168K(const unsigned char* src, int ns, unsigned char* dst) 277 { 278 while (ns--) { 279 *dst++ = C168(M16(R16(src), R16(src + 2))); 280 src += 4; 281 } 282 } 283 284 static void cvtSM1616K(const unsigned char* src, int ns, unsigned char* dst) 285 { 286 while (ns--) { 287 W16(dst, M16(R16(src),R16(src+2))); dst += 2; 288 src += 4; 289 } 290 } 291 292 static void cvtMM816K(const unsigned char* src, int ns, unsigned char* dst) 293 { 294 while (ns--) { 295 W16(dst, C816(*src++)); dst += 2; 296 } 297 } 298 299 static void cvtSS816K(const unsigned char* src, int ns, unsigned char* dst) 300 { 301 while (ns--) { 302 W16(dst, C816(*src++)); dst += 2; 303 W16(dst, C816(*src++)); dst += 2; 304 } 305 } 306 307 static void cvtMM168K(const unsigned char* src, int ns, unsigned char* dst) 308 { 309 while (ns--) { 310 *dst++ = C168(R16(src)); src += 2; 311 } 312 } 313 314 static void cvtSS168K(const unsigned char* src, int ns, unsigned char* dst) 315 { 316 while (ns--) { 317 *dst++ = C168(R16(src)); src += 2; 318 *dst++ = C168(R16(src)); src += 2; 319 } 320 } 321 322 static void (*PCM_ConvertKeepRate[16])(const unsigned char*, int, unsigned char*) = { 323 cvtSS88K, cvtSM88K, cvtMS88K, cvtMM88K, 324 cvtSS816K, cvtSM816K, cvtMS816K, cvtMM816K, 325 cvtSS168K, cvtSM168K, cvtMS168K, cvtMM168K, 326 326 cvtSS1616K, cvtSM1616K, cvtMS1616K, cvtMM1616K, 327 327 }; … … 333 333 * Linear interpolation is used 334 334 */ 335 static inline doubleI(double v1, double v2, double r)335 static inline double I(double v1, double v2, double r) 336 336 { 337 337 if (0.0 >= r || r > 1.0) FIXME("r!! %f\n", r); … … 339 339 } 340 340 341 static void cvtSS88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,342 343 { 344 double 345 346 while (*nsrc != 0 && *ndst != 0) { 347 348 349 350 351 352 353 354 355 356 357 358 341 static void cvtSS88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 342 unsigned char* dst, LPDWORD ndst) 343 { 344 double r; 345 346 while (*nsrc != 0 && *ndst != 0) { 347 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 348 if (*nsrc == 0) return; 349 apd->last[0].b = *src++; 350 apd->last[1].b = *src++; 351 apd->srcPos++; 352 (*nsrc)--; 353 } 354 /* now do the interpolation */ 355 *dst++ = I(apd->last[0].b, src[0], r); 356 *dst++ = I(apd->last[1].b, src[1], r); 357 apd->dstPos += apd->dstIncr; 358 (*ndst)--; 359 359 } 360 360 } … … 368 368 * 369 369 */ 370 static void cvtSM88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,371 372 { 373 double 374 375 while (*nsrc != 0 && *ndst != 0) { 376 377 378 379 380 381 382 383 384 385 386 387 } 388 } 389 390 static void cvtMS88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,391 392 { 393 double 394 395 while (*nsrc != 0 && *ndst != 0) { 396 397 398 399 400 401 402 403 404 405 406 407 } 408 } 409 410 static void cvtMM88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,411 412 { 413 double 414 415 while (*nsrc != 0 && *ndst != 0) { 416 417 418 419 420 421 422 423 424 425 426 } 427 } 428 429 static void cvtSS816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,430 431 { 432 double 433 434 while (*nsrc != 0 && *ndst != 0) { 435 436 437 438 439 440 441 442 443 W16(dst, I(C816(apd->last[0].b), C816(src[0]), r));dst += 2;444 W16(dst, I(C816(apd->last[1].b), C816(src[1]), r));dst += 2;445 446 447 } 448 } 449 450 static void cvtSM816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,451 452 { 453 double 454 455 while (*nsrc != 0 && *ndst != 0) { 456 457 458 459 460 461 462 463 464 465 466 467 468 469 } 470 } 471 472 static void cvtMS816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,473 474 { 475 double 476 short 477 478 while (*nsrc != 0 && *ndst != 0) { 479 480 481 482 483 484 485 486 487 W16(dst, v);dst += 2;488 W16(dst, v);dst += 2;489 490 491 } 492 } 493 494 static void cvtMM816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,495 496 { 497 double 498 499 while (*nsrc != 0 && *ndst != 0) { 500 501 502 503 504 505 506 507 508 509 510 511 } 512 } 513 514 static void cvtSS168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,515 516 { 517 double 518 519 while (*nsrc != 0 && *ndst != 0) { 520 521 522 apd->last[0].s = R16(src);src += 2;523 apd->last[1].s = R16(src);src += 2;524 525 526 527 528 529 530 531 532 } 533 } 534 535 static void cvtSM168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,536 537 { 538 double 539 540 while (*nsrc != 0 && *ndst != 0) { 541 542 543 apd->last[0].s = R16(src);src += 2;544 apd->last[1].s = R16(src);src += 2;545 546 547 548 549 *dst++ = C168(I(M16(apd->last[0].s, apd->last[1].s), 550 551 552 553 } 554 } 555 556 557 static void cvtMS168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,558 559 { 560 double 561 562 while (*nsrc != 0 && *ndst != 0) { 563 564 565 apd->last[0].s = R16(src);src += 2;566 567 568 569 570 dst[0] = dst[1] = C168(I(apd->last[0].s, R16(src), r));dst += 2;571 572 573 } 574 } 575 576 577 static void cvtMM168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,578 579 { 580 double 581 582 while (*nsrc != 0 && *ndst != 0) { 583 584 585 apd->last[0].s = R16(src);src += 2;586 587 588 589 590 591 592 593 } 594 } 595 596 static void cvtSS1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,597 598 { 599 double 600 601 while (*nsrc != 0 && *ndst != 0) { 602 603 604 apd->last[0].s = R16(src);src += 2;605 apd->last[1].s = R16(src);src += 2;606 607 608 609 610 W16(dst, I(apd->last[0].s, R16(src) , r));dst += 2;611 W16(dst, I(apd->last[1].s, R16(src+2), r));dst += 2;612 613 614 } 615 } 616 617 static void cvtSM1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,618 619 { 620 double 621 622 while (*nsrc != 0 && *ndst != 0) { 623 624 625 apd->last[0].s = R16(src);src += 2;626 apd->last[1].s = R16(src);src += 2;627 628 629 630 631 632 633 634 635 636 } 637 } 638 639 static void cvtMS1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,640 641 { 642 double 643 short 644 645 while (*nsrc != 0 && *ndst != 0) { 646 647 648 apd->last[0].s = R16(src);src += 2;649 650 651 652 653 654 W16(dst, v);dst += 2;655 W16(dst, v);dst += 2;656 657 658 } 659 } 660 661 static void cvtMM1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,662 663 { 664 double 665 666 while (*nsrc != 0 && *ndst != 0) { 667 668 669 apd->last[0].s = R16(src);src += 2;670 671 672 673 674 W16(dst, I(apd->last[0].s, R16(src), r));dst += 2;675 676 677 } 678 } 679 680 static void (*PCM_ConvertChangeRate[16])(AcmPcmData* apd,681 const unsigned char* src, LPDWORD nsrc, 682 370 static void cvtSM88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 371 unsigned char* dst, LPDWORD ndst) 372 { 373 double r; 374 375 while (*nsrc != 0 && *ndst != 0) { 376 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 377 if (*nsrc == 0) return; 378 apd->last[0].b = *src++; 379 apd->last[1].b = *src++; 380 apd->srcPos++; 381 (*nsrc)--; 382 } 383 /* now do the interpolation */ 384 *dst++ = I(M8(apd->last[0].b, apd->last[1].b), M8(src[0], src[1]), r); 385 apd->dstPos += apd->dstIncr; 386 (*ndst)--; 387 } 388 } 389 390 static void cvtMS88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 391 unsigned char* dst, LPDWORD ndst) 392 { 393 double r; 394 395 while (*nsrc != 0 && *ndst != 0) { 396 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 397 if (*nsrc == 0) return; 398 apd->last[0].b = *src++; 399 apd->srcPos++; 400 (*nsrc)--; 401 } 402 /* now do the interpolation */ 403 dst[0] = dst[1] = I(apd->last[0].b, src[0], r); 404 dst += 2; 405 apd->dstPos += apd->dstIncr; 406 (*ndst)--; 407 } 408 } 409 410 static void cvtMM88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 411 unsigned char* dst, LPDWORD ndst) 412 { 413 double r; 414 415 while (*nsrc != 0 && *ndst != 0) { 416 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 417 if (*nsrc == 0) return; 418 apd->last[0].b = *src++; 419 apd->srcPos++; 420 (*nsrc)--; 421 } 422 /* now do the interpolation */ 423 *dst++ = I(apd->last[0].b, src[0], r); 424 apd->dstPos += apd->dstIncr; 425 (*ndst)--; 426 } 427 } 428 429 static void cvtSS816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 430 unsigned char* dst, LPDWORD ndst) 431 { 432 double r; 433 434 while (*nsrc != 0 && *ndst != 0) { 435 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 436 if (*nsrc == 0) return; 437 apd->last[0].b = *src++; 438 apd->last[1].b = *src++; 439 apd->srcPos++; 440 (*nsrc)--; 441 } 442 /* now do the interpolation */ 443 W16(dst, I(C816(apd->last[0].b), C816(src[0]), r)); dst += 2; 444 W16(dst, I(C816(apd->last[1].b), C816(src[1]), r)); dst += 2; 445 apd->dstPos += apd->dstIncr; 446 (*ndst)--; 447 } 448 } 449 450 static void cvtSM816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 451 unsigned char* dst, LPDWORD ndst) 452 { 453 double r; 454 455 while (*nsrc != 0 && *ndst != 0) { 456 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 457 if (*nsrc == 0) return; 458 apd->last[0].b = *src++; 459 apd->last[1].b = *src++; 460 apd->srcPos++; 461 (*nsrc)--; 462 } 463 /* now do the interpolation */ 464 W16(dst, I(M16(C816(apd->last[0].b), C816(apd->last[1].b)), 465 M16(C816(src[0]), C816(src[1])), r)); 466 dst += 2; 467 apd->dstPos += apd->dstIncr; 468 (*ndst)--; 469 } 470 } 471 472 static void cvtMS816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 473 unsigned char* dst, LPDWORD ndst) 474 { 475 double r; 476 short v; 477 478 while (*nsrc != 0 && *ndst != 0) { 479 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 480 if (*nsrc == 0) return; 481 apd->last[0].b = *src++; 482 apd->srcPos++; 483 (*nsrc)--; 484 } 485 /* now do the interpolation */ 486 v = I(C816(apd->last[0].b), C816(src[0]), r); 487 W16(dst, v); dst += 2; 488 W16(dst, v); dst += 2; 489 apd->dstPos += apd->dstIncr; 490 (*ndst)--; 491 } 492 } 493 494 static void cvtMM816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 495 unsigned char* dst, LPDWORD ndst) 496 { 497 double r; 498 499 while (*nsrc != 0 && *ndst != 0) { 500 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 501 if (*nsrc == 0) return; 502 apd->last[0].b = *src++; 503 apd->srcPos++; 504 (*nsrc)--; 505 } 506 /* now do the interpolation */ 507 W16(dst, I(C816(apd->last[0].b), C816(src[0]), r)); 508 dst += 2; 509 apd->dstPos += apd->dstIncr; 510 (*ndst)--; 511 } 512 } 513 514 static void cvtSS168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 515 unsigned char* dst, LPDWORD ndst) 516 { 517 double r; 518 519 while (*nsrc != 0 && *ndst != 0) { 520 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 521 if (*nsrc == 0) return; 522 apd->last[0].s = R16(src); src += 2; 523 apd->last[1].s = R16(src); src += 2; 524 apd->srcPos++; 525 (*nsrc)--; 526 } 527 /* now do the interpolation */ 528 *dst++ = C168(I(apd->last[0].s, R16(src) , r)); 529 *dst++ = C168(I(apd->last[1].s, R16(src+2), r)); 530 apd->dstPos += apd->dstIncr; 531 (*ndst)--; 532 } 533 } 534 535 static void cvtSM168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 536 unsigned char* dst, LPDWORD ndst) 537 { 538 double r; 539 540 while (*nsrc != 0 && *ndst != 0) { 541 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 542 if (*nsrc == 0) return; 543 apd->last[0].s = R16(src); src += 2; 544 apd->last[1].s = R16(src); src += 2; 545 apd->srcPos++; 546 (*nsrc)--; 547 } 548 /* now do the interpolation */ 549 *dst++ = C168(I(M16(apd->last[0].s, apd->last[1].s), 550 M16(R16(src), R16(src + 2)), r)); 551 apd->dstPos += apd->dstIncr; 552 (*ndst)--; 553 } 554 } 555 556 557 static void cvtMS168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 558 unsigned char* dst, LPDWORD ndst) 559 { 560 double r; 561 562 while (*nsrc != 0 && *ndst != 0) { 563 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 564 if (*nsrc == 0) return; 565 apd->last[0].s = R16(src); src += 2; 566 apd->srcPos++; 567 (*nsrc)--; 568 } 569 /* now do the interpolation */ 570 dst[0] = dst[1] = C168(I(apd->last[0].s, R16(src), r)); dst += 2; 571 apd->dstPos += apd->dstIncr; 572 (*ndst)--; 573 } 574 } 575 576 577 static void cvtMM168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 578 unsigned char* dst, LPDWORD ndst) 579 { 580 double r; 581 582 while (*nsrc != 0 && *ndst != 0) { 583 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 584 if (*nsrc == 0) return; 585 apd->last[0].s = R16(src); src += 2; 586 apd->srcPos++; 587 (*nsrc)--; 588 } 589 /* now do the interpolation */ 590 *dst++ = C168(I(apd->last[0].s, R16(src), r)); 591 apd->dstPos += apd->dstIncr; 592 (*ndst)--; 593 } 594 } 595 596 static void cvtSS1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 597 unsigned char* dst, LPDWORD ndst) 598 { 599 double r; 600 601 while (*nsrc != 0 && *ndst != 0) { 602 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 603 if (*nsrc == 0) return; 604 apd->last[0].s = R16(src); src += 2; 605 apd->last[1].s = R16(src); src += 2; 606 apd->srcPos++; 607 (*nsrc)--; 608 } 609 /* now do the interpolation */ 610 W16(dst, I(apd->last[0].s, R16(src) , r)); dst += 2; 611 W16(dst, I(apd->last[1].s, R16(src+2), r)); dst += 2; 612 apd->dstPos += apd->dstIncr; 613 (*ndst)--; 614 } 615 } 616 617 static void cvtSM1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 618 unsigned char* dst, LPDWORD ndst) 619 { 620 double r; 621 622 while (*nsrc != 0 && *ndst != 0) { 623 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 624 if (*nsrc == 0) return; 625 apd->last[0].s = R16(src); src += 2; 626 apd->last[1].s = R16(src); src += 2; 627 apd->srcPos++; 628 (*nsrc)--; 629 } 630 /* now do the interpolation */ 631 W16(dst, I(M16(apd->last[0].s, apd->last[1].s), 632 M16(R16(src), R16(src+2)), r)); 633 dst += 2; 634 apd->dstPos += apd->dstIncr; 635 (*ndst)--; 636 } 637 } 638 639 static void cvtMS1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 640 unsigned char* dst, LPDWORD ndst) 641 { 642 double r; 643 short v; 644 645 while (*nsrc != 0 && *ndst != 0) { 646 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 647 if (*nsrc == 0) return; 648 apd->last[0].s = R16(src); src += 2; 649 apd->srcPos++; 650 (*nsrc)--; 651 } 652 /* now do the interpolation */ 653 v = I(apd->last[0].s, R16(src), r); 654 W16(dst, v); dst += 2; 655 W16(dst, v); dst += 2; 656 apd->dstPos += apd->dstIncr; 657 (*ndst)--; 658 } 659 } 660 661 static void cvtMM1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc, 662 unsigned char* dst, LPDWORD ndst) 663 { 664 double r; 665 666 while (*nsrc != 0 && *ndst != 0) { 667 while ((r = (double)apd->srcPos - apd->dstPos) <= 0) { 668 if (*nsrc == 0) return; 669 apd->last[0].s = R16(src); src += 2; 670 apd->srcPos++; 671 (*nsrc)--; 672 } 673 /* now do the interpolation */ 674 W16(dst, I(apd->last[0].s, R16(src), r)); dst += 2; 675 apd->dstPos += apd->dstIncr; 676 (*ndst)--; 677 } 678 } 679 680 static void (*PCM_ConvertChangeRate[16])(AcmPcmData* apd, 681 const unsigned char* src, LPDWORD nsrc, 682 unsigned char* dst, LPDWORD ndst) = { 683 683 cvtSS88C, cvtSM88C, cvtMS88C, cvtMM88C, 684 cvtSS816C, 685 cvtSS168C, 684 cvtSS816C, cvtSM816C, cvtMS816C, cvtMM816C, 685 cvtSS168C, cvtSM168C, cvtMS168C, cvtMM168C, 686 686 cvtSS1616C, cvtSM1616C, cvtMS1616C, cvtMM1616C, 687 687 }; … … 691 691 * 692 692 */ 693 static 693 static LRESULT PCM_DriverDetails(PACMDRIVERDETAILSW add) 694 694 { 695 695 add->fccType = ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC; … … 712 712 add->szLicensing, sizeof(add->szLicensing)/sizeof(WCHAR) ); 713 713 add->szFeatures[0] = 0; 714 714 715 715 return MMSYSERR_NOERROR; 716 716 } … … 720 720 * 721 721 */ 722 static LRESULTPCM_FormatTagDetails(PACMFORMATTAGDETAILSW aftd, DWORD dwQuery)722 static LRESULT PCM_FormatTagDetails(PACMFORMATTAGDETAILSW aftd, DWORD dwQuery) 723 723 { 724 724 switch (dwQuery) { 725 725 case ACM_FORMATTAGDETAILSF_INDEX: 726 727 728 case ACM_FORMATTAGDETAILSF_FORMATTAG: 729 730 726 if (aftd->dwFormatTagIndex != 0) return ACMERR_NOTPOSSIBLE; 727 break; 728 case ACM_FORMATTAGDETAILSF_FORMATTAG: 729 if (aftd->dwFormatTag != WAVE_FORMAT_PCM) return ACMERR_NOTPOSSIBLE; 730 break; 731 731 case ACM_FORMATTAGDETAILSF_LARGESTSIZE: 732 if (aftd->dwFormatTag != WAVE_FORMAT_UNKNOWN && 733 734 735 732 if (aftd->dwFormatTag != WAVE_FORMAT_UNKNOWN && 733 aftd->dwFormatTag != WAVE_FORMAT_UNKNOWN) 734 return ACMERR_NOTPOSSIBLE; 735 break; 736 736 default: 737 738 739 } 740 737 WARN("Unsupported query %08lx\n", dwQuery); 738 return MMSYSERR_NOTSUPPORTED; 739 } 740 741 741 aftd->dwFormatTagIndex = 0; 742 742 aftd->dwFormatTag = WAVE_FORMAT_PCM; … … 745 745 aftd->cStandardFormats = NUM_PCM_FORMATS; 746 746 aftd->szFormatTag[0] = 0; 747 747 748 748 return MMSYSERR_NOERROR; 749 749 } … … 753 753 * 754 754 */ 755 static LRESULTPCM_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery)755 static LRESULT PCM_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery) 756 756 { 757 757 switch (dwQuery) { 758 758 case ACM_FORMATDETAILSF_FORMAT: 759 760 761 759 afd->dwFormatIndex = PCM_GetFormatIndex(afd->pwfx); 760 if (afd->dwFormatIndex == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE; 761 break; 762 762 case ACM_FORMATDETAILSF_INDEX: 763 764 765 766 767 768 769 * afd->pwfx->cbSize = 0; 770 771 afd->pwfx->nBlockAlign = 772 773 afd->pwfx->nAvgBytesPerSec = 774 775 763 assert(afd->dwFormatIndex < NUM_PCM_FORMATS); 764 afd->pwfx->wFormatTag = WAVE_FORMAT_PCM; 765 afd->pwfx->nChannels = PCM_Formats[afd->dwFormatIndex].nChannels; 766 afd->pwfx->nSamplesPerSec = PCM_Formats[afd->dwFormatIndex].rate; 767 afd->pwfx->wBitsPerSample = PCM_Formats[afd->dwFormatIndex].nBits; 768 /* native MSACM uses a PCMWAVEFORMAT structure, so cbSize is not accessible 769 * afd->pwfx->cbSize = 0; 770 */ 771 afd->pwfx->nBlockAlign = 772 (afd->pwfx->nChannels * afd->pwfx->wBitsPerSample) / 8; 773 afd->pwfx->nAvgBytesPerSec = 774 afd->pwfx->nSamplesPerSec * afd->pwfx->nBlockAlign; 775 break; 776 776 default: 777 778 return MMSYSERR_NOTSUPPORTED; 779 } 780 777 WARN("Unsupported query %08lx\n", dwQuery); 778 return MMSYSERR_NOTSUPPORTED; 779 } 780 781 781 afd->dwFormatTag = WAVE_FORMAT_PCM; 782 782 afd->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CONVERTER; 783 783 afd->szFormat[0] = 0; /* let MSACM format this for us... */ 784 784 785 785 return MMSYSERR_NOERROR; 786 786 } … … 790 790 * 791 791 */ 792 static LRESULTPCM_FormatSuggest(PACMDRVFORMATSUGGEST adfs)792 static LRESULT PCM_FormatSuggest(PACMDRVFORMATSUGGEST adfs) 793 793 { 794 794 FIXME("(%p);\n", adfs); … … 800 800 * 801 801 */ 802 static voidPCM_Reset(AcmPcmData* apd, int srcNumBits)802 static void PCM_Reset(AcmPcmData* apd, int srcNumBits) 803 803 { 804 804 apd->srcPos = 0; … … 806 806 /* initialize with neutral value */ 807 807 if (srcNumBits == 16) { 808 809 808 apd->last[0].s = 0; 809 apd->last[1].s = 0; 810 810 } else { 811 812 811 apd->last[0].b = (BYTE)0x80; 812 apd->last[1].b = (BYTE)0x80; 813 813 } 814 814 } … … 818 818 * 819 819 */ 820 static LRESULTPCM_StreamOpen(PACMDRVSTREAMINSTANCE adsi)821 { 822 AcmPcmData* 823 int 820 static LRESULT PCM_StreamOpen(PACMDRVSTREAMINSTANCE adsi) 821 { 822 AcmPcmData* apd; 823 int idx = 0; 824 824 825 825 assert(!(adsi->fdwOpen & ACM_STREAMOPENF_ASYNC)); 826 826 827 827 if (PCM_GetFormatIndex(adsi->pwfxSrc) == 0xFFFFFFFF || 828 829 828 PCM_GetFormatIndex(adsi->pwfxDst) == 0xFFFFFFFF) 829 return ACMERR_NOTPOSSIBLE; 830 830 831 831 apd = HeapAlloc(GetProcessHeap(), 0, sizeof(AcmPcmData)); … … 834 834 adsi->dwDriver = (DWORD)apd; 835 835 adsi->fdwDriver = 0; 836 836 837 837 if (adsi->pwfxSrc->wBitsPerSample == 16) idx += 8; 838 838 if (adsi->pwfxDst->wBitsPerSample == 16) idx += 4; … … 841 841 842 842 if (adsi->pwfxSrc->nSamplesPerSec == adsi->pwfxDst->nSamplesPerSec) { 843 843 apd->cvt.cvtKeepRate = PCM_ConvertKeepRate[idx]; 844 844 } else { 845 846 847 848 849 845 adsi->fdwDriver |= PCM_RESAMPLE; 846 apd->dstIncr = (double)(adsi->pwfxSrc->nSamplesPerSec) / 847 (double)(adsi->pwfxDst->nSamplesPerSec); 848 PCM_Reset(apd, adsi->pwfxSrc->wBitsPerSample); 849 apd->cvt.cvtChangeRate = PCM_ConvertChangeRate[idx]; 850 850 } 851 851 … … 857 857 * 858 858 */ 859 static LRESULTPCM_StreamClose(PACMDRVSTREAMINSTANCE adsi)859 static LRESULT PCM_StreamClose(PACMDRVSTREAMINSTANCE adsi) 860 860 { 861 861 HeapFree(GetProcessHeap(), 0, (void*)adsi->dwDriver); … … 867 867 * 868 868 */ 869 static inline DWORDPCM_round(DWORD a, DWORD b, DWORD c)869 static inline DWORD PCM_round(DWORD a, DWORD b, DWORD c) 870 870 { 871 871 assert(a && b && c); … … 878 878 * 879 879 */ 880 static 880 static LRESULT PCM_StreamSize(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMSIZE adss) 881 881 { 882 882 switch (adss->fdwSize) { 883 883 case ACM_STREAMSIZEF_DESTINATION: 884 885 adss->cbSrcLength = PCM_round(adss->cbDstLength, 886 adsi->pwfxSrc->nAvgBytesPerSec, 887 888 884 /* cbDstLength => cbSrcLength */ 885 adss->cbSrcLength = PCM_round(adss->cbDstLength, 886 adsi->pwfxSrc->nAvgBytesPerSec, 887 adsi->pwfxDst->nAvgBytesPerSec); 888 break; 889 889 case ACM_STREAMSIZEF_SOURCE: 890 891 adss->cbDstLength = PCM_round(adss->cbSrcLength, 892 adsi->pwfxDst->nAvgBytesPerSec, 893 894 890 /* cbSrcLength => cbDstLength */ 891 adss->cbDstLength = PCM_round(adss->cbSrcLength, 892 adsi->pwfxDst->nAvgBytesPerSec, 893 adsi->pwfxSrc->nAvgBytesPerSec); 894 break; 895 895 default: 896 897 return MMSYSERR_NOTSUPPORTED; 896 WARN("Unsupported query %08lx\n", adss->fdwSize); 897 return MMSYSERR_NOTSUPPORTED; 898 898 } 899 899 return MMSYSERR_NOERROR; … … 906 906 static LRESULT PCM_StreamConvert(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMHEADER adsh) 907 907 { 908 AcmPcmData* 909 DWORD 910 DWORD 911 912 if (adsh->fdwConvert & 913 914 915 916 908 AcmPcmData* apd = (AcmPcmData*)adsi->dwDriver; 909 DWORD nsrc = NUM_OF(adsh->cbSrcLength, adsi->pwfxSrc->nBlockAlign); 910 DWORD ndst = NUM_OF(adsh->cbDstLength, adsi->pwfxDst->nBlockAlign); 911 912 if (adsh->fdwConvert & 913 ~(ACM_STREAMCONVERTF_BLOCKALIGN| 914 ACM_STREAMCONVERTF_END| 915 ACM_STREAMCONVERTF_START)) { 916 FIXME("Unsupported fdwConvert (%08lx), ignoring it\n", adsh->fdwConvert); 917 917 } 918 918 /* ACM_STREAMCONVERTF_BLOCKALIGN 919 * 919 * currently all conversions are block aligned, so do nothing for this flag 920 920 * ACM_STREAMCONVERTF_END 921 * 921 * no pending data, so do nothing for this flag 922 922 */ 923 if ((adsh->fdwConvert & ACM_STREAMCONVERTF_START) && 924 925 923 if ((adsh->fdwConvert & ACM_STREAMCONVERTF_START) && 924 (adsi->fdwDriver & PCM_RESAMPLE)) { 925 PCM_Reset(apd, adsi->pwfxSrc->wBitsPerSample); 926 926 } 927 927 928 928 /* do the job */ 929 929 if (adsi->fdwDriver & PCM_RESAMPLE) { 930 DWORDnsrc2 = nsrc;931 DWORDndst2 = ndst;932 933 934 935 930 DWORD nsrc2 = nsrc; 931 DWORD ndst2 = ndst; 932 933 apd->cvt.cvtChangeRate(apd, adsh->pbSrc, &nsrc2, adsh->pbDst, &ndst2); 934 nsrc -= nsrc2; 935 ndst -= ndst2; 936 936 } else { 937 938 939 940 937 if (nsrc < ndst) ndst = nsrc; else nsrc = ndst; 938 939 /* nsrc is now equal to ndst */ 940 apd->cvt.cvtKeepRate(adsh->pbSrc, nsrc, adsh->pbDst); 941 941 } 942 942 … … 948 948 949 949 /************************************************************************** 950 * PCM_DriverProc[exported]951 */ 952 LRESULT CALLBACK PCM_DriverProc(DWORD dwDevID, HDRVR hDriv, UINT wMsg,953 954 { 955 TRACE("(%08lx %08lx %u %08lx %08lx);\n", 956 957 950 * PCM_DriverProc [exported] 951 */ 952 LRESULT CALLBACK PCM_DriverProc(DWORD dwDevID, HDRVR hDriv, UINT wMsg, 953 LPARAM dwParam1, LPARAM dwParam2) 954 { 955 TRACE("(%08lx %08lx %u %08lx %08lx);\n", 956 dwDevID, (DWORD)hDriv, wMsg, dwParam1, dwParam2); 957 958 958 switch (wMsg) { 959 case DRV_LOAD: 960 case DRV_FREE: 961 case DRV_OPEN: 962 case DRV_CLOSE: 963 case DRV_ENABLE: return 1;964 case DRV_DISABLE: 965 case DRV_QUERYCONFIGURE: 966 case DRV_CONFIGURE: 967 case DRV_INSTALL: 968 case DRV_REMOVE: 969 959 case DRV_LOAD: return 1; 960 case DRV_FREE: return 1; 961 case DRV_OPEN: return PCM_drvOpen((LPSTR)dwParam1); 962 case DRV_CLOSE: return PCM_drvClose(dwDevID); 963 case DRV_ENABLE: return 1; 964 case DRV_DISABLE: return 1; 965 case DRV_QUERYCONFIGURE: return 1; 966 case DRV_CONFIGURE: MessageBoxA(0, "MSACM PCM filter !", "Wine Driver", MB_OK); return 1; 967 case DRV_INSTALL: return DRVCNF_RESTART; 968 case DRV_REMOVE: return DRVCNF_RESTART; 969 970 970 case ACMDM_DRIVER_NOTIFY: 971 972 973 971 /* no caching from other ACM drivers is done so far */ 972 return MMSYSERR_NOERROR; 973 974 974 case ACMDM_DRIVER_DETAILS: 975 976 975 return PCM_DriverDetails((PACMDRIVERDETAILSW)dwParam1); 976 977 977 case ACMDM_FORMATTAG_DETAILS: 978 979 978 return PCM_FormatTagDetails((PACMFORMATTAGDETAILSW)dwParam1, dwParam2); 979 980 980 case ACMDM_FORMAT_DETAILS: 981 982 981 return PCM_FormatDetails((PACMFORMATDETAILSW)dwParam1, dwParam2); 982 983 983 case ACMDM_FORMAT_SUGGEST: 984 985 984 return PCM_FormatSuggest((PACMDRVFORMATSUGGEST)dwParam1); 985 986 986 case ACMDM_STREAM_OPEN: 987 988 987 return PCM_StreamOpen((PACMDRVSTREAMINSTANCE)dwParam1); 988 989 989 case ACMDM_STREAM_CLOSE: 990 991 990 return PCM_StreamClose((PACMDRVSTREAMINSTANCE)dwParam1); 991 992 992 case ACMDM_STREAM_SIZE: 993 994 993 return PCM_StreamSize((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMSIZE)dwParam2); 994 995 995 case ACMDM_STREAM_CONVERT: 996 997 996 return PCM_StreamConvert((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMHEADER)dwParam2); 997 998 998 case ACMDM_HARDWARE_WAVE_CAPS_INPUT: 999 999 case ACMDM_HARDWARE_WAVE_CAPS_OUTPUT: 1000 1000 /* this converter is not a hardware driver */ 1001 1001 case ACMDM_FILTERTAG_DETAILS: 1002 1002 case ACMDM_FILTER_DETAILS: 1003 1003 /* this converter is not a filter */ 1004 1004 case ACMDM_STREAM_RESET: 1005 1005 /* only needed for asynchronous driver... we aren't, so just say it */ 1006 1006 case ACMDM_STREAM_PREPARE: 1007 1007 case ACMDM_STREAM_UNPREPARE: 1008 1009 1010 1008 /* nothing special to do here... so don't do anything */ 1009 return MMSYSERR_NOTSUPPORTED; 1010 1011 1011 default: 1012 1012 return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2); 1013 1013 } 1014 1014 return 0; -
trunk/src/msacm32/stream.c
r6648 r6712 1 1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */ 2 /* $Id: stream.c,v 1.2 2001-09-05 13:11:26 bird Exp $ */ 2 3 3 /* 4 4 * MSACM32 library 5 5 * 6 6 * Copyright 1998 Patrik Stridvall 7 * 1999Eric Pouech7 * 1999 Eric Pouech 8 8 */ 9 9 10 10 /* TODO 11 * 12 * 13 * 14 * 11 * + asynchronous conversion is not implemented 12 * + callback/notification 13 * * acmStreamMessage 14 * + properly close ACM streams 15 15 */ 16 16 … … 26 26 27 27 DEFAULT_DEBUG_CHANNEL(msacm); 28 29 static PWINE_ACMSTREAM 28 29 static PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has) 30 30 { 31 31 return (PWINE_ACMSTREAM)has; … … 37 37 MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose) 38 38 { 39 PWINE_ACMSTREAM 40 MMRESULT 41 39 PWINE_ACMSTREAM was; 40 MMRESULT ret; 41 42 42 TRACE("(0x%08x, %ld)\n", has, fdwClose); 43 43 44 44 if ((was = ACM_GetStream(has)) == NULL) { 45 45 return MMSYSERR_INVALHANDLE; 46 46 } 47 47 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CLOSE, (DWORD)&was->drvInst, 0); 48 48 if (ret == MMSYSERR_NOERROR) { 49 50 acmDriverClose(was->hAcmDriver, 0L); 51 49 if (was->hAcmDriver) 50 acmDriverClose(was->hAcmDriver, 0L); 51 HeapFree(MSACM_hHeap, 0, was); 52 52 } 53 53 TRACE("=> (%d)\n", ret); … … 58 58 * acmStreamConvert (MSACM32.38) 59 59 */ 60 MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash, 61 62 { 63 PWINE_ACMSTREAM 64 MMRESULT 65 PACMDRVSTREAMHEADER 60 MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash, 61 DWORD fdwConvert) 62 { 63 PWINE_ACMSTREAM was; 64 MMRESULT ret = MMSYSERR_NOERROR; 65 PACMDRVSTREAMHEADER padsh; 66 66 67 67 TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwConvert); 68 68 69 69 if ((was = ACM_GetStream(has)) == NULL) 70 70 return MMSYSERR_INVALHANDLE; 71 71 if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) 72 72 return MMSYSERR_INVALPARAM; 73 73 74 74 if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED)) 75 75 return ACMERR_UNPREPARED; 76 76 77 77 /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same … … 83 83 /* check that pointers have not been modified */ 84 84 if (padsh->pbPreparedSrc != padsh->pbSrc || 85 86 87 88 89 } 85 padsh->cbPreparedSrcLength < padsh->cbSrcLength || 86 padsh->pbPreparedDst != padsh->pbDst || 87 padsh->cbPreparedDstLength < padsh->cbDstLength) { 88 return MMSYSERR_INVALPARAM; 89 } 90 90 91 91 padsh->fdwConvert = fdwConvert; … … 93 93 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CONVERT, (DWORD)&was->drvInst, (DWORD)padsh); 94 94 if (ret == MMSYSERR_NOERROR) { 95 95 padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_DONE; 96 96 } 97 97 TRACE("=> (%d)\n", ret); … … 102 102 * acmStreamMessage (MSACM32.39) 103 103 */ 104 MMRESULT WINAPI acmStreamMessage(HACMSTREAM has, UINT uMsg, LPARAM lParam1, 105 104 MMRESULT WINAPI acmStreamMessage(HACMSTREAM has, UINT uMsg, LPARAM lParam1, 105 LPARAM lParam2) 106 106 { 107 107 FIXME("(0x%08x, %u, %ld, %ld): stub\n", has, uMsg, lParam1, lParam2); … … 114 114 */ 115 115 MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pwfxSrc, 116 117 118 { 119 PWINE_ACMSTREAM 120 PWINE_ACMDRIVER 121 MMRESULT 122 int 123 int 124 116 PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD dwCallback, 117 DWORD dwInstance, DWORD fdwOpen) 118 { 119 PWINE_ACMSTREAM was; 120 PWINE_ACMDRIVER wad; 121 MMRESULT ret; 122 int wfxSrcSize; 123 int wfxDstSize; 124 125 125 TRACE("(%p, 0x%08x, %p, %p, %p, %ld, %ld, %ld)\n", 126 127 128 TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", 129 pwfxSrc->wFormatTag, pwfxSrc->nChannels, pwfxSrc->nSamplesPerSec, pwfxSrc->nAvgBytesPerSec, 130 131 132 TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", 133 pwfxDst->wFormatTag, pwfxDst->nChannels, pwfxDst->nSamplesPerSec, pwfxDst->nAvgBytesPerSec, 134 126 phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen); 127 128 TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", 129 pwfxSrc->wFormatTag, pwfxSrc->nChannels, pwfxSrc->nSamplesPerSec, pwfxSrc->nAvgBytesPerSec, 130 pwfxSrc->nBlockAlign, pwfxSrc->wBitsPerSample, pwfxSrc->cbSize); 131 132 TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", 133 pwfxDst->wFormatTag, pwfxDst->nChannels, pwfxDst->nSamplesPerSec, pwfxDst->nAvgBytesPerSec, 134 pwfxDst->nBlockAlign, pwfxDst->wBitsPerSample, pwfxDst->cbSize); 135 135 136 136 if ((fdwOpen & ACM_STREAMOPENF_QUERY) && phas) return MMSYSERR_INVALPARAM; … … 143 143 was = HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0)); 144 144 if (was == NULL) 145 146 145 return MMSYSERR_NOMEM; 146 147 147 was->drvInst.cbStruct = sizeof(was->drvInst); 148 148 was->drvInst.pwfxSrc = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was)); … … 151 151 memcpy(was->drvInst.pwfxDst, pwfxDst, wfxDstSize); 152 152 if (pwfltr) { 153 154 153 was->drvInst.pwfltr = (PWAVEFILTER)((LPSTR)was + sizeof(*was) + wfxSrcSize + wfxDstSize); 154 memcpy(was->drvInst.pwfltr, pwfltr, sizeof(WAVEFILTER)); 155 155 } else { 156 157 } 158 was->drvInst.dwCallback = dwCallback; 156 was->drvInst.pwfltr = NULL; 157 } 158 was->drvInst.dwCallback = dwCallback; 159 159 was->drvInst.dwInstance = dwInstance; 160 160 was->drvInst.fdwOpen = fdwOpen; 161 was->drvInst.fdwDriver = 0L; 162 was->drvInst.dwDriver = 0L; 161 was->drvInst.fdwDriver = 0L; 162 was->drvInst.dwDriver = 0L; 163 163 was->drvInst.has = (HACMSTREAM)was; 164 164 165 165 if (had) { 166 167 168 169 170 171 172 173 174 175 176 177 178 166 if (!(wad = MSACM_GetDriver(had))) { 167 ret = MMSYSERR_INVALPARAM; 168 goto errCleanUp; 169 } 170 171 was->obj.dwType = WINE_ACMOBJ_STREAM; 172 was->obj.pACMDriverID = wad->obj.pACMDriverID; 173 was->pDrv = wad; 174 was->hAcmDriver = 0; /* not to close it in acmStreamClose */ 175 176 ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L); 177 if (ret != MMSYSERR_NOERROR) 178 goto errCleanUp; 179 179 } else { 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 180 PWINE_ACMDRIVERID wadi; 181 182 ret = ACMERR_NOTPOSSIBLE; 183 for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID) { 184 ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L); 185 if (ret == MMSYSERR_NOERROR) { 186 if ((wad = MSACM_GetDriver(had)) != 0) { 187 was->obj.dwType = WINE_ACMOBJ_STREAM; 188 was->obj.pACMDriverID = wad->obj.pACMDriverID; 189 was->pDrv = wad; 190 was->hAcmDriver = had; 191 192 ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L); 193 if (ret == MMSYSERR_NOERROR) { 194 if (fdwOpen & ACM_STREAMOPENF_QUERY) { 195 acmDriverClose(had, 0L); 196 } 197 break; 198 } 199 } 200 /* no match, close this acm driver and try next one */ 201 acmDriverClose(had, 0L); 202 } 203 } 204 if (ret != MMSYSERR_NOERROR) { 205 ret = ACMERR_NOTPOSSIBLE; 206 goto errCleanUp; 207 } 208 208 } 209 209 ret = MMSYSERR_NOERROR; 210 210 if (!(fdwOpen & ACM_STREAMOPENF_QUERY)) { 211 if (phas) 212 *phas = (HACMSTREAM)was; 213 TRACE("=> (%d)\n", ret); 214 return ret; 215 } 216 errCleanUp: 211 217 if (phas) 212 *phas = (HACMSTREAM)was; 213 TRACE("=> (%d)\n", ret); 214 return ret; 215 } 216 errCleanUp: 217 if (phas) 218 *phas = (HACMSTREAM)0; 218 *phas = (HACMSTREAM)0; 219 219 HeapFree(MSACM_hHeap, 0, was); 220 220 TRACE("=> (%d)\n", ret); … … 226 226 * acmStreamPrepareHeader (MSACM32.41) 227 227 */ 228 MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, 229 230 { 231 PWINE_ACMSTREAM 232 MMRESULT 233 PACMDRVSTREAMHEADER 228 MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, 229 DWORD fdwPrepare) 230 { 231 PWINE_ACMSTREAM was; 232 MMRESULT ret = MMSYSERR_NOERROR; 233 PACMDRVSTREAMHEADER padsh; 234 234 235 235 TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwPrepare); 236 236 237 237 if ((was = ACM_GetStream(has)) == NULL) 238 238 return MMSYSERR_INVALHANDLE; 239 239 if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) 240 240 return MMSYSERR_INVALPARAM; 241 241 if (fdwPrepare) 242 242 ret = MMSYSERR_INVALFLAG; 243 243 244 244 if (pash->fdwStatus & ACMSTREAMHEADER_STATUSF_DONE) 245 245 return MMSYSERR_NOERROR; 246 246 247 247 /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same … … 264 264 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_PREPARE, (DWORD)&was->drvInst, (DWORD)padsh); 265 265 if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) { 266 267 268 269 270 271 272 273 274 266 ret = MMSYSERR_NOERROR; 267 padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE); 268 padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_PREPARED; 269 padsh->fdwPrepared = padsh->fdwStatus; 270 padsh->dwPrepared = 0; 271 padsh->pbPreparedSrc = padsh->pbSrc; 272 padsh->cbPreparedSrcLength = padsh->cbSrcLength; 273 padsh->pbPreparedDst = padsh->pbDst; 274 padsh->cbPreparedDstLength = padsh->cbDstLength; 275 275 } else { 276 277 278 279 280 281 276 padsh->fdwPrepared = 0; 277 padsh->dwPrepared = 0; 278 padsh->pbPreparedSrc = 0; 279 padsh->cbPreparedSrcLength = 0; 280 padsh->pbPreparedDst = 0; 281 padsh->cbPreparedDstLength = 0; 282 282 } 283 283 TRACE("=> (%d)\n", ret); … … 290 290 MMRESULT WINAPI acmStreamReset(HACMSTREAM has, DWORD fdwReset) 291 291 { 292 PWINE_ACMSTREAM 293 MMRESULT 292 PWINE_ACMSTREAM was; 293 MMRESULT ret = MMSYSERR_NOERROR; 294 294 295 295 TRACE("(0x%08x, %ld)\n", has, fdwReset); 296 296 297 297 if (fdwReset) { 298 298 ret = MMSYSERR_INVALFLAG; 299 299 } else if ((was = ACM_GetStream(has)) == NULL) { 300 300 return MMSYSERR_INVALHANDLE; 301 301 } else if (was->drvInst.fdwOpen & ACM_STREAMOPENF_ASYNC) { 302 302 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_RESET, (DWORD)&was->drvInst, 0); 303 303 } 304 304 TRACE("=> (%d)\n", ret); … … 309 309 * acmStreamSize (MSACM32.43) 310 310 */ 311 MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput, 312 313 { 314 PWINE_ACMSTREAM 315 ACMDRVSTREAMSIZE 316 MMRESULT 317 311 MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput, 312 LPDWORD pdwOutputBytes, DWORD fdwSize) 313 { 314 PWINE_ACMSTREAM was; 315 ACMDRVSTREAMSIZE adss; 316 MMRESULT ret; 317 318 318 TRACE("(0x%08x, %ld, %p, %ld)\n", has, cbInput, pdwOutputBytes, fdwSize); 319 319 320 320 if ((was = ACM_GetStream(has)) == NULL) { 321 321 return MMSYSERR_INVALHANDLE; 322 322 } 323 323 if ((fdwSize & ~ACM_STREAMSIZEF_QUERYMASK) != 0) { 324 324 return MMSYSERR_INVALFLAG; 325 325 } 326 326 327 327 *pdwOutputBytes = 0L; 328 328 329 329 switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) { 330 330 case ACM_STREAMSIZEF_DESTINATION: 331 332 333 331 adss.cbDstLength = cbInput; 332 adss.cbSrcLength = 0; 333 break; 334 334 case ACM_STREAMSIZEF_SOURCE: 335 336 337 338 default: 339 340 } 341 335 adss.cbSrcLength = cbInput; 336 adss.cbDstLength = 0; 337 break; 338 default: 339 return MMSYSERR_INVALFLAG; 340 } 341 342 342 adss.cbStruct = sizeof(adss); 343 343 adss.fdwSize = fdwSize; 344 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_SIZE, 345 344 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_SIZE, 345 (DWORD)&was->drvInst, (DWORD)&adss); 346 346 if (ret == MMSYSERR_NOERROR) { 347 348 349 350 351 352 353 354 347 switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) { 348 case ACM_STREAMSIZEF_DESTINATION: 349 *pdwOutputBytes = adss.cbSrcLength; 350 break; 351 case ACM_STREAMSIZEF_SOURCE: 352 *pdwOutputBytes = adss.cbDstLength; 353 break; 354 } 355 355 } 356 356 TRACE("=> (%d) [%lu]\n", ret, *pdwOutputBytes); … … 361 361 * acmStreamUnprepareHeader (MSACM32.44) 362 362 */ 363 MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, 364 365 { 366 PWINE_ACMSTREAM 367 MMRESULT 368 PACMDRVSTREAMHEADER 363 MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, 364 DWORD fdwUnprepare) 365 { 366 PWINE_ACMSTREAM was; 367 MMRESULT ret = MMSYSERR_NOERROR; 368 PACMDRVSTREAMHEADER padsh; 369 369 370 370 TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwUnprepare); 371 371 372 372 if ((was = ACM_GetStream(has)) == NULL) 373 373 return MMSYSERR_INVALHANDLE; 374 374 if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) 375 375 return MMSYSERR_INVALPARAM; 376 376 377 377 if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED)) 378 378 return ACMERR_UNPREPARED; 379 379 380 380 /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same … … 386 386 /* check that pointers have not been modified */ 387 387 if (padsh->pbPreparedSrc != padsh->pbSrc || 388 389 390 391 392 } 388 padsh->cbPreparedSrcLength < padsh->cbSrcLength || 389 padsh->pbPreparedDst != padsh->pbDst || 390 padsh->cbPreparedDstLength < padsh->cbDstLength) { 391 return MMSYSERR_INVALPARAM; 392 } 393 393 394 394 padsh->fdwConvert = fdwUnprepare; … … 396 396 ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_UNPREPARE, (DWORD)&was->drvInst, (DWORD)padsh); 397 397 if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) { 398 399 400 } 401 TRACE("=> (%d)\n", ret); 402 return ret; 403 } 398 ret = MMSYSERR_NOERROR; 399 padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE|ACMSTREAMHEADER_STATUSF_PREPARED); 400 } 401 TRACE("=> (%d)\n", ret); 402 return ret; 403 } -
trunk/src/msacm32/wineacm.h
r5434 r6712 3 3 #define __WINE_WINEACM_H 4 4 5 #ifndef __WIN32OS2__ 5 #ifdef __WIN32OS2__ 6 #include "windef.h" 7 #else 6 8 #include "wine/windef16.h" 7 9 #include "wine/mmsystem16.h"
Note:
See TracChangeset
for help on using the changeset viewer.