Changeset 73653 in vbox for trunk/src/VBox
- Timestamp:
- Aug 14, 2018 12:57:20 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r73652 r73653 898 898 899 899 uint32_t cbToWrite = RT_MIN(cbBuf, cbFree); 900 if (cbToWrite > cbBuf) /* Paranoia. */901 cbToWrite = cbBuf;902 903 900 if (!cbToWrite) 904 901 { … … 943 940 944 941 pStream->tsLastReadWrittenNs = RTTimeNanoTS(); 945 942 #ifdef DEBUG 943 pStream->Out.Dbg.cfWrittenSinceLastPlay += AUDIOMIXBUF_F2F_RATIO(&pStream->Guest.MixBuf, cfGstMixed); 944 #endif 946 945 /* Keep going. */ 947 946 } … … 951 950 952 951 cbWrittenTotal = AUDIOMIXBUF_F2B(&pStream->Guest.MixBuf, cfGstWritten); 953 #ifdef DEBUG954 if (pStream->fThresholdReached)955 pStream->Out.Dbg.cbJitterWrittenPlayed += cbWrittenTotal;956 #endif957 952 958 953 #ifdef VBOX_WITH_STATISTICS … … 1408 1403 } 1409 1404 uint32_t cfLive = AudioMixBufLive(&pStream->Host.MixBuf); 1405 #ifdef LOG_ENABLED 1410 1406 const uint8_t uLivePercent = (100 * cfLive) / AudioMixBufSize(&pStream->Host.MixBuf); 1411 1407 1412 1408 const uint64_t tsDeltaPlayedCapturedNs = RTTimeNanoTS() - pStream->tsLastPlayedCapturedNs; 1413 1409 1414 pStream->tsLastPlayedCapturedNs = RTTimeNanoTS(); 1415 1416 Log3Func(("[%s] Last played %RU64ns (%RU64ms), filled with %RU64ms (%RU8%%) total, " 1417 "(cfLive=%RU32, fThresholdReached=%RTbool)\n", 1410 uint32_t cfPassed = DrvAudioHlpNanoToFrames(tsDeltaPlayedCapturedNs, &pStream->Host.Cfg.Props); 1411 #endif 1412 const uint32_t cfPeriod = pStream->Host.Cfg.Backend.cfPeriod; 1413 1414 Log3Func(("[%s] Last played %RU64ns (%RU64ms), filled with %RU64ms (%RU8%%) total (fThresholdReached=%RTbool)\n", 1418 1415 pStream->szName, tsDeltaPlayedCapturedNs, tsDeltaPlayedCapturedNs / RT_NS_1MS_64, 1419 DrvAudioHlpFramesToMilli(cfLive, &pStream->Host.Cfg.Props), 1420 uLivePercent, cfLive, pStream->fThresholdReached)); 1416 DrvAudioHlpFramesToMilli(cfLive, &pStream->Host.Cfg.Props), uLivePercent, pStream->fThresholdReached)); 1421 1417 1422 1418 bool fDoPlay = pStream->fThresholdReached; … … 1455 1451 if (fDoPlay) 1456 1452 { 1453 uint32_t cfWritable; 1454 if (pThis->pHostDrvAudio->pfnStreamGetWritable) 1455 { 1456 cfWritable = PDMAUDIOPCMPROPS_B2F(&pStream->Host.Cfg.Props, 1457 pThis->pHostDrvAudio->pfnStreamGetWritable(pThis->pHostDrvAudio, pStream->pvBackend)); 1458 } 1459 else 1460 cfWritable = cfPeriod; 1461 1457 1462 uint32_t cfToPlay = 0; 1458 1463 if (fJustStarted) 1459 cfToPlay = pStream->Host.Cfg.Backend.cfPeriod; /* cfPeriod can be 0. */1464 cfToPlay = RT_MIN(cfWritable, cfPeriod); 1460 1465 1461 1466 if (!cfToPlay) 1462 { 1463 cfToPlay = DrvAudioHlpNanoToFrames(tsDeltaPlayedCapturedNs, &pStream->Host.Cfg.Props); 1464 if (pStream->Host.Cfg.Device.uSchedulingHintMs) 1465 cfToPlay = RT_MIN(cfToPlay, DrvAudioHlpMilliToFrames(pStream->Host.Cfg.Device.uSchedulingHintMs, &pStream->Host.Cfg.Props)); 1466 } 1467 1468 Log3Func(("[%s] fJustStarted=%RTbool, cfLive=%RU32, cfToPlay=%RU32\n", 1469 pStream->szName, fJustStarted, cfLive, cfToPlay)); 1470 1471 /* Did we reach a buffer underrun? Do pre-buffering again. 1472 * If we're in pending disabled mode, try to play (drain) the remaining audio data. */ 1473 if ( !(pStream->fStatus & PDMAUDIOSTREAMSTS_FLAG_PENDING_DISABLE) 1474 && !fJustStarted) 1475 { 1476 if (cfLive < cfToPlay) 1477 { 1478 pStream->fThresholdReached = false; 1479 Log3Func(("[%s] Warning: Buffer underrun (cfLive=%RU32, cfToPlay=%RU32)\n", pStream->szName, cfLive, cfToPlay)); 1480 LogRel2(("Audio: Stream '%s' buffer underrun (total %RU8%%, which is %RU8%% of a period), buffering ...\n", 1481 pStream->szName, uLivePercent, (100 * cfLive) / pStream->Host.Cfg.Backend.cfPeriod)); 1482 break; 1483 } 1484 } 1467 cfToPlay = cfWritable; 1485 1468 1486 1469 if (cfToPlay > cfLive) /* Don't try to play more than available. */ 1487 1470 cfToPlay = cfLive; 1488 1489 if (!cfToPlay)1490 break;1491 1471 #ifdef DEBUG 1492 if (!fJustStarted)1493 pStream->Out.Dbg.cbJitterWrittenPlayed -= AUDIOMIXBUF_F2B(&pStream->Host.MixBuf, cfToPlay);1494 1472 Log3Func(("[%s] Playing %RU32 frames (%RU64ms), now filled with %RU64ms -- %RU8%% (cbJitterWrittenPlayed=%RI64)\n", 1495 1473 pStream->szName, cfToPlay, DrvAudioHlpFramesToMilli(cfToPlay, &pStream->Host.Cfg.Props), 1496 1474 DrvAudioHlpFramesToMilli(AudioMixBufUsed(&pStream->Host.MixBuf), &pStream->Host.Cfg.Props), 1497 AudioMixBufUsed(&pStream->Host.MixBuf) * 100 / AudioMixBufSize(&pStream->Host.MixBuf), 1498 pStream->Out.Dbg.cbJitterWrittenPlayed)); 1475 AudioMixBufUsed(&pStream->Host.MixBuf) * 100 / AudioMixBufSize(&pStream->Host.MixBuf))); 1499 1476 #endif 1500 if (pThis->pHostDrvAudio->pfnStreamPlayBegin) 1501 pThis->pHostDrvAudio->pfnStreamPlayBegin(pThis->pHostDrvAudio, pStream->pvBackend); 1502 1503 if (RT_LIKELY(pStream->Host.Cfg.enmLayout == PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED)) 1477 if (cfToPlay) 1504 1478 { 1505 rc = drvAudioStreamPlayNonInterleaved(pThis, pStream, cfToPlay, &cfPlayedTotal); 1479 if (pThis->pHostDrvAudio->pfnStreamPlayBegin) 1480 pThis->pHostDrvAudio->pfnStreamPlayBegin(pThis->pHostDrvAudio, pStream->pvBackend); 1481 1482 if (RT_LIKELY(pStream->Host.Cfg.enmLayout == PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED)) 1483 { 1484 rc = drvAudioStreamPlayNonInterleaved(pThis, pStream, cfToPlay, &cfPlayedTotal); 1485 } 1486 else if (pStream->Host.Cfg.enmLayout == PDMAUDIOSTREAMLAYOUT_RAW) 1487 { 1488 rc = drvAudioStreamPlayRaw(pThis, pStream, cfToPlay, &cfPlayedTotal); 1489 } 1490 else 1491 AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED); 1492 1493 if (pThis->pHostDrvAudio->pfnStreamPlayEnd) 1494 pThis->pHostDrvAudio->pfnStreamPlayEnd(pThis->pHostDrvAudio, pStream->pvBackend); 1495 1496 pStream->tsLastPlayedCapturedNs = RTTimeNanoTS(); 1497 #ifdef DEBUG 1498 Log3Func(("[%s] Dbg: cfWrittenSinceLastPlay=%RU64 (%RU64ms)\n", 1499 pStream->szName, 1500 pStream->Out.Dbg.cfWrittenSinceLastPlay, DrvAudioHlpFramesToMilli(pStream->Out.Dbg.cfWrittenSinceLastPlay, &pStream->Host.Cfg.Props))); 1501 pStream->Out.Dbg.cfWrittenSinceLastPlay = 0; 1502 #endif 1506 1503 } 1507 else if (pStream->Host.Cfg.enmLayout == PDMAUDIOSTREAMLAYOUT_RAW) 1508 { 1509 rc = drvAudioStreamPlayRaw(pThis, pStream, cfToPlay, &cfPlayedTotal); 1510 } 1511 else 1512 AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED); 1513 1514 if (pThis->pHostDrvAudio->pfnStreamPlayEnd) 1515 pThis->pHostDrvAudio->pfnStreamPlayEnd(pThis->pHostDrvAudio, pStream->pvBackend); 1504 1505 Log3Func(("[%s] Dbg: fJustStarted=%RTbool, cfPassed=%RU32 (%RU64ms), cfLive=%RU32 (%RU64ms), cfPeriod=%RU32 (%RU64ms), " 1506 "cfWritable=%RU32 (%RU64ms), -> cfToPlay=%RU32 (%RU64ms), cfPlayed=%RU32 (%RU64ms)\n", 1507 pStream->szName, fJustStarted, 1508 cfPassed, DrvAudioHlpFramesToMilli(cfPassed, &pStream->Host.Cfg.Props), 1509 cfLive, DrvAudioHlpFramesToMilli(cfLive, &pStream->Host.Cfg.Props), 1510 cfPeriod, DrvAudioHlpFramesToMilli(cfPeriod, &pStream->Host.Cfg.Props), 1511 cfWritable, DrvAudioHlpFramesToMilli(cfWritable, &pStream->Host.Cfg.Props), 1512 cfToPlay, DrvAudioHlpFramesToMilli(cfToPlay, &pStream->Host.Cfg.Props), 1513 cfPlayedTotal, DrvAudioHlpFramesToMilli(cfPlayedTotal, &pStream->Host.Cfg.Props))); 1516 1514 } 1517 1515
Note:
See TracChangeset
for help on using the changeset viewer.