Changeset 89570 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Jun 8, 2021 2:35:13 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145005
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r89569 r89570 238 238 uint32_t cbBackendReadableBefore; 239 239 uint32_t cbBackendReadableAfter; 240 241 STAMCOUNTER TotalFramesCaptured; 242 STAMCOUNTER AvgFramesCaptured; 243 STAMCOUNTER TotalTimesCaptured; 244 STAMCOUNTER TotalFramesRead; 245 STAMCOUNTER AvgFramesRead; 246 STAMCOUNTER TotalTimesRead; 240 #ifdef VBOX_WITH_STATISTICS 241 STAMPROFILE ProfCapture; 242 STAMPROFILE ProfGetReadable; 243 STAMPROFILE ProfGetReadableBytes; 244 #endif 247 245 } Stats; 248 246 } In; … … 253 251 struct 254 252 { 255 struct256 {257 /** File for writing stream playback. */258 PAUDIOHLPFILE pFilePlay;259 } Dbg;260 struct261 {262 uint32_t cbBackendWritableBefore;263 uint32_t cbBackendWritableAfter;264 } Stats;265 266 253 /** Space for pre-buffering. */ 267 254 uint8_t *pbPreBuf; … … 274 261 /** The play state. */ 275 262 DRVAUDIOPLAYSTATE enmPlayState; 263 264 struct 265 { 266 /** File for writing stream playback. */ 267 PAUDIOHLPFILE pFilePlay; 268 } Dbg; 269 struct 270 { 271 uint32_t cbBackendWritableBefore; 272 uint32_t cbBackendWritableAfter; 273 #ifdef VBOX_WITH_STATISTICS 274 STAMPROFILE ProfPlay; 275 STAMPROFILE ProfGetWritable; 276 STAMPROFILE ProfGetWritableBytes; 277 #endif 278 } Stats; 276 279 } Out; 277 280 } RT_UNION_NM(u); 281 #ifdef VBOX_WITH_STATISTICS 282 STAMPROFILE StatProfGetState; 283 STAMPROFILE StatXfer; 284 #endif 278 285 } DRVAUDIOSTREAM; 279 286 /** Pointer to an extended stream structure. */ … … 389 396 RTREQPOOL hReqPool; 390 397 391 #ifdef VBOX_WITH_STATISTICS392 /** Statistics. */393 struct394 {395 STAMCOUNTER TotalStreamsActive;396 STAMCOUNTER TotalStreamsCreated;397 STAMCOUNTER TotalFramesRead;398 STAMCOUNTER TotalFramesIn;399 STAMCOUNTER TotalBytesRead;400 } Stats;401 #endif402 403 398 #ifdef VBOX_WITH_AUDIO_ENUM 404 399 /** Handle to the timer for delayed re-enumeration of backend devices. */ … … 412 407 /** Output audio configuration values (static). */ 413 408 DRVAUDIOCFG CfgOut; 409 410 STAMCOUNTER StatTotalStreamsCreated; 414 411 } DRVAUDIO; 415 412 /** Pointer to the instance data of an audio driver. */ … … 1637 1634 /** @todo expose config and more. */ 1638 1635 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Core.Cfg.Backend.cFramesBufferSize, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 1639 "Host side: The size of the backend buffer (in frames)", "%s/0-HostBackendBufSize", pStreamEx->Core.Cfg.szName); 1636 "The size of the backend buffer (in frames)", "%s/0-HostBackendBufSize", pStreamEx->Core.Cfg.szName); 1637 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Core.Cfg.Backend.cFramesPeriod, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 1638 "The size of the backend period (in frames)", "%s/0-HostBackendPeriodSize", pStreamEx->Core.Cfg.szName); 1639 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Core.Cfg.Backend.cFramesPreBuffering, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 1640 "Pre-buffer size (in frames)", "%s/0-HostBackendPreBufferSize", pStreamEx->Core.Cfg.szName); 1641 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Core.Cfg.Device.cMsSchedulingHint, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 1642 "Device DMA scheduling hint (in milliseconds)", "%s/0-DeviceSchedulingHint", pStreamEx->Core.Cfg.szName); 1643 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Core.Cfg.Props.uHz, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_HZ, 1644 "Backend stream frequency", "%s/Hz", pStreamEx->Core.Cfg.szName); 1645 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Core.Cfg.Props.cbFrame, STAMTYPE_U8, STAMVISIBILITY_USED, STAMUNIT_BYTES, 1646 "Backend frame size", "%s/Framesize", pStreamEx->Core.Cfg.szName); 1640 1647 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_IN) 1641 1648 { 1642 /** @todo later? */ 1649 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->In.Stats.cbBackendReadableBefore, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 1650 "Free space in backend buffer before play", "%s/0-HostBackendBufReadableBefore", pStreamEx->Core.Cfg.szName); 1651 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->In.Stats.cbBackendReadableAfter, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 1652 "Free space in backend buffer after play", "%s/0-HostBackendBufReadableAfter", pStreamEx->Core.Cfg.szName); 1653 #ifdef VBOX_WITH_STATISTICS 1654 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->In.Stats.ProfCapture, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES, 1655 "Profiling time spent in StreamCapture", "%s/ProfStreamCapture", pStreamEx->Core.Cfg.szName); 1656 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->In.Stats.ProfGetReadable, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES, 1657 "Profiling time spent in StreamGetReadable", "%s/ProfStreamGetReadable", pStreamEx->Core.Cfg.szName); 1658 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->In.Stats.ProfGetReadableBytes, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_BYTES, 1659 "Readable byte stats", "%s/ProfStreamGetReadableBytes", pStreamEx->Core.Cfg.szName); 1660 #endif 1643 1661 } 1644 1662 else 1645 1663 { 1646 1664 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Out.Stats.cbBackendWritableBefore, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 1647 " Host side: Free space in backend buffer before play", "%s/0-HostBackendBufFreeBefore", pStreamEx->Core.Cfg.szName);1665 "Free space in backend buffer before play", "%s/0-HostBackendBufWritableBefore", pStreamEx->Core.Cfg.szName); 1648 1666 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Out.Stats.cbBackendWritableAfter, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 1649 "Host side: Free space in backend buffer after play", "%s/0-HostBackendBufFreeAfter", pStreamEx->Core.Cfg.szName); 1650 } 1651 1667 "Free space in backend buffer after play", "%s/0-HostBackendBufWritableAfter", pStreamEx->Core.Cfg.szName); 1652 1668 #ifdef VBOX_WITH_STATISTICS 1653 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_IN) 1654 { 1655 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->In.Stats.TotalFramesCaptured, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_NONE, 1656 "Total frames played.", "%s/TotalFramesCaptured", pStreamEx->Core.Cfg.szName); 1657 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->In.Stats.TotalTimesCaptured, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_NONE, 1658 "Total number of playbacks.", "%s/TotalTimesCaptured", pStreamEx->Core.Cfg.szName); 1659 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->In.Stats.TotalTimesRead, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_NONE, 1660 "Total number of reads.", "%s/TotalTimesRead", pStreamEx->Core.Cfg.szName); 1661 } 1662 else 1663 { 1664 Assert(pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT); 1665 } 1666 #endif /* VBOX_WITH_STATISTICS */ 1669 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Out.Stats.ProfPlay, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES, 1670 "Profiling time spent in StreamPlay", "%s/ProfStreamPlay", pStreamEx->Core.Cfg.szName); 1671 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Out.Stats.ProfGetWritable, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES, 1672 "Profiling time spent in StreamGetWritable", "%s/ProfStreamGetWritable", pStreamEx->Core.Cfg.szName); 1673 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Out.Stats.ProfGetWritableBytes, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_BYTES, 1674 "Writeable byte stats", "%s/ProfStreamGetWritableBytes", pStreamEx->Core.Cfg.szName); 1675 #endif 1676 } 1677 #ifdef VBOX_WITH_STATISTICS 1678 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->StatProfGetState, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES, 1679 "Profiling time spent in StreamGetState", "%s/ProfStreamGetState", pStreamEx->Core.Cfg.szName); 1680 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->StatXfer, STAMTYPE_PROFILE, STAMVISIBILITY_USED, STAMUNIT_BYTES, 1681 "Byte transfer stats (excluding pre-buffering)", "%s/Transfers", pStreamEx->Core.Cfg.szName); 1682 #endif 1683 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->offInternal, STAMTYPE_U64, STAMVISIBILITY_USED, STAMUNIT_NONE, 1684 "Internal stream offset", "%s/offInternal", pStreamEx->Core.Cfg.szName); 1667 1685 1668 1686 LogFlowFunc(("[%s] Returning %Rrc\n", pStreamEx->Core.Cfg.szName, rc)); … … 1789 1807 RTListAppend(&pThis->LstStreams, &pStreamEx->ListEntry); 1790 1808 pThis->cStreams++; 1791 STAM_ COUNTER_INC(&pThis->Stats.TotalStreamsCreated);1809 STAM_REL_COUNTER_INC(&pThis->StatTotalStreamsCreated); 1792 1810 1793 1811 RTCritSectRwLeaveExcl(&pThis->CritSectGlobals); … … 2556 2574 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_IN) 2557 2575 { 2558 STAM_COUNTER_RESET(&pStreamEx->In.Stats.TotalFramesCaptured);2559 STAM_COUNTER_RESET(&pStreamEx->In.Stats.TotalTimesCaptured);2560 STAM_COUNTER_RESET(&pStreamEx->In.Stats.TotalTimesRead);2561 2576 } 2562 2577 else if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT) … … 2937 2952 } 2938 2953 2954 STAM_PROFILE_ADD_PERIOD(&pStreamEx->StatXfer, cbWritten); 2939 2955 *pcbWritten = cbWritten; 2940 2956 pStreamEx->Out.Stats.cbBackendWritableAfter = cbWritable; … … 3201 3217 AssertReturn(pStreamEx->Core.uMagic == PDMAUDIOSTREAM_MAGIC, PDMAUDIOSTREAMSTATE_INVALID); 3202 3218 AssertReturn(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC, PDMAUDIOSTREAMSTATE_INVALID); 3219 STAM_PROFILE_START(&pStreamEx->StatProfGetState, a); 3203 3220 3204 3221 /* … … 3240 3257 enmState = PDMAUDIOSTREAMSTATE_NEED_REINIT; 3241 3258 3259 STAM_PROFILE_STOP(&pStreamEx->StatProfGetState, a); 3242 3260 #ifdef LOG_ENABLED 3243 3261 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; … … 3261 3279 AssertReturn(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC, 0); 3262 3280 AssertMsgReturn(pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT, ("Can't write to a non-output stream\n"), 0); 3281 STAM_PROFILE_START(&pStreamEx->Out.Stats.ProfGetWritable, a); 3263 3282 3264 3283 int rc = RTCritSectEnter(&pStreamEx->Core.CritSect); … … 3346 3365 3347 3366 RTCritSectRwLeaveShared(&pThis->CritSectHotPlug); 3367 STAM_PROFILE_ADD_PERIOD(&pStreamEx->Out.Stats.ProfGetWritableBytes, cbWritable); 3368 STAM_PROFILE_STOP(&pStreamEx->Out.Stats.ProfGetWritable, a); 3348 3369 RTCritSectLeave(&pStreamEx->Core.CritSect); 3349 3370 Log3Func(("[%s] cbWritable=%#RX32 (%RU64ms) enmPlayMode=%s enmBackendState=%s\n", … … 3385 3406 AssertMsg(PDMAudioPropsIsSizeAligned(&pStreamEx->Core.Cfg.Props, cbBuf), 3386 3407 ("Stream '%s' got a non-frame-aligned write (%#RX32 bytes)\n", pStreamEx->Core.Cfg.szName, cbBuf)); 3408 STAM_PROFILE_START(&pStreamEx->Out.Stats.ProfPlay, a); 3387 3409 3388 3410 int rc = RTCritSectEnter(&pStreamEx->Core.CritSect); … … 3486 3508 rc = VERR_AUDIO_STREAM_NOT_READY; 3487 3509 3510 STAM_PROFILE_STOP(&pStreamEx->Out.Stats.ProfPlay, a); 3488 3511 RTCritSectLeave(&pStreamEx->Core.CritSect); 3489 3512 return rc; … … 3503 3526 AssertReturn(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC, 0); 3504 3527 AssertMsg(pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_IN, ("Can't read from a non-input stream\n")); 3505 3528 STAM_PROFILE_START(&pStreamEx->In.Stats.ProfGetReadable, a); 3506 3529 3507 3530 int rc = RTCritSectEnter(&pStreamEx->Core.CritSect); … … 3560 3583 3561 3584 RTCritSectRwLeaveShared(&pThis->CritSectHotPlug); 3585 STAM_PROFILE_ADD_PERIOD(&pStreamEx->In.Stats.ProfGetReadableBytes, cbReadable); 3586 STAM_PROFILE_STOP(&pStreamEx->In.Stats.ProfGetReadable, a); 3562 3587 RTCritSectLeave(&pStreamEx->Core.CritSect); 3563 3588 Log3Func(("[%s] cbReadable=%#RX32 (%RU64ms) enmCaptureMode=%s enmBackendState=%s\n", … … 3647 3672 } 3648 3673 3674 STAM_PROFILE_ADD_PERIOD(&pStreamEx->StatXfer, cbRead); 3649 3675 *pcbRead = cbRead; 3650 3676 pStreamEx->In.Stats.cbBackendReadableAfter = cbReadable; … … 3688 3714 AssertMsg(PDMAudioPropsIsSizeAligned(&pStreamEx->Core.Cfg.Props, cbBuf), 3689 3715 ("Stream '%s' got a non-frame-aligned write (%#RX32 bytes)\n", pStreamEx->Core.Cfg.szName, cbBuf)); 3716 STAM_PROFILE_START(&pStreamEx->In.Stats.ProfCapture, a); 3690 3717 3691 3718 int rc = RTCritSectEnter(&pStreamEx->Core.CritSect); … … 3769 3796 rc = VERR_AUDIO_STREAM_NOT_READY; 3770 3797 3798 STAM_PROFILE_STOP(&pStreamEx->In.Stats.ProfCapture, a); 3771 3799 RTCritSectLeave(&pStreamEx->Core.CritSect); 3772 3800 return rc; … … 4590 4618 RTCritSectRwDelete(&pThis->CritSectHotPlug); 4591 4619 4592 #ifdef VBOX_WITH_STATISTICS 4593 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalStreamsActive); 4594 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalStreamsCreated); 4595 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalFramesRead); 4596 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalFramesIn); 4597 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalBytesRead); 4598 #endif 4620 PDMDrvHlpSTAMDeregisterByPrefix(pDrvIns, ""); 4599 4621 4600 4622 LogFlowFuncLeave(); … … 4812 4834 pThis->IHostAudioPort.pfnNotifyDevicesChanged = drvAudioHostPort_NotifyDevicesChanged; 4813 4835 4814 /*4815 * Statistics.4816 */4817 #ifdef VBOX_WITH_STATISTICS4818 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalStreamsActive, "TotalStreamsActive",4819 STAMUNIT_COUNT, "Total active audio streams.");4820 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalStreamsCreated, "TotalStreamsCreated",4821 STAMUNIT_COUNT, "Total created audio streams.");4822 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesRead, "TotalFramesRead",4823 STAMUNIT_COUNT, "Total frames read by device emulation.");4824 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesIn, "TotalFramesIn",4825 STAMUNIT_COUNT, "Total frames captured by backend.");4826 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalBytesRead, "TotalBytesRead",4827 STAMUNIT_BYTES, "Total bytes read.");4828 #endif4829 4830 4836 #ifdef VBOX_WITH_AUDIO_ENUM 4831 4837 /* … … 4844 4850 if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 4845 4851 rc = VINF_SUCCESS; 4852 4853 /* 4854 * Statistics (afte driver attach for name). 4855 */ 4856 PDMDrvHlpSTAMRegister(pDrvIns, &pThis->BackendCfg.fFlags, STAMTYPE_U32, "BackendFlags", STAMUNIT_COUNT, pThis->BackendCfg.szName); /* Mainly for the name. */ 4857 PDMDrvHlpSTAMRegister(pDrvIns, &pThis->cStreams, STAMTYPE_U32, "Streams", STAMUNIT_COUNT, "Current streams count."); 4858 PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->StatTotalStreamsCreated, "TotalStreamsCreated", "Number of stream ever created."); 4859 PDMDrvHlpSTAMRegister(pDrvIns, &pThis->In.fEnabled, STAMTYPE_BOOL, "InputEnabled", STAMUNIT_NONE, "Whether input is enabled or not."); 4860 PDMDrvHlpSTAMRegister(pDrvIns, &pThis->In.cStreamsFree, STAMTYPE_U32, "InputStreamFree", STAMUNIT_COUNT, "Number of free input stream slots"); 4861 PDMDrvHlpSTAMRegister(pDrvIns, &pThis->Out.fEnabled, STAMTYPE_BOOL, "OutputEnabled", STAMUNIT_NONE, "Whether output is enabled or not."); 4862 PDMDrvHlpSTAMRegister(pDrvIns, &pThis->Out.cStreamsFree, STAMTYPE_U32, "OutputStreamFree", STAMUNIT_COUNT, "Number of free output stream slots"); 4846 4863 4847 4864 LogFlowFuncLeaveRC(rc);
Note:
See TracChangeset
for help on using the changeset viewer.