Changeset 89530 in vbox
- Timestamp:
- Jun 6, 2021 11:59:38 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkatDriverStack.cpp
r89511 r89530 1210 1210 if (pMix->pStream->Cfg.enmDir == PDMAUDIODIR_IN) 1211 1211 { 1212 //uint32_t const cbBuf = PDMAudioPropsFloorBytesToFrame(&pMix->pStream->Cfg.Props, sizeof(abBuf)); 1213 1212 /* 1213 * Try fill up the mixer buffer as much as possible. 1214 * 1215 * Slight fun part is that we have to calculate conversion 1216 * ratio and be rather pessimistic about it. 1217 */ 1218 uint32_t const cbBuf = PDMAudioPropsFloorBytesToFrame(&pMix->pStream->Cfg.Props, sizeof(abBuf)); 1219 for (;;) 1220 { 1221 /* 1222 * Figure out how much we can move in this iteration. 1223 */ 1224 uint32_t cDstFrames = AudioMixBufFree(&pMix->MixBuf); 1225 if (!cDstFrames) 1226 break; 1227 1228 uint32_t cbReadable = audioTestDriverStackStreamGetReadable(pMix->pDrvStack, pMix->pStream); 1229 if (!cbReadable) 1230 break; 1231 1232 uint32_t cbToRead; 1233 if (PDMAudioPropsHz(&pMix->pStream->Cfg.Props) == PDMAudioPropsHz(&pMix->MixBuf.Props)) 1234 cbToRead = PDMAudioPropsFramesToBytes(&pMix->pStream->Cfg.Props, cDstFrames); 1235 else 1236 cbToRead = PDMAudioPropsFramesToBytes(&pMix->pStream->Cfg.Props, 1237 (uint64_t)cDstFrames * PDMAudioPropsHz(&pMix->pStream->Cfg.Props) 1238 / PDMAudioPropsHz(&pMix->MixBuf.Props)); 1239 cbToRead = RT_MIN(cbToRead, RT_MIN(cbReadable, cbBuf)); 1240 if (!cbToRead) 1241 break; 1242 1243 /* 1244 * Get the data. 1245 */ 1246 uint32_t cbCaptured = 0; 1247 int rc = audioTestDriverStackStreamCapture(pMix->pDrvStack, pMix->pStream, abBuf, cbToRead, &cbCaptured); 1248 if (RT_FAILURE(rc)) 1249 return rc; 1250 Assert(cbCaptured == cbToRead); 1251 AssertBreak(cbCaptured > 0); 1252 1253 /* 1254 * Feed it to the mixer. 1255 */ 1256 uint32_t cDstFramesWritten = 0; 1257 if ((abBuf[0] >> 4) & 1) /* some cheap random */ 1258 AudioMixBufWrite(&pMix->MixBuf, &pMix->WriteState, abBuf, cbCaptured, 1259 0 /*offDstFrame*/, cDstFrames, &cDstFramesWritten); 1260 else 1261 { 1262 AudioMixBufSilence(&pMix->MixBuf, &pMix->WriteState, 0 /*offFrame*/, cDstFrames); 1263 AudioMixBufBlend(&pMix->MixBuf, &pMix->WriteState, abBuf, cbCaptured, 1264 0 /*offDstFrame*/, cDstFrames, &cDstFramesWritten); 1265 } 1266 AudioMixBufCommit(&pMix->MixBuf, cDstFramesWritten); 1267 } 1214 1268 } 1215 1269 else
Note:
See TracChangeset
for help on using the changeset viewer.