Changeset 87583 in vbox
- Timestamp:
- Feb 3, 2021 4:20:48 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/HDAStream.cpp
r87573 r87583 30 30 #include <VBox/vmm/pdmaudioifs.h> 31 31 32 #include <math.h> /* Needed for round (). */32 #include <math.h> /* Needed for roundl(). */ 33 33 34 34 #include "DrvAudio.h" … … 549 549 550 550 /* Calculate the timer ticks per byte for this stream. */ 551 pStreamShared->State.cTicksPerByte = round (cTicksPerByte); /** @todo r=andy Do we have rounding in IPRT? */551 pStreamShared->State.cTicksPerByte = roundl(cTicksPerByte); /** @todo r=andy Do we have rounding in IPRT? */ 552 552 Assert(pStreamShared->State.cTicksPerByte); 553 553 … … 555 555 556 556 /* Calculate timer ticks per transfer. */ 557 pStreamShared->State.cTransferTicks = round (cTransferTicks);557 pStreamShared->State.cTransferTicks = roundl(cTransferTicks); 558 558 Assert(pStreamShared->State.cTransferTicks); 559 559 … … 743 743 #endif 744 744 745 /* 745 /** 746 746 * Updates an HDA stream's current read or write buffer position (depending on the stream type) by 747 747 * setting its associated LPIB register and DMA position buffer (if enabled) to an absolute value. … … 772 772 } 773 773 774 /* 774 /** 775 775 * Updates an HDA stream's current read or write buffer position (depending on the stream type) by 776 776 * adding a value to its associated LPIB register and DMA position buffer (if enabled). … … 985 985 if (pcbRead) 986 986 *pcbRead = cbReadTotal; 987 988 return rc;989 }990 991 /*992 * Reads DMA data from a given HDA output stream.993 *994 * @return IPRT status code.995 * @param pDevIns The device instance.996 * @param pThis The shared HDA device state (for stats).997 * @param pStreamShared HDA output stream to read DMA data from - shared bits.998 * @param pStreamR3 HDA output stream to read DMA data from - shared ring-3.999 * @param pvBuf Where to store the read data.1000 * @param cbBuf How much to read in bytes.1001 * @param pcbRead Returns read bytes from DMA. Optional.1002 */1003 int hdaR3DMARead2(PPDMDEVINS pDevIns, PHDASTATE pThis, PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3,1004 void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead)1005 {1006 RT_NOREF(pThis);1007 PHDABDLE pBDLE = &pStreamShared->State.BDLE;1008 1009 int rc = VINF_SUCCESS;1010 1011 uint32_t cbReadTotal = 0;1012 uint32_t cbLeft = RT_MIN(cbBuf, pBDLE->Desc.u32BufSize - pBDLE->State.u32BufOff);1013 1014 # ifdef HDA_DEBUG_SILENCE1015 uint64_t csSilence = 0;1016 1017 pStreamR3->Dbg.cSilenceThreshold = 100;1018 pStreamR3->Dbg.cbSilenceReadMin = _1M;1019 # endif1020 1021 RTGCPHYS GCPhysChunk = pBDLE->Desc.u64BufAddr + pBDLE->State.u32BufOff;1022 1023 while (cbLeft)1024 {1025 uint32_t cbChunk = RT_MIN(cbLeft, pStreamShared->u8FIFOS);1026 1027 rc = PDMDevHlpPhysRead(pDevIns, GCPhysChunk, (uint8_t *)pvBuf + cbReadTotal, cbChunk);1028 AssertRCBreak(rc);1029 1030 # ifdef HDA_DEBUG_SILENCE1031 uint16_t *pu16Buf = (uint16_t *)pvBuf;1032 for (size_t i = 0; i < cbChunk / sizeof(uint16_t); i++)1033 {1034 if (*pu16Buf == 0)1035 csSilence++;1036 else1037 break;1038 pu16Buf++;1039 }1040 # endif1041 1042 /*1043 * Update the stream's current position.1044 * Do this as accurate and close to the actual data transfer as possible.1045 * All guetsts rely on this, depending on the mechanism they use (LPIB register or DMA counters).1046 */1047 hdaR3StreamSetPositionAdd(pStreamShared, pDevIns, pThis, /* cbChunk */ 0);1048 1049 if (RT_LIKELY(!pStreamR3->Dbg.Runtime.fEnabled))1050 { /* likely */ }1051 else1052 DrvAudioHlpFileWrite(pStreamR3->Dbg.Runtime.pFileDMARaw, (uint8_t *)pvBuf + cbReadTotal, cbChunk, 0 /* fFlags */);1053 1054 STAM_COUNTER_ADD(&pThis->StatBytesRead, cbChunk);1055 1056 /* advance */1057 Assert(cbLeft >= cbChunk);1058 GCPhysChunk = (GCPhysChunk + cbChunk) % pBDLE->Desc.u32BufSize;1059 cbReadTotal += cbChunk;1060 cbLeft -= cbChunk;1061 }1062 1063 # ifdef HDA_DEBUG_SILENCE1064 if (csSilence)1065 pStreamR3->Dbg.csSilence += csSilence;1066 1067 if ( csSilence == 01068 && pStreamR3->Dbg.csSilence > pStreamR3->Dbg.cSilenceThreshold1069 && pStreamR3->Dbg.cbReadTotal >= pStreamR3->Dbg.cbSilenceReadMin)1070 {1071 LogFunc(("Silent block detected: %RU64 audio samples\n", pStreamR3->Dbg.csSilence));1072 pStreamR3->Dbg.csSilence = 0;1073 }1074 # endif1075 1076 if (RT_SUCCESS(rc))1077 {1078 if (pcbRead)1079 *pcbRead = cbReadTotal;1080 }1081 987 1082 988 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.