Changeset 34228 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Nov 22, 2010 7:15:41 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchIntelHDA.cpp
r34227 r34228 1341 1341 PHDABDLEDESC pBdle = &pState->stInBdle; 1342 1342 uint32_t cbTransfered = 0; 1343 while( *pu32Avail 1344 && pBdle->u32BdleCviPos < pBdle->u32BdleCviLen) 1345 { 1346 uint32_t cb2Copy = 0; 1347 uint32_t cbBackendCopy = 0; 1348 bool fUnderFifoCleared = false; 1349 if ( !pBdle->u32BdleCviLen 1350 || (*pu32Avail < hdaFifoWToSz(pState, 0))) 1351 { 1352 *fStop = true; 1353 return 0; 1354 } 1355 Log(("hda:ra: CVI(pos:%d, len:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1356 Assert((pBdle->u32BdleCviLen >= pBdle->u32BdleCviPos)); /* sanity */ 1357 cb2Copy = pBdle->u32BdleCviLen - pBdle->u32BdleCviPos; 1358 cb2Copy = RT_MIN(cb2Copy, SDFIFOS(pState, 0) + 1 - pBdle->cbUnderFifoW); /* we may increase the counter in range of [0, FIFOS(pState, 4) + 1] */ 1359 Assert((*pu32Avail > 0)); 1360 cb2Copy = RT_MIN(cb2Copy, *pu32Avail); /* sanity check to avoid overriding sound backend buffer */ 1361 cb2Copy = RT_MIN(cb2Copy, u32CblLimit); 1362 if ( !cb2Copy 1363 || cb2Copy < pBdle->cbUnderFifoW) 1364 { 1365 *fStop = true; 1366 return 0; 1367 } 1368 1369 /* 1370 * read from backend input line 1371 */ 1372 cbBackendCopy = AUD_read (ISD0FMT_TO_AUDIO_SELECTOR(pState), pBdle->au8HdaBuffer, cb2Copy); 1373 /* 1374 * write on the HDA DMA 1375 */ 1376 PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(pState), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer, cbBackendCopy); 1377 1378 Assert((cbBackendCopy == cb2Copy && (*pu32Avail) >= cb2Copy)); /* sanity */ 1379 *pu32Avail -= cb2Copy; 1380 pBdle->u32BdleCviPos += RT_MIN(cb2Copy, cbBackendCopy); 1381 if (pBdle->cbUnderFifoW + cbBackendCopy > hdaFifoWToSz(pState, 0)) 1382 { 1383 Log(("hda:ra: CVI resetting cbUnderFifoW:%d(pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1384 cbTransfered += cbBackendCopy + pBdle->cbUnderFifoW; 1385 pBdle->cbUnderFifoW -= RT_MIN(pBdle->cbUnderFifoW, cbBackendCopy); 1386 Assert(!pBdle->cbUnderFifoW); /* we assume, we've read Under FIFO W fully */ 1387 } 1388 else 1389 { 1390 Log(("hda:ra: CVI (cbUnderFifoW:%d, pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1391 pBdle->cbUnderFifoW += RT_MIN(cbBackendCopy, cb2Copy); 1392 Assert((pBdle->cbUnderFifoW <= hdaFifoWToSz(pState, 0))); 1393 *fStop = true; 1394 break; 1395 } 1396 Log(("hda:ra: CVI(pos:%d, len:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1397 if ( cbTransfered == (SDFIFOS(pState, 0) + 1) 1398 || pBdle->u32BdleCviLen == pBdle->u32BdleCviPos) 1399 break; 1400 } 1343 uint32_t cb2Copy = 0; 1344 uint32_t cbBackendCopy = 0; 1345 1346 if ( !pBdle->u32BdleCviLen 1347 || (*pu32Avail < hdaFifoWToSz(pState, 0))) 1348 { 1349 *fStop = true; 1350 goto done; 1351 } 1352 1353 Log(("hda:ra: CVI(pos:%d, len:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1354 Assert((pBdle->u32BdleCviLen >= pBdle->u32BdleCviPos)); /* sanity */ 1355 cb2Copy = pBdle->u32BdleCviLen - pBdle->u32BdleCviPos; 1356 /* 1357 * we may increase the counter in range of [0, FIFOS(pState, 4) + 1] 1358 */ 1359 cb2Copy = RT_MIN(cb2Copy, SDFIFOS(pState, 0) + 1); 1360 Assert((*pu32Avail > 0)); 1361 1362 /* sanity check to avoid overriding sound backend buffer */ 1363 cb2Copy = RT_MIN(cb2Copy, *pu32Avail); 1364 cb2Copy = RT_MIN(cb2Copy, u32CblLimit); 1365 1366 if (cb2Copy <= pBdle->cbUnderFifoW) 1367 { 1368 *fStop = true; 1369 goto done; 1370 } 1371 cb2Copy -= pBdle->cbUnderFifoW; 1372 1373 /* 1374 * read from backend input line 1375 */ 1376 cbBackendCopy = AUD_read (ISD0FMT_TO_AUDIO_SELECTOR(pState), pBdle->au8HdaBuffer, cb2Copy); 1377 /* 1378 * write on the HDA DMA 1379 */ 1380 PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(pState), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer, cbBackendCopy); 1381 1382 Assert((cbBackendCopy == cb2Copy && (*pu32Avail) >= cb2Copy)); /* sanity */ 1383 *pu32Avail -= cb2Copy; 1384 pBdle->u32BdleCviPos += RT_MIN(cb2Copy, cbBackendCopy); 1385 if (pBdle->cbUnderFifoW + cbBackendCopy > hdaFifoWToSz(pState, 0)) 1386 { 1387 Log(("hda:ra: CVI resetting cbUnderFifoW:%d(pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1388 cbTransfered += cbBackendCopy + pBdle->cbUnderFifoW; 1389 pBdle->cbUnderFifoW -= RT_MIN(pBdle->cbUnderFifoW, cbBackendCopy); 1390 Assert(!pBdle->cbUnderFifoW); /* we assume, we've read Under FIFO W fully */ 1391 } 1392 else 1393 { 1394 Log(("hda:ra: CVI (cbUnderFifoW:%d, pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1395 pBdle->cbUnderFifoW += RT_MIN(cbBackendCopy, cb2Copy); 1396 Assert((pBdle->cbUnderFifoW <= hdaFifoWToSz(pState, 0))); 1397 *fStop = true; 1398 goto done; 1399 } 1400 Log(("hda:ra: CVI(pos:%d, len:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1401 done: 1401 1402 Assert((cbTransfered <= (SDFIFOS(pState, 0) + 1))); 1402 1403 Log(("hda:ra: cbTransfered: %d\n", cbTransfered));
Note:
See TracChangeset
for help on using the changeset viewer.