Changeset 88022 in vbox
- Timestamp:
- Mar 8, 2021 5:50:57 PM (4 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r88016 r88022 656 656 if (RT_SUCCESS(rc)) 657 657 { 658 rc = RTCircBufCreate(&pMixStream->pCircBuf, DrvAudioHlpMilliToBytes(&pSink->PCMProps, 100 /*ms*/)); /** @todo Make this configurable. */658 rc = RTCircBufCreate(&pMixStream->pCircBuf, PDMAudioPropsMilliToBytes(&pSink->PCMProps, 100 /*ms*/)); /** @todo Make this configurable. */ 659 659 AssertRC(rc); 660 660 } … … 1036 1036 1037 1037 Log3Func(("[%s] cbWritable=%RU32 (%RU64ms)\n", 1038 pSink->pszName, cbWritable, DrvAudioHlpBytesToMilli(&pSink->PCMProps, cbWritable)));1038 pSink->pszName, cbWritable, PDMAudioPropsBytesToMilli(&pSink->PCMProps, cbWritable))); 1039 1039 1040 1040 int rc2 = RTCritSectLeave(&pSink->CritSect); … … 1475 1475 return rc; 1476 1476 1477 if ( DrvAudioHlpPcmPropsAreEqual(&pSink->PCMProps, pPCMProps)) /* Bail out early if PCM properties are equal. */1477 if (PDMAudioPropsAreEqual(&pSink->PCMProps, pPCMProps)) /* Bail out early if PCM properties are equal. */ 1478 1478 { 1479 1479 rc = RTCritSectLeave(&pSink->CritSect); … … 1495 1495 AudioMixBufDestroy(&pSink->MixBuf); 1496 1496 rc = AudioMixBufInit(&pSink->MixBuf, pSink->pszName, &pSink->PCMProps, 1497 DrvAudioHlpMilliToFrames(&pSink->PCMProps, 100 /*ms*/)); /** @todo Make this configurable? */1497 PDMAudioPropsMilliToFrames(&pSink->PCMProps, 100 /*ms*/)); /** @todo Make this configurable? */ 1498 1498 if (RT_SUCCESS(rc)) 1499 1499 { … … 1715 1715 break; 1716 1716 1717 const uint32_t cbChunk = DrvAudioHlpFramesToBytes(&pSink->PCMProps, cfChunk);1717 const uint32_t cbChunk = PDMAudioPropsFramesToBytes(&pSink->PCMProps, cfChunk); 1718 1718 Assert(cbChunk <= pSink->cbScratchBuf); 1719 1719 … … 2119 2119 break; 2120 2120 2121 const uint32_t cbWrittenChunk = DrvAudioHlpFramesToBytes(&pSink->PCMProps, cfWritten);2121 const uint32_t cbWrittenChunk = PDMAudioPropsFramesToBytes(&pSink->PCMProps, cfWritten); 2122 2122 2123 2123 Assert(cbToWrite >= cbWrittenChunk); -
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r88015 r88022 1643 1643 Log3Func(("[SD%RU8] PICB=%zu (%RU64ms), cbFree=%zu (%RU64ms), cbTransferChunk=%zu (%RU64ms)\n", 1644 1644 pStream->u8SD, 1645 (pStream->Regs.picb << 1), DrvAudioHlpBytesToMilli(&pStreamCC->State.Cfg.Props, pStream->Regs.picb << 1),1646 cbStreamFree, DrvAudioHlpBytesToMilli(&pStreamCC->State.Cfg.Props, cbStreamFree),1647 pStreamCC->State.cbTransferChunk, DrvAudioHlpBytesToMilli(&pStreamCC->State.Cfg.Props, pStreamCC->State.cbTransferChunk)));1645 (pStream->Regs.picb << 1), PDMAudioPropsBytesToMilli(&pStreamCC->State.Cfg.Props, pStream->Regs.picb << 1), 1646 cbStreamFree, PDMAudioPropsBytesToMilli(&pStreamCC->State.Cfg.Props, cbStreamFree), 1647 pStreamCC->State.cbTransferChunk, PDMAudioPropsBytesToMilli(&pStreamCC->State.Cfg.Props, pStreamCC->State.cbTransferChunk))); 1648 1648 1649 1649 /* Do the DMA transfer. */ … … 2088 2088 return 0; 2089 2089 2090 const uint64_t usBytes = DrvAudioHlpBytesToMicro(&pStreamCC->State.Cfg.Props, cbBytes);2090 const uint64_t usBytes = PDMAudioPropsBytesToMicro(&pStreamCC->State.Cfg.Props, cbBytes); 2091 2091 const uint64_t cTransferTicks = PDMDevHlpTimerFromMicro(pDevIns, pStream->hTimer, usBytes); 2092 2092 … … 2228 2228 } 2229 2229 2230 rc = RTCircBufCreate(&pStreamCC->State.pCircBuf, DrvAudioHlpMilliToBytes(&Cfg.Props, 100 /*ms*/)); /** @todo Make this configurable. */2230 rc = RTCircBufCreate(&pStreamCC->State.pCircBuf, PDMAudioPropsMilliToBytes(&Cfg.Props, 100 /*ms*/)); /** @todo Make this configurable. */ 2231 2231 if (RT_SUCCESS(rc)) 2232 2232 { … … 2812 2812 2813 2813 #ifdef VBOX_STRICT 2814 const unsigned cbFrame = DrvAudioHlpBytesPerFrame(&pStreamCC->State.Cfg.Props);2814 const unsigned cbFrame = PDMAudioPropsBytesPerFrame(&pStreamCC->State.Cfg.Props); 2815 2815 #endif 2816 2816 -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r88016 r88022 592 592 if (CfgHostAcq.Backend.cFramesBufferSize != pCfgHost->Backend.cFramesBufferSize) 593 593 LogRel2(("Audio: Backend changed buffer size from %RU64ms (%RU32 frames) to %RU64ms (%RU32 frames)\n", 594 DrvAudioHlpFramesToMilli(&pCfgHost->Props, pCfgHost->Backend.cFramesBufferSize), pCfgHost->Backend.cFramesBufferSize,595 DrvAudioHlpFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesBufferSize), CfgHostAcq.Backend.cFramesBufferSize));594 PDMAudioPropsFramesToMilli(&pCfgHost->Props, pCfgHost->Backend.cFramesBufferSize), pCfgHost->Backend.cFramesBufferSize, 595 PDMAudioPropsFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesBufferSize), CfgHostAcq.Backend.cFramesBufferSize)); 596 596 597 597 if (CfgHostAcq.Backend.cFramesPeriod != pCfgHost->Backend.cFramesPeriod) 598 598 LogRel2(("Audio: Backend changed period size from %RU64ms (%RU32 frames) to %RU64ms (%RU32 frames)\n", 599 DrvAudioHlpFramesToMilli(&pCfgHost->Props, pCfgHost->Backend.cFramesPeriod), pCfgHost->Backend.cFramesPeriod,600 DrvAudioHlpFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPeriod), CfgHostAcq.Backend.cFramesPeriod));599 PDMAudioPropsFramesToMilli(&pCfgHost->Props, pCfgHost->Backend.cFramesPeriod), pCfgHost->Backend.cFramesPeriod, 600 PDMAudioPropsFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPeriod), CfgHostAcq.Backend.cFramesPeriod)); 601 601 602 602 if (CfgHostAcq.Backend.cFramesPreBuffering != pCfgHost->Backend.cFramesPreBuffering) 603 603 LogRel2(("Audio: Backend changed pre-buffering size from %RU64ms (%RU32 frames) to %RU64ms (%RU32 frames)\n", 604 DrvAudioHlpFramesToMilli(&pCfgHost->Props, pCfgHost->Backend.cFramesPreBuffering), pCfgHost->Backend.cFramesPreBuffering,605 DrvAudioHlpFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPreBuffering), CfgHostAcq.Backend.cFramesPreBuffering));604 PDMAudioPropsFramesToMilli(&pCfgHost->Props, pCfgHost->Backend.cFramesPreBuffering), pCfgHost->Backend.cFramesPreBuffering, 605 PDMAudioPropsFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPreBuffering), CfgHostAcq.Backend.cFramesPreBuffering)); 606 606 /* 607 607 * Configure host buffers. … … 625 625 } 626 626 627 uint64_t msBufferSize = DrvAudioHlpFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesBufferSize);627 uint64_t msBufferSize = PDMAudioPropsFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesBufferSize); 628 628 629 629 LogRel2(("Audio: Buffer size of stream '%s' is %RU64ms (%RU32 frames)\n", … … 631 631 632 632 /* If no own pre-buffer is set, let the backend choose. */ 633 uint64_t msPreBuf = DrvAudioHlpFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPreBuffering);633 uint64_t msPreBuf = PDMAudioPropsFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPreBuffering); 634 634 LogRel2(("Audio: Pre-buffering size of stream '%s' is %RU64ms (%RU32 frames)\n", 635 635 pStream->szName, msPreBuf, CfgHostAcq.Backend.cFramesPreBuffering)); 636 636 637 637 /* Make sure the configured buffer size by the backend at least can hold the configured latency. */ 638 const uint32_t msPeriod = DrvAudioHlpFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPeriod);638 const uint32_t msPeriod = PDMAudioPropsFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPeriod); 639 639 640 640 LogRel2(("Audio: Period size of stream '%s' is %RU64ms (%RU32 frames)\n", … … 668 668 LogRel2(("Audio: Stream '%s' got a scheduling hint of %RU32ms (%RU32 bytes)\n", 669 669 pStream->szName, pCfgGuest->Device.cMsSchedulingHint, 670 DrvAudioHlpMilliToBytes(&pCfgGuest->Props, pCfgGuest->Device.cMsSchedulingHint)));670 PDMAudioPropsMilliToBytes(&pCfgGuest->Props, pCfgGuest->Device.cMsSchedulingHint))); 671 671 672 672 /* Destroy any former mixing buffer. */ … … 940 940 pStream->szName, DrvAudioHlpAudDirToStr(pStream->enmDir))); 941 941 942 AssertMsg( DrvAudioHlpIsBytesAligned(&pStream->Guest.Cfg.Props, cbBuf),942 AssertMsg(PDMAudioPropsIsSizeAligned(&pStream->Guest.Cfg.Props, cbBuf), 943 943 ("Stream '%s' got a non-frame-aligned write (%RU32 bytes)\n", pStream->szName, cbBuf)); 944 944 … … 990 990 if (cbFree < cbBuf) 991 991 LogRel2(("Audio: Lost audio output (%RU64ms, %RU32 free but needs %RU32) due to full host stream buffer '%s'\n", 992 DrvAudioHlpBytesToMilli(&pStream->Host.Cfg.Props, cbBuf - cbFree), cbFree, cbBuf, pStream->szName));992 PDMAudioPropsBytesToMilli(&pStream->Host.Cfg.Props, cbBuf - cbFree), cbFree, cbBuf, pStream->szName)); 993 993 994 994 uint32_t cbToWrite = RT_MIN(cbBuf, cbFree); … … 1029 1029 1030 1030 Log3Func(("[%s] Writing %RU32 frames (%RU64ms)\n", 1031 pStream->szName, cfGstWritten, DrvAudioHlpFramesToMilli(&pStream->Guest.Cfg.Props, cfGstWritten)));1031 pStream->szName, cfGstWritten, PDMAudioPropsFramesToMilli(&pStream->Guest.Cfg.Props, cfGstWritten))); 1032 1032 1033 1033 Log3Func(("[%s] Last written %RU64ns (%RU64ms), now filled with %RU64ms -- %RU8%%\n", 1034 1034 pStream->szName, tsNowNs - pStream->tsLastReadWrittenNs, 1035 1035 (tsNowNs - pStream->tsLastReadWrittenNs) / RT_NS_1MS, 1036 DrvAudioHlpFramesToMilli(&pStream->Host.Cfg.Props, AudioMixBufUsed(&pStream->Host.MixBuf)),1036 PDMAudioPropsFramesToMilli(&pStream->Host.Cfg.Props, AudioMixBufUsed(&pStream->Host.MixBuf)), 1037 1037 AudioMixBufUsed(&pStream->Host.MixBuf) * 100 / AudioMixBufSize(&pStream->Host.MixBuf))); 1038 1038 … … 1544 1544 #endif 1545 1545 const uint64_t tsDeltaPlayedCapturedNs = RTTimeNanoTS() - pStream->tsLastPlayedCapturedNs; 1546 const uint32_t cfPassedReal = DrvAudioHlpNanoToFrames(&pStream->Host.Cfg.Props, tsDeltaPlayedCapturedNs);1546 const uint32_t cfPassedReal = PDMAudioPropsNanoToFrames(&pStream->Host.Cfg.Props, tsDeltaPlayedCapturedNs); 1547 1547 1548 1548 const uint32_t cFramesPeriod = pStream->Host.Cfg.Backend.cFramesPeriod; … … 1550 1550 Log3Func(("[%s] Last played %RU64ns (%RU64ms), filled with %RU64ms (%RU8%%) total (fThresholdReached=%RTbool)\n", 1551 1551 pStream->szName, tsDeltaPlayedCapturedNs, tsDeltaPlayedCapturedNs / RT_NS_1MS_64, 1552 DrvAudioHlpFramesToMilli(&pStream->Host.Cfg.Props, cFramesLive), uLivePercent, pStream->fThresholdReached));1552 PDMAudioPropsFramesToMilli(&pStream->Host.Cfg.Props, cFramesLive), uLivePercent, pStream->fThresholdReached)); 1553 1553 1554 1554 if ( pStream->fThresholdReached /* Has the treshold been reached (e.g. are we in playing stage) ... */ … … 1556 1556 { 1557 1557 LogRel2(("Audio: Buffer underrun for stream '%s' occurred (%RU64ms passed)\n", 1558 pStream->szName, DrvAudioHlpFramesToMilli(&pStream->Host.Cfg.Props, cfPassedReal)));1558 pStream->szName, PDMAudioPropsFramesToMilli(&pStream->Host.Cfg.Props, cfPassedReal))); 1559 1559 1560 1560 if (pStream->Host.Cfg.Backend.cFramesPreBuffering) /* Any pre-buffering configured? */ … … 1614 1614 /* Did we reach/pass (in real time) the device scheduling slot? 1615 1615 * Play as much as we can write to the backend then. */ 1616 if (cfPassedReal >= DrvAudioHlpMilliToFrames(&pStream->Host.Cfg.Props, pStream->Guest.Cfg.Device.cMsSchedulingHint))1616 if (cfPassedReal >= PDMAudioPropsMilliToFrames(&pStream->Host.Cfg.Props, pStream->Guest.Cfg.Device.cMsSchedulingHint)) 1617 1617 cfToPlay = cfWritable; 1618 1618 } … … 1622 1622 #ifdef DEBUG 1623 1623 Log3Func(("[%s] Playing %RU32 frames (%RU64ms), now filled with %RU64ms -- %RU8%%\n", 1624 pStream->szName, cfToPlay, DrvAudioHlpFramesToMilli(&pStream->Host.Cfg.Props, cfToPlay),1625 DrvAudioHlpFramesToMilli(&pStream->Host.Cfg.Props, AudioMixBufUsed(&pStream->Host.MixBuf)),1624 pStream->szName, cfToPlay, PDMAudioPropsFramesToMilli(&pStream->Host.Cfg.Props, cfToPlay), 1625 PDMAudioPropsFramesToMilli(&pStream->Host.Cfg.Props, AudioMixBufUsed(&pStream->Host.MixBuf)), 1626 1626 AudioMixBufUsed(&pStream->Host.MixBuf) * 100 / AudioMixBufSize(&pStream->Host.MixBuf))); 1627 1627 #endif … … 1652 1652 "-> cfToPlay=%RU32 (%RU64ms), cfPlayed=%RU32 (%RU64ms)\n", 1653 1653 pStream->szName, fJustStarted, 1654 DrvAudioHlpMilliToFrames(&pStream->Host.Cfg.Props, pStream->Guest.Cfg.Device.cMsSchedulingHint),1654 PDMAudioPropsMilliToFrames(&pStream->Host.Cfg.Props, pStream->Guest.Cfg.Device.cMsSchedulingHint), 1655 1655 pStream->Guest.Cfg.Device.cMsSchedulingHint, 1656 cfPassedReal, DrvAudioHlpFramesToMilli(&pStream->Host.Cfg.Props, cfPassedReal),1657 cFramesLive, DrvAudioHlpFramesToMilli(&pStream->Host.Cfg.Props, cFramesLive),1658 cFramesPeriod, DrvAudioHlpFramesToMilli(&pStream->Host.Cfg.Props, cFramesPeriod),1659 cfWritable, DrvAudioHlpFramesToMilli(&pStream->Host.Cfg.Props, cfWritable),1660 cfToPlay, DrvAudioHlpFramesToMilli(&pStream->Host.Cfg.Props, cfToPlay),1661 cfPlayedTotal, DrvAudioHlpFramesToMilli(&pStream->Host.Cfg.Props, cfPlayedTotal)));1656 cfPassedReal, PDMAudioPropsFramesToMilli(&pStream->Host.Cfg.Props, cfPassedReal), 1657 cFramesLive, PDMAudioPropsFramesToMilli(&pStream->Host.Cfg.Props, cFramesLive), 1658 cFramesPeriod, PDMAudioPropsFramesToMilli(&pStream->Host.Cfg.Props, cFramesPeriod), 1659 cfWritable, PDMAudioPropsFramesToMilli(&pStream->Host.Cfg.Props, cfWritable), 1660 cfToPlay, PDMAudioPropsFramesToMilli(&pStream->Host.Cfg.Props, cfToPlay), 1661 cfPlayedTotal, PDMAudioPropsFramesToMilli(&pStream->Host.Cfg.Props, cfPlayedTotal))); 1662 1662 } 1663 1663 … … 2504 2504 { 2505 2505 Log3Func(("[%s] Filling in silence (%RU64ms / %RU64ms)\n", pStream->szName, 2506 DrvAudioHlpFramesToMilli(&pStream->Guest.Cfg.Props, cfBuf - cfReadTotal),2507 DrvAudioHlpFramesToMilli(&pStream->Guest.Cfg.Props, cfBuf)));2508 2509 DrvAudioHlpClearBuf(&pStream->Guest.Cfg.Props,2510 (uint8_t *)pvBuf + AUDIOMIXBUF_F2B(&pStream->Guest.MixBuf, cfReadTotal),2511 AUDIOMIXBUF_F2B(&pStream->Guest.MixBuf, cfBuf - cfReadTotal),2512 cfBuf - cfReadTotal);2506 PDMAudioPropsFramesToMilli(&pStream->Guest.Cfg.Props, cfBuf - cfReadTotal), 2507 PDMAudioPropsFramesToMilli(&pStream->Guest.Cfg.Props, cfBuf))); 2508 2509 PDMAudioPropsClearBuffer(&pStream->Guest.Cfg.Props, 2510 (uint8_t *)pvBuf + AUDIOMIXBUF_F2B(&pStream->Guest.MixBuf, cfReadTotal), 2511 AUDIOMIXBUF_F2B(&pStream->Guest.MixBuf, cfBuf - cfReadTotal), 2512 cfBuf - cfReadTotal); 2513 2513 2514 2514 cfReadTotal = cfBuf; … … 2966 2966 || fDisabled) 2967 2967 { 2968 cbReadable = DrvAudioHlpNanoToBytes(&pStream->Host.Cfg.Props, RTTimeNanoTS() - pStream->tsLastReadWrittenNs);2968 cbReadable = PDMAudioPropsNanoToBytes(&pStream->Host.Cfg.Props, RTTimeNanoTS() - pStream->tsLastReadWrittenNs); 2969 2969 if (!(pStream->fWarningsShown & PDMAUDIOSTREAM_WARN_FLAGS_DISABLED)) 2970 2970 { … … 2984 2984 /* Make sure to align the readable size to the guest's frame size. */ 2985 2985 if (cbReadable) 2986 cbReadable = DrvAudioHlpFloorBytesToFrame(&pStream->Guest.Cfg.Props, cbReadable);2986 cbReadable = PDMAudioPropsFloorBytesToFrame(&pStream->Guest.Cfg.Props, cbReadable); 2987 2987 } 2988 2988 2989 2989 Log3Func(("[%s] cbReadable=%RU32 (%RU64ms)\n", 2990 pStream->szName, cbReadable, DrvAudioHlpBytesToMilli(&pStream->Host.Cfg.Props, cbReadable)));2990 pStream->szName, cbReadable, PDMAudioPropsBytesToMilli(&pStream->Host.Cfg.Props, cbReadable))); 2991 2991 2992 2992 rc2 = RTCritSectLeave(&pThis->CritSect); … … 3021 3021 3022 3022 /* Make sure to align the writable size to the host's frame size. */ 3023 cbWritable = DrvAudioHlpFloorBytesToFrame(&pStream->Host.Cfg.Props, cbWritable);3023 cbWritable = PDMAudioPropsFloorBytesToFrame(&pStream->Host.Cfg.Props, cbWritable); 3024 3024 } 3025 3025 3026 3026 Log3Func(("[%s] cbWritable=%RU32 (%RU64ms)\n", 3027 pStream->szName, cbWritable, DrvAudioHlpBytesToMilli(&pStream->Host.Cfg.Props, cbWritable)));3027 pStream->szName, cbWritable, PDMAudioPropsBytesToMilli(&pStream->Host.Cfg.Props, cbWritable))); 3028 3028 3029 3029 rc2 = RTCritSectLeave(&pThis->CritSect); … … 3217 3217 if (pDrvCfg->uPeriodSizeMs) 3218 3218 { 3219 pCfgReq->Backend.cFramesPeriod = DrvAudioHlpMilliToFrames(&pCfgReq->Props, pDrvCfg->uPeriodSizeMs);3219 pCfgReq->Backend.cFramesPeriod = PDMAudioPropsMilliToFrames(&pCfgReq->Props, pDrvCfg->uPeriodSizeMs); 3220 3220 RTStrPrintf(szWhat, sizeof(szWhat), "custom"); 3221 3221 } … … 3223 3223 if (!pCfgReq->Backend.cFramesPeriod) /* Set default period size if nothing explicitly is set. */ 3224 3224 { 3225 pCfgReq->Backend.cFramesPeriod = DrvAudioHlpMilliToFrames(&pCfgReq->Props, 150 /*ms*/);3225 pCfgReq->Backend.cFramesPeriod = PDMAudioPropsMilliToFrames(&pCfgReq->Props, 150 /*ms*/); 3226 3226 RTStrPrintf(szWhat, sizeof(szWhat), "default"); 3227 3227 } 3228 3228 3229 3229 LogRel2(("Audio: Using %s period size %RU64 ms / %RU32 frames for stream '%s'\n", 3230 szWhat, DrvAudioHlpFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesPeriod),3230 szWhat, PDMAudioPropsFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesPeriod), 3231 3231 pCfgReq->Backend.cFramesPeriod, pStream->szName)); 3232 3232 … … 3236 3236 if (pDrvCfg->uBufferSizeMs) 3237 3237 { 3238 pCfgReq->Backend.cFramesBufferSize = DrvAudioHlpMilliToFrames(&pCfgReq->Props, pDrvCfg->uBufferSizeMs);3238 pCfgReq->Backend.cFramesBufferSize = PDMAudioPropsMilliToFrames(&pCfgReq->Props, pDrvCfg->uBufferSizeMs); 3239 3239 RTStrPrintf(szWhat, sizeof(szWhat), "custom"); 3240 3240 } … … 3242 3242 if (!pCfgReq->Backend.cFramesBufferSize) /* Set default buffer size if nothing explicitly is set. */ 3243 3243 { 3244 pCfgReq->Backend.cFramesBufferSize = DrvAudioHlpMilliToFrames(&pCfgReq->Props, 300 /*ms*/);3244 pCfgReq->Backend.cFramesBufferSize = PDMAudioPropsMilliToFrames(&pCfgReq->Props, 300 /*ms*/); 3245 3245 RTStrPrintf(szWhat, sizeof(szWhat), "default"); 3246 3246 } 3247 3247 3248 3248 LogRel2(("Audio: Using %s buffer size %RU64 ms / %RU32 frames for stream '%s'\n", 3249 szWhat, DrvAudioHlpFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize),3249 szWhat, PDMAudioPropsFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize), 3250 3250 pCfgReq->Backend.cFramesBufferSize, pStream->szName)); 3251 3251 … … 3255 3255 if (pDrvCfg->uPreBufSizeMs != UINT32_MAX) /* Anything set via global / per-VM extra-data? */ 3256 3256 { 3257 pCfgReq->Backend.cFramesPreBuffering = DrvAudioHlpMilliToFrames(&pCfgReq->Props, pDrvCfg->uPreBufSizeMs);3257 pCfgReq->Backend.cFramesPreBuffering = PDMAudioPropsMilliToFrames(&pCfgReq->Props, pDrvCfg->uPreBufSizeMs); 3258 3258 RTStrPrintf(szWhat, sizeof(szWhat), "custom"); 3259 3259 } … … 3269 3269 3270 3270 LogRel2(("Audio: Using %s pre-buffering size %RU64 ms / %RU32 frames for stream '%s'\n", 3271 szWhat, DrvAudioHlpFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesPreBuffering),3271 szWhat, PDMAudioPropsFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesPreBuffering), 3272 3272 pCfgReq->Backend.cFramesPreBuffering, pStream->szName)); 3273 3273 … … 3278 3278 { 3279 3279 LogRel(("Audio: Error for stream '%s': Buffering size (%RU64ms) must not be smaller than the period size (%RU64ms)\n", 3280 pStream->szName, DrvAudioHlpFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize),3281 DrvAudioHlpFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesPeriod)));3280 pStream->szName, PDMAudioPropsFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize), 3281 PDMAudioPropsFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesPeriod))); 3282 3282 return VERR_INVALID_PARAMETER; 3283 3283 } … … 3289 3289 { 3290 3290 LogRel(("Audio: Error for stream '%s': Buffering size (%RU64ms) must not be smaller than the pre-buffering size (%RU64ms)\n", 3291 pStream->szName, DrvAudioHlpFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesPreBuffering),3292 DrvAudioHlpFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize)));3291 pStream->szName, PDMAudioPropsFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesPreBuffering), 3292 PDMAudioPropsFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize))); 3293 3293 return VERR_INVALID_PARAMETER; 3294 3294 } … … 3328 3328 if (pCfgAcq->Backend.cFramesBufferSize != pCfgReq->Backend.cFramesBufferSize) 3329 3329 LogRel2(("Audio: Buffer size overwritten by backend for stream '%s' (now %RU64ms, %RU32 frames)\n", 3330 pStream->szName, DrvAudioHlpFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesBufferSize), pCfgAcq->Backend.cFramesBufferSize));3330 pStream->szName, PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesBufferSize), pCfgAcq->Backend.cFramesBufferSize)); 3331 3331 3332 3332 if (pCfgAcq->Backend.cFramesPeriod != pCfgReq->Backend.cFramesPeriod) 3333 3333 LogRel2(("Audio: Period size overwritten by backend for stream '%s' (now %RU64ms, %RU32 frames)\n", 3334 pStream->szName, DrvAudioHlpFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPeriod), pCfgAcq->Backend.cFramesPeriod));3334 pStream->szName, PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPeriod), pCfgAcq->Backend.cFramesPeriod)); 3335 3335 3336 3336 /* Was pre-buffering requested, but the acquired configuration from the backend told us something else? */ … … 3339 3339 if (pCfgAcq->Backend.cFramesPreBuffering != pCfgReq->Backend.cFramesPreBuffering) 3340 3340 LogRel2(("Audio: Pre-buffering size overwritten by backend for stream '%s' (now %RU64ms, %RU32 frames)\n", 3341 pStream->szName, DrvAudioHlpFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPreBuffering), pCfgAcq->Backend.cFramesPreBuffering));3341 pStream->szName, PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPreBuffering), pCfgAcq->Backend.cFramesPreBuffering)); 3342 3342 3343 3343 if (pCfgAcq->Backend.cFramesPreBuffering > pCfgAcq->Backend.cFramesBufferSize) … … 3345 3345 pCfgAcq->Backend.cFramesPreBuffering = pCfgAcq->Backend.cFramesBufferSize; 3346 3346 LogRel2(("Audio: Pre-buffering size bigger than buffer size for stream '%s', adjusting to %RU64ms (%RU32 frames)\n", 3347 pStream->szName, DrvAudioHlpFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPreBuffering), pCfgAcq->Backend.cFramesPreBuffering));3347 pStream->szName, PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPreBuffering), pCfgAcq->Backend.cFramesPreBuffering)); 3348 3348 } 3349 3349 } -
trunk/src/VBox/Devices/Audio/DrvAudio.h
r88016 r88022 200 200 /** @name Audio PCM properties helper methods. 201 201 * @{ */ 202 void DrvAudioHlpClearBuf(PCPDMAUDIOPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t cFrames); 203 uint32_t DrvAudioHlpGetBitrate(PCPDMAUDIOPCMPROPS pProps); 204 uint32_t DrvAudioHlpFloorBytesToFrame(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 205 bool DrvAudioHlpIsBytesAligned(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 206 uint32_t DrvAudioHlpBytesPerFrame(PCPDMAUDIOPCMPROPS pProps); 207 uint32_t DrvAudioHlpBytesToFrames(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 208 uint64_t DrvAudioHlpBytesToMilli(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 209 uint64_t DrvAudioHlpBytesToMicro(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 210 uint64_t DrvAudioHlpBytesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 211 uint32_t DrvAudioHlpFramesToBytes(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames); 212 uint64_t DrvAudioHlpFramesToMilli(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames); 213 uint64_t DrvAudioHlpFramesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames); 214 uint32_t DrvAudioHlpMilliToBytes(PCPDMAUDIOPCMPROPS pProps, uint64_t cMs); 215 uint32_t DrvAudioHlpNanoToBytes(PCPDMAUDIOPCMPROPS pProps, uint64_t cNs); 216 uint32_t DrvAudioHlpMilliToFrames(PCPDMAUDIOPCMPROPS pProps, uint64_t cMs); 217 uint32_t DrvAudioHlpNanoToFrames(PCPDMAUDIOPCMPROPS pProps, uint64_t cNs); 218 219 bool DrvAudioHlpPcmPropsAreEqual(PCPDMAUDIOPCMPROPS pPCMProps1, PCPDMAUDIOPCMPROPS pPCMProps2); 202 void PDMAudioPropsClearBuffer(PCPDMAUDIOPCMPROPS pProps, void *pvBuf, size_t cbBuf, uint32_t cFrames); 203 uint32_t PDMAudioPropsGetBitrate(PCPDMAUDIOPCMPROPS pProps); 204 uint32_t PDMAudioPropsFloorBytesToFrame(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 205 bool PDMAudioPropsIsSizeAligned(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 206 uint32_t PDMAudioPropsBytesPerFrame(PCPDMAUDIOPCMPROPS pProps); 207 uint32_t PDMAudioPropsBytesToFrames(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 208 uint64_t PDMAudioPropsBytesToMilli(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 209 uint64_t PDMAudioPropsBytesToMicro(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 210 uint64_t PDMAudioPropsBytesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 211 uint32_t PDMAudioPropsFramesToBytes(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames); 212 uint64_t PDMAudioPropsFramesToMilli(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames); 213 uint64_t PDMAudioPropsFramesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames); 214 uint32_t PDMAudioPropsMilliToBytes(PCPDMAUDIOPCMPROPS pProps, uint64_t cMs); 215 uint32_t PDMAudioPropsNanoToBytes(PCPDMAUDIOPCMPROPS pProps, uint64_t cNs); 216 uint32_t PDMAudioPropsMilliToFrames(PCPDMAUDIOPCMPROPS pProps, uint64_t cMs); 217 uint32_t PDMAudioPropsNanoToFrames(PCPDMAUDIOPCMPROPS pProps, uint64_t cNs); 218 219 bool PDMAudioPropsAreEqual(PCPDMAUDIOPCMPROPS pPCMProps1, PCPDMAUDIOPCMPROPS pPCMProps2); 220 void PDMAudioPropsLog(PCPDMAUDIOPCMPROPS pProps); 221 220 222 bool DrvAudioHlpPcmPropsAreValid(PCPDMAUDIOPCMPROPS pProps); 221 void DrvAudioHlpPcmPropsLog(PCPDMAUDIOPCMPROPS pProps);222 223 /** @} */ 223 224 -
trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
r88017 r88022 801 801 { 802 802 AssertPtrReturn(pCfg, false); 803 return DrvAudioHlpPcmPropsAreEqual(pProps, &pCfg->Props);803 return PDMAudioPropsAreEqual(pProps, &pCfg->Props); 804 804 } 805 805 … … 997 997 * @param pProps PCM properties to calculate bitrate for. 998 998 */ 999 uint32_t DrvAudioHlpGetBitrate(PCPDMAUDIOPCMPROPS pProps)999 uint32_t PDMAudioPropsGetBitrate(PCPDMAUDIOPCMPROPS pProps) 1000 1000 { 1001 1001 return DrvAudioHlpCalcBitrate(pProps->cbSample * 8, pProps->uHz, pProps->cChannels); … … 1009 1009 * @param cb The size (in bytes) to round. 1010 1010 */ 1011 uint32_t DrvAudioHlpFloorBytesToFrame(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)1011 uint32_t PDMAudioPropsFloorBytesToFrame(PCPDMAUDIOPCMPROPS pProps, uint32_t cb) 1012 1012 { 1013 1013 AssertPtrReturn(pProps, 0); … … 1022 1022 * @param cb The size (in bytes) to check. 1023 1023 */ 1024 bool DrvAudioHlpIsBytesAligned(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)1024 bool PDMAudioPropsIsSizeAligned(PCPDMAUDIOPCMPROPS pProps, uint32_t cb) 1025 1025 { 1026 1026 AssertPtrReturn(pProps, false); … … 1037 1037 * @param cb The number of bytes to convert. 1038 1038 */ 1039 uint32_t DrvAudioHlpBytesToFrames(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)1039 uint32_t PDMAudioPropsBytesToFrames(PCPDMAUDIOPCMPROPS pProps, uint32_t cb) 1040 1040 { 1041 1041 AssertPtrReturn(pProps, 0); … … 1052 1052 * @note Rounds up the result. 1053 1053 */ 1054 uint64_t DrvAudioHlpBytesToMilli(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)1054 uint64_t PDMAudioPropsBytesToMilli(PCPDMAUDIOPCMPROPS pProps, uint32_t cb) 1055 1055 { 1056 1056 AssertPtrReturn(pProps, 0); … … 1082 1082 * @note Rounds up the result. 1083 1083 */ 1084 uint64_t DrvAudioHlpBytesToMicro(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)1084 uint64_t PDMAudioPropsBytesToMicro(PCPDMAUDIOPCMPROPS pProps, uint32_t cb) 1085 1085 { 1086 1086 AssertPtrReturn(pProps, 0); … … 1112 1112 * @note Rounds up the result. 1113 1113 */ 1114 uint64_t DrvAudioHlpBytesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)1114 uint64_t PDMAudioPropsBytesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cb) 1115 1115 { 1116 1116 AssertPtrReturn(pProps, 0); … … 1141 1141 * @sa PDMAUDIOPCMPROPS_F2B 1142 1142 */ 1143 uint32_t DrvAudioHlpFramesToBytes(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames)1143 uint32_t PDMAudioPropsFramesToBytes(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames) 1144 1144 { 1145 1145 AssertPtrReturn(pProps, 0); … … 1155 1155 * @note No rounding here, result is floored. 1156 1156 */ 1157 uint64_t DrvAudioHlpFramesToMilli(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames)1157 uint64_t PDMAudioPropsFramesToMilli(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames) 1158 1158 { 1159 1159 AssertPtrReturn(pProps, 0); … … 1174 1174 * @note No rounding here, result is floored. 1175 1175 */ 1176 uint64_t DrvAudioHlpFramesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames)1176 uint64_t PDMAudioPropsFramesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames) 1177 1177 { 1178 1178 AssertPtrReturn(pProps, 0); … … 1194 1194 * @note The result is rounded rather than floored (hysterical raisins). 1195 1195 */ 1196 uint32_t DrvAudioHlpMilliToFrames(PCPDMAUDIOPCMPROPS pProps, uint64_t cMs)1196 uint32_t PDMAudioPropsMilliToFrames(PCPDMAUDIOPCMPROPS pProps, uint64_t cMs) 1197 1197 { 1198 1198 AssertPtrReturn(pProps, 0); … … 1220 1220 * @note The result is rounded rather than floored (hysterical raisins). 1221 1221 */ 1222 uint32_t DrvAudioHlpMilliToBytes(PCPDMAUDIOPCMPROPS pProps, uint64_t cMs)1223 { 1224 return PDMAUDIOPCMPROPS_F2B(pProps, DrvAudioHlpMilliToFrames(pProps, cMs));1222 uint32_t PDMAudioPropsMilliToBytes(PCPDMAUDIOPCMPROPS pProps, uint64_t cMs) 1223 { 1224 return PDMAUDIOPCMPROPS_F2B(pProps, PDMAudioPropsMilliToFrames(pProps, cMs)); 1225 1225 } 1226 1226 … … 1234 1234 * @note The result is rounded rather than floored (hysterical raisins). 1235 1235 */ 1236 uint32_t DrvAudioHlpNanoToFrames(PCPDMAUDIOPCMPROPS pProps, uint64_t cNs)1236 uint32_t PDMAudioPropsNanoToFrames(PCPDMAUDIOPCMPROPS pProps, uint64_t cNs) 1237 1237 { 1238 1238 AssertPtrReturn(pProps, 0); … … 1260 1260 * @note The result is rounded rather than floored (hysterical raisins). 1261 1261 */ 1262 uint32_t DrvAudioHlpNanoToBytes(PCPDMAUDIOPCMPROPS pProps, uint64_t cNs)1263 { 1264 return PDMAUDIOPCMPROPS_F2B(pProps, DrvAudioHlpNanoToFrames(pProps, cNs));1262 uint32_t PDMAudioPropsNanoToBytes(PCPDMAUDIOPCMPROPS pProps, uint64_t cNs) 1263 { 1264 return PDMAUDIOPCMPROPS_F2B(pProps, PDMAudioPropsNanoToFrames(pProps, cNs)); 1265 1265 } 1266 1266 … … 1269 1269 * given by the PCM properties). 1270 1270 * 1271 * @param pPCMProps PCM properties to use for the buffer to clear. 1272 * @param pvBuf Buffer to clear. 1273 * @param cbBuf Size (in bytes) of the buffer. 1274 * @param cFrames Number of audio frames to clear in the buffer. 1275 */ 1276 void DrvAudioHlpClearBuf(PCPDMAUDIOPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t cFrames) 1271 * @param pProps The PCM properties to apply. 1272 * @param pvBuf The buffer to clear. 1273 * @param cbBuf The buffer size in bytes. 1274 * @param cFrames The number of audio frames to clear. Capped at @a cbBuf 1275 * if exceeding the buffer. If the size is an unaligned 1276 * number of frames, the extra bytes may be left 1277 * uninitialized in some configurations. 1278 */ 1279 void PDMAudioPropsClearBuffer(PCPDMAUDIOPCMPROPS pProps, void *pvBuf, size_t cbBuf, uint32_t cFrames) 1277 1280 { 1278 1281 /* 1279 1282 * Validate input 1280 1283 */ 1281 AssertPtrReturnVoid(pP CMProps);1282 Assert(pP CMProps->cbSample);1284 AssertPtrReturnVoid(pProps); 1285 Assert(pProps->cbSample); 1283 1286 if (!cbBuf || !cFrames) 1284 1287 return; 1285 1288 AssertPtrReturnVoid(pvBuf); 1286 1289 1287 Assert(pP CMProps->fSwapEndian == false); /** @todo Swapping Endianness is not supported yet. */1290 Assert(pProps->fSwapEndian == false); /** @todo Swapping Endianness is not supported yet. */ 1288 1291 1289 1292 /* 1290 1293 * Decide how much needs clearing. 1291 1294 */ 1292 size_t cbToClear = DrvAudioHlpFramesToBytes(pPCMProps, cFrames);1295 size_t cbToClear = PDMAudioPropsFramesToBytes(pProps, cFrames); 1293 1296 AssertStmt(cbToClear <= cbBuf, cbToClear = cbBuf); 1294 1297 1295 Log2Func(("pP CMProps=%p, pvBuf=%p, cFrames=%RU32, fSigned=%RTbool, cBytes=%RU8\n",1296 pP CMProps, pvBuf, cFrames, pPCMProps->fSigned, pPCMProps->cbSample));1298 Log2Func(("pProps=%p, pvBuf=%p, cFrames=%RU32, fSigned=%RTbool, cBytes=%RU8\n", 1299 pProps, pvBuf, cFrames, pProps->fSigned, pProps->cbSample)); 1297 1300 1298 1301 /* 1299 1302 * Do the job. 1300 1303 */ 1301 if (pP CMProps->fSigned)1304 if (pProps->fSigned) 1302 1305 RT_BZERO(pvBuf, cbToClear); 1303 1306 else /* Unsigned formats. */ 1304 1307 { 1305 switch (pP CMProps->cbSample)1308 switch (pProps->cbSample) 1306 1309 { 1307 1310 case 1: /* 8 bit */ … … 1325 1328 1326 1329 default: 1327 AssertMsgFailed(("Invalid bytes per sample: %RU8\n", pP CMProps->cbSample));1330 AssertMsgFailed(("Invalid bytes per sample: %RU8\n", pProps->cbSample)); 1328 1331 } 1329 1332 } … … 1337 1340 * @param pProps2 The second set of properties to compare. 1338 1341 */ 1339 bool DrvAudioHlpPcmPropsAreEqual(PCPDMAUDIOPCMPROPS pProps1, PCPDMAUDIOPCMPROPS pProps2)1342 bool PDMAudioPropsAreEqual(PCPDMAUDIOPCMPROPS pProps1, PCPDMAUDIOPCMPROPS pProps2) 1340 1343 { 1341 1344 AssertPtrReturn(pProps1, false); … … 1416 1419 * @sa PDMAUDIOPCMPROPS_F2B 1417 1420 */ 1418 uint32_t DrvAudioHlpBytesPerFrame(PCPDMAUDIOPCMPROPS pProps)1421 uint32_t PDMAudioPropsBytesPerFrame(PCPDMAUDIOPCMPROPS pProps) 1419 1422 { 1420 1423 return PDMAUDIOPCMPROPS_F2B(pProps, 1 /*cFrames*/); … … 1426 1429 * @param pProps Stream configuration to log. 1427 1430 */ 1428 void DrvAudioHlpPcmPropsLog(PCPDMAUDIOPCMPROPS pProps)1431 void PDMAudioPropsLog(PCPDMAUDIOPCMPROPS pProps) 1429 1432 { 1430 1433 AssertPtrReturnVoid(pProps); … … 1714 1717 pData->Hdr.u16NumChannels = pProps->cChannels; 1715 1718 pData->Hdr.u32SampleRate = pProps->uHz; 1716 pData->Hdr.u32ByteRate = DrvAudioHlpGetBitrate(pProps) / 8;1719 pData->Hdr.u32ByteRate = PDMAudioPropsGetBitrate(pProps) / 8; 1717 1720 pData->Hdr.u16BlockAlign = pProps->cChannels * pProps->cbSample; 1718 1721 pData->Hdr.u16BitsPerSample = pProps->cbSample * 8; -
trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp
r88009 r88022 999 999 pCfgAcq->Backend.cFramesPreBuffering = obt.threshold; 1000 1000 1001 pStreamALSA->cbBuf = pCfgAcq->Backend.cFramesBufferSize * DrvAudioHlpBytesPerFrame(&pCfgAcq->Props);1001 pStreamALSA->cbBuf = pCfgAcq->Backend.cFramesBufferSize * PDMAudioPropsBytesPerFrame(&pCfgAcq->Props); 1002 1002 pStreamALSA->pvBuf = RTMemAllocZ(pStreamALSA->cbBuf); 1003 1003 if (!pStreamALSA->pvBuf) … … 1039 1039 req.freq = pCfgReq->Props.uHz; 1040 1040 req.nchannels = pCfgReq->Props.cChannels; 1041 req.period_size = DrvAudioHlpMilliToFrames(&pCfgReq->Props, 50 /*ms*/); /** @todo Make this configurable. */1041 req.period_size = PDMAudioPropsMilliToFrames(&pCfgReq->Props, 50 /*ms*/); /** @todo Make this configurable. */ 1042 1042 req.buffer_size = req.period_size * 2; /** @todo Make this configurable. */ 1043 1043 req.threshold = req.period_size; … … 1059 1059 /* No pre-buffering. */ 1060 1060 1061 pStreamALSA->cbBuf = pCfgAcq->Backend.cFramesBufferSize * DrvAudioHlpBytesPerFrame(&pCfgAcq->Props);1061 pStreamALSA->cbBuf = pCfgAcq->Backend.cFramesBufferSize * PDMAudioPropsBytesPerFrame(&pCfgAcq->Props); 1062 1062 pStreamALSA->pvBuf = RTMemAlloc(pStreamALSA->cbBuf); 1063 1063 if (!pStreamALSA->pvBuf) … … 1501 1501 Log2Func(("cFramesDelay=%RI32, enmState=%d, rc=%d\n", cFramesDelay, enmState, rc)); 1502 1502 1503 return DrvAudioHlpFramesToBytes(&pStreamALSA->pCfg->Props, cFramesDelay);1503 return PDMAudioPropsFramesToBytes(&pStreamALSA->pCfg->Props, cFramesDelay); 1504 1504 } 1505 1505 -
trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp
r87994 r88022 1305 1305 return VERR_GENERAL_FAILURE; /** @todo Fudge! */ 1306 1306 1307 const size_t cbBufSize = DrvAudioHlpFramesToBytes(&pCAStream->pCfg->Props, pCAStream->pCfg->Backend.cFramesPeriod);1307 const size_t cbBufSize = PDMAudioPropsFramesToBytes(&pCAStream->pCfg->Props, pCAStream->pCfg->Backend.cFramesPeriod); 1308 1308 1309 1309 /* -
trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
r87994 r88022 666 666 */ 667 667 bd.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCSOFTWARE; 668 bd.dwBufferBytes = DrvAudioHlpFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize);668 bd.dwBufferBytes = PDMAudioPropsFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize); 669 669 670 670 DSLOG(("DSound: Requested playback buffer is %RU64ms (%ld bytes)\n", 671 DrvAudioHlpBytesToMilli(&pCfgReq->Props, bd.dwBufferBytes), bd.dwBufferBytes));671 PDMAudioPropsBytesToMilli(&pCfgReq->Props, bd.dwBufferBytes), bd.dwBufferBytes)); 672 672 673 673 hr = IDirectSound8_CreateSoundBuffer(pThis->pDS, &bd, &pDSB, NULL); … … 711 711 712 712 DSLOG(("DSound: Acquired playback buffer is %RU64ms (%ld bytes)\n", 713 DrvAudioHlpBytesToMilli(&pCfgReq->Props, bc.dwBufferBytes), bc.dwBufferBytes));713 PDMAudioPropsBytesToMilli(&pCfgReq->Props, bc.dwBufferBytes), bc.dwBufferBytes)); 714 714 715 715 DSLOG(("DSound: Acquired playback format:\n" … … 779 779 if (SUCCEEDED(hr)) 780 780 { 781 DrvAudioHlpClearBuf(pProps, pv1, pStreamDS->cbBufSize, PDMAUDIOPCMPROPS_B2F(pProps, pStreamDS->cbBufSize));781 PDMAudioPropsClearBuffer(pProps, pv1, pStreamDS->cbBufSize, PDMAUDIOPCMPROPS_B2F(pProps, pStreamDS->cbBufSize)); 782 782 783 783 directSoundPlayUnlock(pThis, pStreamDS->Out.pDSB, pv1, NULL, 0, 0); … … 895 895 896 896 if ( pStreamDS->Out.fFirstTransfer 897 && pStreamDS->Out.cbTransferred >= DrvAudioHlpFramesToBytes(&pStreamDS->Cfg.Props, pStreamDS->Cfg.Backend.cFramesPreBuffering))897 && pStreamDS->Out.cbTransferred >= PDMAudioPropsFramesToBytes(&pStreamDS->Cfg.Props, pStreamDS->Cfg.Backend.cFramesPreBuffering)) 898 898 { 899 899 hr = directSoundPlayStart(pThis, pStreamDS); … … 1041 1041 if (SUCCEEDED(hr)) 1042 1042 { 1043 DrvAudioHlpClearBuf(&pStreamDS->Cfg.Props, pv1, cb1, PDMAUDIOPCMPROPS_B2F(&pStreamDS->Cfg.Props, cb1));1043 PDMAudioPropsClearBuffer(&pStreamDS->Cfg.Props, pv1, cb1, PDMAUDIOPCMPROPS_B2F(&pStreamDS->Cfg.Props, cb1)); 1044 1044 if (pv2 && cb2) 1045 DrvAudioHlpClearBuf(&pStreamDS->Cfg.Props, pv2, cb2, PDMAUDIOPCMPROPS_B2F(&pStreamDS->Cfg.Props, cb2));1045 PDMAudioPropsClearBuffer(&pStreamDS->Cfg.Props, pv2, cb2, PDMAUDIOPCMPROPS_B2F(&pStreamDS->Cfg.Props, cb2)); 1046 1046 directSoundCaptureUnlock(pStreamDS->In.pDSCB, pv1, pv2, cb1, cb2); 1047 1047 } … … 1076 1076 if (SUCCEEDED(hr)) 1077 1077 { 1078 DrvAudioHlpClearBuf(&pStreamDS->Cfg.Props, pv1, cb1, PDMAUDIOPCMPROPS_B2F(&pStreamDS->Cfg.Props, cb1));1078 PDMAudioPropsClearBuffer(&pStreamDS->Cfg.Props, pv1, cb1, PDMAUDIOPCMPROPS_B2F(&pStreamDS->Cfg.Props, cb1)); 1079 1079 if (pv2 && cb2) 1080 DrvAudioHlpClearBuf(&pStreamDS->Cfg.Props, pv2, cb2, PDMAUDIOPCMPROPS_B2F(&pStreamDS->Cfg.Props, cb2));1080 PDMAudioPropsClearBuffer(&pStreamDS->Cfg.Props, pv2, cb2, PDMAUDIOPCMPROPS_B2F(&pStreamDS->Cfg.Props, cb2)); 1081 1081 directSoundPlayUnlock(pThis, pStreamDS->Out.pDSB, pv1, pv2, cb1, cb2); 1082 1082 } … … 1401 1401 bd.dwSize = sizeof(bd); 1402 1402 bd.lpwfxFormat = &wfx; 1403 bd.dwBufferBytes = DrvAudioHlpFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize);1403 bd.dwBufferBytes = PDMAudioPropsFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize); 1404 1404 1405 1405 DSLOG(("DSound: Requested capture buffer is %RU64ms (%ld bytes)\n", 1406 DrvAudioHlpBytesToMilli(&pCfgReq->Props, bd.dwBufferBytes), bd.dwBufferBytes));1406 PDMAudioPropsBytesToMilli(&pCfgReq->Props, bd.dwBufferBytes), bd.dwBufferBytes)); 1407 1407 1408 1408 LPDIRECTSOUNDCAPTUREBUFFER pDSCB; … … 1457 1457 1458 1458 DSLOG(("DSound: Acquired capture buffer is %RU64ms (%ld bytes)\n", 1459 DrvAudioHlpBytesToMilli(&pCfgReq->Props, bc.dwBufferBytes), bc.dwBufferBytes));1459 PDMAudioPropsBytesToMilli(&pCfgReq->Props, bc.dwBufferBytes), bc.dwBufferBytes)); 1460 1460 1461 1461 DSLOG(("DSound: Capture format:\n" … … 2500 2500 { 2501 2501 const uint64_t diffLastTransferredMs = RTTimeMilliTS() - pStreamDS->Out.tsLastTransferredMs; 2502 const uint64_t uLastTranserredChunkMs = DrvAudioHlpBytesToMilli(&pStreamDS->Cfg.Props, pStreamDS->Out.cbLastTransferred);2502 const uint64_t uLastTranserredChunkMs = PDMAudioPropsBytesToMilli(&pStreamDS->Cfg.Props, pStreamDS->Out.cbLastTransferred); 2503 2503 if ( uLastTranserredChunkMs 2504 2504 && diffLastTransferredMs < uLastTranserredChunkMs) -
trunk/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp
r88002 r88022 349 349 AssertPtr(pStreamDbg->pCfg); 350 350 351 return DrvAudioHlpMilliToBytes(&pStreamDbg->pCfg->Props, 10 /*ms*/);351 return PDMAudioPropsMilliToBytes(&pStreamDbg->pCfg->Props, 10 /*ms*/); 352 352 } 353 353 -
trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp
r82968 r88022 168 168 /* Return silence. */ 169 169 Assert(pStreamNull->pCfg); 170 DrvAudioHlpClearBuf(&pStreamNull->pCfg->Props, pvBuf, uBufSize, PDMAUDIOPCMPROPS_B2F(&pStreamNull->pCfg->Props, uBufSize));170 PDMAudioPropsClearBuffer(&pStreamNull->pCfg->Props, pvBuf, uBufSize, PDMAUDIOPCMPROPS_B2F(&pStreamNull->pCfg->Props, uBufSize)); 171 171 172 172 if (puRead) -
trunk/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp
r82968 r88022 356 356 case PDMAUDIOSTREAMCMD_RESUME: 357 357 { 358 DrvAudioHlpClearBuf(&pStreamOSS->pCfg->Props, pStreamOSS->pvBuf, pStreamOSS->cbBuf,359 PDMAUDIOPCMPROPS_B2F(&pStreamOSS->pCfg->Props, pStreamOSS->cbBuf));358 PDMAudioPropsClearBuffer(&pStreamOSS->pCfg->Props, pStreamOSS->pvBuf, pStreamOSS->cbBuf, 359 PDMAUDIOPCMPROPS_B2F(&pStreamOSS->pCfg->Props, pStreamOSS->cbBuf)); 360 360 361 361 int mask = PCM_ENABLE_OUTPUT; -
trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp
r87994 r88022 794 794 pStreamPA->SampleSpec.channels = pCfgReq->Props.cChannels; 795 795 796 pStreamPA->curLatencyUs = DrvAudioHlpFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize) * RT_US_1MS;796 pStreamPA->curLatencyUs = PDMAudioPropsFramesToMilli(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize) * RT_US_1MS; 797 797 798 798 const uint32_t cbLatency = pa_usec_to_bytes(pStreamPA->curLatencyUs, &pStreamPA->SampleSpec); … … 803 803 pStreamPA->BufAttr.maxlength = -1; /* Let the PulseAudio server choose the biggest size it can handle. */ 804 804 pStreamPA->BufAttr.prebuf = cbLatency; 805 pStreamPA->BufAttr.minreq = DrvAudioHlpFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesPeriod);805 pStreamPA->BufAttr.minreq = PDMAudioPropsFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesPeriod); 806 806 807 807 LogFunc(("Requested: BufAttr tlength=%RU32, maxLength=%RU32, minReq=%RU32\n", … … 849 849 pStreamPA->SampleSpec.channels = pCfgReq->Props.cChannels; 850 850 851 pStreamPA->BufAttr.fragsize = DrvAudioHlpFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesPeriod);851 pStreamPA->BufAttr.fragsize = PDMAudioPropsFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesPeriod); 852 852 pStreamPA->BufAttr.maxlength = -1; /* Let the PulseAudio server choose the biggest size it can handle. */ 853 853 -
trunk/src/VBox/Devices/Audio/DrvHostValidationKit.cpp
r87994 r88022 145 145 pStreamDbg->uSamplesSinceStarted = 0; 146 146 pStreamDbg->Out.tsLastPlayed = 0; 147 pStreamDbg->Out.cbPlayBuffer = DrvAudioHlpFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize);147 pStreamDbg->Out.cbPlayBuffer = PDMAudioPropsFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize); 148 148 pStreamDbg->Out.pu8PlayBuffer = (uint8_t *)RTMemAlloc(pStreamDbg->Out.cbPlayBuffer); 149 149 AssertReturn(pStreamDbg->Out.pu8PlayBuffer, VERR_NO_MEMORY); -
trunk/src/VBox/Devices/Audio/HDAStream.cpp
r88016 r88022 354 354 LogRel2(("HDA: Stream #%RU8 DMA @ 0x%x (%RU32 bytes = %RU64ms total)\n", 355 355 uSD, pStreamShared->u64BDLBase, pStreamShared->u32CBL, 356 DrvAudioHlpBytesToMilli(&pStreamR3->State.Mapping.PCMProps, pStreamShared->u32CBL)));356 PDMAudioPropsBytesToMilli(&pStreamR3->State.Mapping.PCMProps, pStreamShared->u32CBL))); 357 357 358 358 /* Figure out how many transfer fragments we're going to use for this stream. */ … … 456 456 457 457 /* Audio data per second the stream needs. */ 458 const uint32_t cbDataPerSec = DrvAudioHlpMilliToBytes(&pStreamR3->State.Mapping.PCMProps, RT_MS_1SEC);458 const uint32_t cbDataPerSec = PDMAudioPropsMilliToBytes(&pStreamR3->State.Mapping.PCMProps, RT_MS_1SEC); 459 459 460 460 /* This is used to indicate whether we're done or should the uTimerIoHz as fallback. */ … … 532 532 if (cbTransferHeuristics >= 8) 533 533 { 534 ASSERT_GUEST_LOGREL_MSG( DrvAudioHlpIsBytesAligned(&pStreamR3->State.Mapping.PCMProps, cbTransferHeuristics),534 ASSERT_GUEST_LOGREL_MSG(PDMAudioPropsIsSizeAligned(&pStreamR3->State.Mapping.PCMProps, cbTransferHeuristics), 535 535 ("We arrived at a misaligned transfer size for stream #%RU8: %#x (%u)\n", 536 536 uSD, cbTransferHeuristics, cbTransferHeuristics)); … … 544 544 halve the buffer till we get there. */ 545 545 while (cbTransferHeuristics > 1024 && cbTransferHeuristics > cbTransferPerSec / 4) 546 cbTransferHeuristics = DrvAudioHlpFloorBytesToFrame(&pStreamR3->State.Mapping.PCMProps, cbTransferHeuristics / 2);546 cbTransferHeuristics = PDMAudioPropsFloorBytesToFrame(&pStreamR3->State.Mapping.PCMProps, cbTransferHeuristics / 2); 547 547 548 548 /* Set the transfer size per timer callout. (No chunking, so same.) */ 549 549 pStreamShared->State.cbTransferSize = cbTransferHeuristics; 550 550 pStreamShared->State.cbTransferChunk = cbTransferHeuristics; 551 ASSERT_GUEST_LOGREL_MSG( DrvAudioHlpIsBytesAligned(&pStreamR3->State.Mapping.PCMProps, cbTransferHeuristics),551 ASSERT_GUEST_LOGREL_MSG(PDMAudioPropsIsSizeAligned(&pStreamR3->State.Mapping.PCMProps, cbTransferHeuristics), 552 552 ("We arrived at a misaligned transfer size for stream #%RU8: %#x (%u)\n", 553 553 uSD, cbTransferHeuristics, cbTransferHeuristics)); … … 642 642 uSD, pStreamShared->State.uTimerIoHz, (uint64_t)cTicksPerHz, pStreamR3->State.Mapping.PCMProps.uHz, 643 643 pStreamShared->State.cTicksPerByte, pStreamShared->State.cTransferTicks, 644 pStreamShared->State.cbTransferChunk, DrvAudioHlpBytesToMilli(&pStreamR3->State.Mapping.PCMProps, pStreamShared->State.cbTransferChunk),645 pStreamShared->State.cbTransferSize, DrvAudioHlpBytesToMilli(&pStreamR3->State.Mapping.PCMProps, pStreamShared->State.cbTransferSize)));644 pStreamShared->State.cbTransferChunk, PDMAudioPropsBytesToMilli(&pStreamR3->State.Mapping.PCMProps, pStreamShared->State.cbTransferChunk), 645 pStreamShared->State.cbTransferSize, PDMAudioPropsBytesToMilli(&pStreamR3->State.Mapping.PCMProps, pStreamShared->State.cbTransferSize))); 646 646 } 647 647 } … … 698 698 * channels we don't support / need to save space. 699 699 */ 700 uint32_t cbCircBuf = DrvAudioHlpMilliToBytes(&pCfg->Props,700 uint32_t cbCircBuf = PDMAudioPropsMilliToBytes(&pCfg->Props, 701 701 RT_MS_1SEC * 6 / RT_MIN(uTransferHz, pStreamShared->State.uTimerIoHz)); 702 702 LogRel2(("HDA: Stream #%RU8 default ring buffer size is %RU32 bytes / %RU64 ms\n", 703 uSD, cbCircBuf, DrvAudioHlpBytesToMilli(&pCfg->Props, cbCircBuf)));703 uSD, cbCircBuf, PDMAudioPropsBytesToMilli(&pCfg->Props, cbCircBuf))); 704 704 705 705 uint32_t msCircBufCfg = hdaGetDirFromSD(uSD) == PDMAUDIODIR_IN ? pThis->cbCircBufInMs : pThis->cbCircBufOutMs; 706 706 if (msCircBufCfg) /* Anything set via CFGM? */ 707 707 { 708 cbCircBuf = DrvAudioHlpMilliToBytes(&pCfg->Props, msCircBufCfg);708 cbCircBuf = PDMAudioPropsMilliToBytes(&pCfg->Props, msCircBufCfg); 709 709 LogRel2(("HDA: Stream #%RU8 is using a custom ring buffer size of %RU32 bytes / %RU64 ms\n", 710 uSD, cbCircBuf, DrvAudioHlpBytesToMilli(&pCfg->Props, cbCircBuf)));710 uSD, cbCircBuf, PDMAudioPropsBytesToMilli(&pCfg->Props, cbCircBuf))); 711 711 } 712 712 … … 1874 1874 uint32_t cbToReadFromStream = RT_MIN(cbStreamReadable, cbSinkWritable); 1875 1875 /* Make sure that we always align the number of bytes when reading to the stream's PCM properties. */ 1876 cbToReadFromStream = DrvAudioHlpFloorBytesToFrame(&pStreamR3->State.Mapping.PCMProps, cbToReadFromStream);1876 cbToReadFromStream = PDMAudioPropsFloorBytesToFrame(&pStreamR3->State.Mapping.PCMProps, cbToReadFromStream); 1877 1877 1878 1878 Assert(tsNowNs >= pStreamShared->State.tsLastReadNs); -
trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
r88016 r88022 62 62 ); 63 63 64 RTTESTI_CHECK( DrvAudioHlpGetBitrate(&s_Cfg441StereoS16) == 44100*4*8);65 RTTESTI_CHECK( DrvAudioHlpGetBitrate(&s_Cfg441StereoU16) == 44100*4*8);66 RTTESTI_CHECK( DrvAudioHlpGetBitrate(&s_Cfg441StereoU32) == 44100*8*8);64 RTTESTI_CHECK(PDMAudioPropsGetBitrate(&s_Cfg441StereoS16) == 44100*4*8); 65 RTTESTI_CHECK(PDMAudioPropsGetBitrate(&s_Cfg441StereoU16) == 44100*4*8); 66 RTTESTI_CHECK(PDMAudioPropsGetBitrate(&s_Cfg441StereoU32) == 44100*8*8); 67 67 68 68 RTTESTI_CHECK(DrvAudioHlpPcmPropsAreValid(&s_Cfg441StereoS16)); … … 78 78 ("got %x, expected 4\n", PDMAUDIOPCMPROPS_F2B(&s_Cfg441StereoU32, 1))); 79 79 80 RTTESTI_CHECK_MSG( DrvAudioHlpBytesPerFrame(&s_Cfg441StereoS16) == 4,81 ("got %x, expected 4\n", DrvAudioHlpBytesPerFrame(&s_Cfg441StereoS16)));82 RTTESTI_CHECK_MSG( DrvAudioHlpBytesPerFrame(&s_Cfg441StereoU16) == 4,83 ("got %x, expected 4\n", DrvAudioHlpBytesPerFrame(&s_Cfg441StereoU16)));84 RTTESTI_CHECK_MSG( DrvAudioHlpBytesPerFrame(&s_Cfg441StereoU32) == 8,85 ("got %x, expected 4\n", DrvAudioHlpBytesPerFrame(&s_Cfg441StereoU32)));80 RTTESTI_CHECK_MSG(PDMAudioPropsBytesPerFrame(&s_Cfg441StereoS16) == 4, 81 ("got %x, expected 4\n", PDMAudioPropsBytesPerFrame(&s_Cfg441StereoS16))); 82 RTTESTI_CHECK_MSG(PDMAudioPropsBytesPerFrame(&s_Cfg441StereoU16) == 4, 83 ("got %x, expected 4\n", PDMAudioPropsBytesPerFrame(&s_Cfg441StereoU16))); 84 RTTESTI_CHECK_MSG(PDMAudioPropsBytesPerFrame(&s_Cfg441StereoU32) == 8, 85 ("got %x, expected 4\n", PDMAudioPropsBytesPerFrame(&s_Cfg441StereoU32))); 86 86 87 87 uint32_t u32; 88 88 for (uint32_t i = 0; i < 256; i += 8) 89 89 { 90 RTTESTI_CHECK( DrvAudioHlpIsBytesAligned(&s_Cfg441StereoU32, i) == true);90 RTTESTI_CHECK(PDMAudioPropsIsSizeAligned(&s_Cfg441StereoU32, i) == true); 91 91 for (uint32_t j = 1; j < 8; j++) 92 RTTESTI_CHECK( DrvAudioHlpIsBytesAligned(&s_Cfg441StereoU32, i + j) == false);92 RTTESTI_CHECK(PDMAudioPropsIsSizeAligned(&s_Cfg441StereoU32, i + j) == false); 93 93 for (uint32_t j = 0; j < 8; j++) 94 RTTESTI_CHECK( DrvAudioHlpFloorBytesToFrame(&s_Cfg441StereoU32, i + j) == i);94 RTTESTI_CHECK(PDMAudioPropsFloorBytesToFrame(&s_Cfg441StereoU32, i + j) == i); 95 95 } 96 96 for (uint32_t i = 0; i < 4096; i += 4) 97 97 { 98 RTTESTI_CHECK( DrvAudioHlpIsBytesAligned(&s_Cfg441StereoS16, i) == true);98 RTTESTI_CHECK(PDMAudioPropsIsSizeAligned(&s_Cfg441StereoS16, i) == true); 99 99 for (uint32_t j = 1; j < 4; j++) 100 RTTESTI_CHECK( DrvAudioHlpIsBytesAligned(&s_Cfg441StereoS16, i + j) == false);100 RTTESTI_CHECK(PDMAudioPropsIsSizeAligned(&s_Cfg441StereoS16, i + j) == false); 101 101 for (uint32_t j = 0; j < 4; j++) 102 RTTESTI_CHECK( DrvAudioHlpFloorBytesToFrame(&s_Cfg441StereoS16, i + j) == i);103 } 104 105 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpFramesToBytes(&s_Cfg441StereoS16, 44100)) == 44100 * 2 * 2,102 RTTESTI_CHECK(PDMAudioPropsFloorBytesToFrame(&s_Cfg441StereoS16, i + j) == i); 103 } 104 105 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(&s_Cfg441StereoS16, 44100)) == 44100 * 2 * 2, 106 106 ("cb=%RU32\n", u32)); 107 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpFramesToBytes(&s_Cfg441StereoS16, 2)) == 2 * 2 * 2,107 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(&s_Cfg441StereoS16, 2)) == 2 * 2 * 2, 108 108 ("cb=%RU32\n", u32)); 109 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpFramesToBytes(&s_Cfg441StereoS16, 1)) == 4,109 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(&s_Cfg441StereoS16, 1)) == 4, 110 110 ("cb=%RU32\n", u32)); 111 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpFramesToBytes(&s_Cfg441StereoU16, 1)) == 4,111 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(&s_Cfg441StereoU16, 1)) == 4, 112 112 ("cb=%RU32\n", u32)); 113 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpFramesToBytes(&s_Cfg441StereoU32, 1)) == 8,113 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(&s_Cfg441StereoU32, 1)) == 8, 114 114 ("cb=%RU32\n", u32)); 115 115 116 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpBytesToFrames(&s_Cfg441StereoS16, 4)) == 1, ("cb=%RU32\n", u32));117 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpBytesToFrames(&s_Cfg441StereoU16, 4)) == 1, ("cb=%RU32\n", u32));118 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpBytesToFrames(&s_Cfg441StereoU32, 8)) == 1, ("cb=%RU32\n", u32));116 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsBytesToFrames(&s_Cfg441StereoS16, 4)) == 1, ("cb=%RU32\n", u32)); 117 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsBytesToFrames(&s_Cfg441StereoU16, 4)) == 1, ("cb=%RU32\n", u32)); 118 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsBytesToFrames(&s_Cfg441StereoU32, 8)) == 1, ("cb=%RU32\n", u32)); 119 119 120 120 uint64_t u64; 121 RTTESTI_CHECK_MSG((u64 = DrvAudioHlpBytesToNano(&s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_NS_1SEC,121 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsBytesToNano(&s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_NS_1SEC, 122 122 ("ns=%RU64\n", u64)); 123 RTTESTI_CHECK_MSG((u64 = DrvAudioHlpBytesToMicro(&s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_US_1SEC,123 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsBytesToMicro(&s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_US_1SEC, 124 124 ("us=%RU64\n", u64)); 125 RTTESTI_CHECK_MSG((u64 = DrvAudioHlpBytesToMilli(&s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_MS_1SEC,125 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsBytesToMilli(&s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_MS_1SEC, 126 126 ("ms=%RU64\n", u64)); 127 127 128 RTTESTI_CHECK_MSG((u64 = DrvAudioHlpFramesToNano(&s_Cfg441StereoS16, 44100)) == RT_NS_1SEC, ("ns=%RU64\n", u64));129 RTTESTI_CHECK_MSG((u64 = DrvAudioHlpFramesToNano(&s_Cfg441StereoS16, 1)) == 22675, ("ns=%RU64\n", u64));130 RTTESTI_CHECK_MSG((u64 = DrvAudioHlpFramesToNano(&s_Cfg441StereoS16, 31)) == 702947, ("ns=%RU64\n", u64));131 RTTESTI_CHECK_MSG((u64 = DrvAudioHlpFramesToNano(&s_Cfg441StereoS16, 255)) == 5782312, ("ns=%RU64\n", u64));128 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToNano(&s_Cfg441StereoS16, 44100)) == RT_NS_1SEC, ("ns=%RU64\n", u64)); 129 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToNano(&s_Cfg441StereoS16, 1)) == 22675, ("ns=%RU64\n", u64)); 130 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToNano(&s_Cfg441StereoS16, 31)) == 702947, ("ns=%RU64\n", u64)); 131 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToNano(&s_Cfg441StereoS16, 255)) == 5782312, ("ns=%RU64\n", u64)); 132 132 //RTTESTI_CHECK_MSG((u64 = DrvAudioHlpFramesToMicro(&s_Cfg441StereoS16, 44100)) == RT_US_1SEC, 133 133 // ("us=%RU64\n", u64)); 134 RTTESTI_CHECK_MSG((u64 = DrvAudioHlpFramesToMilli(&s_Cfg441StereoS16, 44100)) == RT_MS_1SEC, ("ms=%RU64\n", u64));135 RTTESTI_CHECK_MSG((u64 = DrvAudioHlpFramesToMilli(&s_Cfg441StereoS16, 255)) == 5, ("ms=%RU64\n", u64));136 137 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpNanoToFrames(&s_Cfg441StereoS16, RT_NS_1SEC)) == 44100, ("cb=%RU32\n", u32));138 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpNanoToFrames(&s_Cfg441StereoS16, 215876)) == 10, ("cb=%RU32\n", u32));139 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpMilliToFrames(&s_Cfg441StereoS16, RT_MS_1SEC)) == 44100, ("cb=%RU32\n", u32));140 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpMilliToFrames(&s_Cfg441StereoU32, 6)) == 265, ("cb=%RU32\n", u32));141 142 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpNanoToBytes(&s_Cfg441StereoS16, RT_NS_1SEC)) == 44100*2*2, ("cb=%RU32\n", u32));143 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpNanoToBytes(&s_Cfg441StereoS16, 702947)) == 31*2*2, ("cb=%RU32\n", u32));144 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpMilliToBytes(&s_Cfg441StereoS16, RT_MS_1SEC)) == 44100*2*2, ("cb=%RU32\n", u32));145 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpMilliToBytes(&s_Cfg441StereoS16, 5)) == 884, ("cb=%RU32\n", u32));134 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToMilli(&s_Cfg441StereoS16, 44100)) == RT_MS_1SEC, ("ms=%RU64\n", u64)); 135 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToMilli(&s_Cfg441StereoS16, 255)) == 5, ("ms=%RU64\n", u64)); 136 137 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsNanoToFrames(&s_Cfg441StereoS16, RT_NS_1SEC)) == 44100, ("cb=%RU32\n", u32)); 138 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsNanoToFrames(&s_Cfg441StereoS16, 215876)) == 10, ("cb=%RU32\n", u32)); 139 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsMilliToFrames(&s_Cfg441StereoS16, RT_MS_1SEC)) == 44100, ("cb=%RU32\n", u32)); 140 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsMilliToFrames(&s_Cfg441StereoU32, 6)) == 265, ("cb=%RU32\n", u32)); 141 142 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsNanoToBytes(&s_Cfg441StereoS16, RT_NS_1SEC)) == 44100*2*2, ("cb=%RU32\n", u32)); 143 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsNanoToBytes(&s_Cfg441StereoS16, 702947)) == 31*2*2, ("cb=%RU32\n", u32)); 144 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsMilliToBytes(&s_Cfg441StereoS16, RT_MS_1SEC)) == 44100*2*2, ("cb=%RU32\n", u32)); 145 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsMilliToBytes(&s_Cfg441StereoS16, 5)) == 884, ("cb=%RU32\n", u32)); 146 146 147 147 /* DrvAudioHlpClearBuf: */ … … 151 151 152 152 memset(pbPage, 0x42, PAGE_SIZE); 153 DrvAudioHlpClearBuf(&s_Cfg441StereoS16, pbPage, PAGE_SIZE, PAGE_SIZE / 4);153 PDMAudioPropsClearBuffer(&s_Cfg441StereoS16, pbPage, PAGE_SIZE, PAGE_SIZE / 4); 154 154 RTTESTI_CHECK(ASMMemIsZero(pbPage, PAGE_SIZE)); 155 155 156 156 memset(pbPage, 0x42, PAGE_SIZE); 157 DrvAudioHlpClearBuf(&s_Cfg441StereoU16, pbPage, PAGE_SIZE, PAGE_SIZE / 4);157 PDMAudioPropsClearBuffer(&s_Cfg441StereoU16, pbPage, PAGE_SIZE, PAGE_SIZE / 4); 158 158 for (uint32_t off = 0; off < PAGE_SIZE; off += 2) 159 159 RTTESTI_CHECK_MSG(pbPage[off] == 0x80 && pbPage[off + 1] == 0, ("off=%#x: %#x %x\n", off, pbPage[off], pbPage[off + 1])); 160 160 161 161 memset(pbPage, 0x42, PAGE_SIZE); 162 DrvAudioHlpClearBuf(&s_Cfg441StereoU32, pbPage, PAGE_SIZE, PAGE_SIZE / 8);162 PDMAudioPropsClearBuffer(&s_Cfg441StereoU32, pbPage, PAGE_SIZE, PAGE_SIZE / 8); 163 163 for (uint32_t off = 0; off < PAGE_SIZE; off += 4) 164 164 RTTESTI_CHECK(pbPage[off] == 0x80 && pbPage[off + 1] == 0 && pbPage[off + 2] == 0 && pbPage[off + 3] == 0); … … 167 167 RTTestDisableAssertions(hTest); 168 168 memset(pbPage, 0x42, PAGE_SIZE); 169 DrvAudioHlpClearBuf(&s_Cfg441StereoS16, pbPage, PAGE_SIZE, PAGE_SIZE); /* should adjust down the frame count. */169 PDMAudioPropsClearBuffer(&s_Cfg441StereoS16, pbPage, PAGE_SIZE, PAGE_SIZE); /* should adjust down the frame count. */ 170 170 RTTESTI_CHECK(ASMMemIsZero(pbPage, PAGE_SIZE)); 171 171 172 172 memset(pbPage, 0x42, PAGE_SIZE); 173 DrvAudioHlpClearBuf(&s_Cfg441StereoU16, pbPage, PAGE_SIZE, PAGE_SIZE); /* should adjust down the frame count. */173 PDMAudioPropsClearBuffer(&s_Cfg441StereoU16, pbPage, PAGE_SIZE, PAGE_SIZE); /* should adjust down the frame count. */ 174 174 for (uint32_t off = 0; off < PAGE_SIZE; off += 2) 175 175 RTTESTI_CHECK_MSG(pbPage[off] == 0x80 && pbPage[off + 1] == 0, ("off=%#x: %#x %x\n", off, pbPage[off], pbPage[off + 1])); 176 176 177 177 memset(pbPage, 0x42, PAGE_SIZE); 178 DrvAudioHlpClearBuf(&s_Cfg441StereoU32, pbPage, PAGE_SIZE, PAGE_SIZE); /* should adjust down the frame count. */178 PDMAudioPropsClearBuffer(&s_Cfg441StereoU32, pbPage, PAGE_SIZE, PAGE_SIZE); /* should adjust down the frame count. */ 179 179 for (uint32_t off = 0; off < PAGE_SIZE; off += 4) 180 180 RTTESTI_CHECK(pbPage[off] == 0x80 && pbPage[off + 1] == 0 && pbPage[off + 2] == 0 && pbPage[off + 3] == 0); -
trunk/src/VBox/Main/src-client/DrvAudioRec.cpp
r88016 r88022 437 437 pCodec->Opus.msFrame = AVREC_OPUS_FRAME_MS_DEFAULT; /* 20ms by default; to prevent division by zero. */ 438 438 pCodec->Opus.csFrame = pSink->Codec.Parms.PCMProps.uHz / (1000 /* s in ms */ / pSink->Codec.Opus.msFrame); 439 pCodec->Opus.cbFrame = DrvAudioHlpFramesToBytes(&pSink->Codec.Parms.PCMProps, pCodec->Opus.csFrame);439 pCodec->Opus.cbFrame = PDMAudioPropsFramesToBytes(&pSink->Codec.Parms.PCMProps, pCodec->Opus.csFrame); 440 440 441 441 #ifdef VBOX_WITH_STATISTICS … … 553 553 554 554 /* Every Opus frame marks a period for now. Optimize this later. */ 555 pCfgAcq->Backend.cFramesPeriod = DrvAudioHlpMilliToFrames(&pCfgAcq->Props, pSink->Codec.Opus.msFrame);556 pCfgAcq->Backend.cFramesBufferSize = DrvAudioHlpMilliToFrames(&pCfgAcq->Props, 100 /*ms*/); /** @todo Make this configurable. */555 pCfgAcq->Backend.cFramesPeriod = PDMAudioPropsMilliToFrames(&pCfgAcq->Props, pSink->Codec.Opus.msFrame); 556 pCfgAcq->Backend.cFramesBufferSize = PDMAudioPropsMilliToFrames(&pCfgAcq->Props, 100 /*ms*/); /** @todo Make this configurable. */ 557 557 pCfgAcq->Backend.cFramesPreBuffering = pCfgAcq->Backend.cFramesPeriod * 2; 558 558 } -
trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp
r88002 r88022 93 93 94 94 /* According to the VRDP docs, the VRDP server stores audio in 200ms chunks. */ 95 const uint32_t cFramesVrdpServer = DrvAudioHlpMilliToFrames(&pCfgAcq->Props, 200 /*ms*/);96 97 int rc = RTCircBufCreate(&pStreamVRDE->In.pCircBuf, DrvAudioHlpFramesToBytes(&pCfgAcq->Props, cFramesVrdpServer));95 const uint32_t cFramesVrdpServer = PDMAudioPropsMilliToFrames(&pCfgAcq->Props, 200 /*ms*/); 96 97 int rc = RTCircBufCreate(&pStreamVRDE->In.pCircBuf, PDMAudioPropsFramesToBytes(&pCfgAcq->Props, cFramesVrdpServer)); 98 98 if (RT_SUCCESS(rc)) 99 99 { … … 137 137 138 138 /* According to the VRDP docs, the VRDP server stores audio in 200ms chunks. */ 139 pCfgAcq->Backend.cFramesPeriod = DrvAudioHlpMilliToFrames(&pCfgAcq->Props, 20 /*ms*/);140 pCfgAcq->Backend.cFramesBufferSize = DrvAudioHlpMilliToFrames(&pCfgAcq->Props, 100 /*ms*/);139 pCfgAcq->Backend.cFramesPeriod = PDMAudioPropsMilliToFrames(&pCfgAcq->Props, 20 /*ms*/); 140 pCfgAcq->Backend.cFramesBufferSize = PDMAudioPropsMilliToFrames(&pCfgAcq->Props, 100 /*ms*/); 141 141 pCfgAcq->Backend.cFramesPreBuffering = pCfgAcq->Backend.cFramesPeriod * 2; 142 142 } … … 174 174 { 175 175 rc = pDrv->pConsoleVRDPServer->SendAudioInputBegin(NULL, pStreamVRDE, 176 DrvAudioHlpMilliToFrames(&pStreamVRDE->pCfg->Props, 200 /*ms*/),176 PDMAudioPropsMilliToFrames(&pStreamVRDE->pCfg->Props, 200 /*ms*/), 177 177 pStreamVRDE->pCfg->Props.uHz, pStreamVRDE->pCfg->Props.cChannels, 178 178 pStreamVRDE->pCfg->Props.cbSample * 8 /* Bit */);
Note:
See TracChangeset
for help on using the changeset viewer.