Changeset 88006 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Mar 8, 2021 12:08:34 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143129
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r88005 r88006 2984 2984 /* Make sure to align the readable size to the guest's frame size. */ 2985 2985 if (cbReadable) 2986 cbReadable = DrvAudioHlp BytesAlign(cbReadable, &pStream->Guest.Cfg.Props);2986 cbReadable = DrvAudioHlpFloorBytesToFrame(&pStream->Guest.Cfg.Props, cbReadable); 2987 2987 } 2988 2988 … … 3021 3021 3022 3022 /* Make sure to align the writable size to the host's frame size. */ 3023 cbWritable = DrvAudioHlp BytesAlign(cbWritable, &pStream->Host.Cfg.Props);3023 cbWritable = DrvAudioHlpFloorBytesToFrame(&pStream->Host.Cfg.Props, cbWritable); 3024 3024 } 3025 3025 -
trunk/src/VBox/Devices/Audio/DrvAudio.h
r88004 r88006 198 198 uint32_t DrvAudioHlpCalcBitrate(uint8_t cBits, uint32_t uHz, uint8_t cChannels); 199 199 uint32_t DrvAudioHlpGetBitrate(PCPDMAUDIOPCMPROPS pProps); 200 uint32_t DrvAudioHlp BytesAlign(uint32_t cbSize, PCPDMAUDIOPCMPROPS pProps);200 uint32_t DrvAudioHlpFloorBytesToFrame(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 201 201 bool DrvAudioHlpIsBytesAligned(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 202 202 uint32_t DrvAudioHlpBytesToFrames(uint32_t cbBytes, PCPDMAUDIOPCMPROPS pProps); -
trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
r88004 r88006 1159 1159 1160 1160 /** 1161 * Aligns the given byte amount to the given PCM properties and returns the aligned 1162 * size. 1163 * 1164 * @return Aligned size (in bytes). 1165 * @param cbSize Size (in bytes) to align. 1166 * @param pProps PCM properties to align size to. 1167 */ 1168 uint32_t DrvAudioHlpBytesAlign(uint32_t cbSize, PCPDMAUDIOPCMPROPS pProps) 1161 * Rounds down the given byte amount to the nearest frame boundrary. 1162 * 1163 * @returns Rounded byte amount. 1164 * @param pProps PCM properties to use. 1165 * @param cb The size (in bytes) to round. 1166 */ 1167 uint32_t DrvAudioHlpFloorBytesToFrame(PCPDMAUDIOPCMPROPS pProps, uint32_t cb) 1169 1168 { 1170 1169 AssertPtrReturn(pProps, 0); 1171 1172 if (!cbSize) 1173 return 0; 1174 1175 return PDMAUDIOPCMPROPS_B2F(pProps, cbSize) * PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); 1170 return PDMAUDIOPCMPROPS_F2B(pProps, PDMAUDIOPCMPROPS_B2F(pProps, cb)); 1176 1171 } 1177 1172 -
trunk/src/VBox/Devices/Audio/HDAStream.cpp
r88005 r88006 544 544 halve the buffer till we get there. */ 545 545 while (cbTransferHeuristics > 1024 && cbTransferHeuristics > cbTransferPerSec / 4) 546 cbTransferHeuristics = DrvAudioHlp BytesAlign(cbTransferHeuristics / 2, &pStreamR3->State.Mapping.PCMProps);546 cbTransferHeuristics = DrvAudioHlpFloorBytesToFrame(&pStreamR3->State.Mapping.PCMProps, cbTransferHeuristics / 2); 547 547 548 548 /* Set the transfer size per timer callout. (No chunking, so same.) */ … … 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 = DrvAudioHlp BytesAlign(cbToReadFromStream, &pStreamR3->State.Mapping.PCMProps);1876 cbToReadFromStream = DrvAudioHlpFloorBytesToFrame(&pStreamR3->State.Mapping.PCMProps, cbToReadFromStream); 1877 1877 1878 1878 Assert(tsNowNs >= pStreamShared->State.tsLastReadNs); -
trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
r88004 r88006 72 72 ("got %x, expected 4\n", PDMAUDIOPCMPROPS_F2B(&s_Cfg441StereoU32, 1))); 73 73 74 uint32_t u32; 74 75 for (uint32_t i = 0; i < 256; i += 8) 75 76 { 76 77 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoU32, i) == true); 77 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoU32, i+1) == false); 78 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoU32, i+2) == false); 79 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoU32, i+3) == false); 80 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoU32, i+4) == false); 81 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoU32, i+5) == false); 82 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoU32, i+6) == false); 83 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoU32, i+7) == false); 78 for (uint32_t j = 1; j < 8; j++) 79 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoU32, i + j) == false); 80 for (uint32_t j = 0; j < 8; j++) 81 RTTESTI_CHECK(DrvAudioHlpFloorBytesToFrame(&s_Cfg441StereoU32, i + j) == i); 84 82 } 85 83 for (uint32_t i = 0; i < 4096; i += 4) 86 84 { 87 85 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoS16, i) == true); 88 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoS16, i+1) == false);89 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoS16, i+2) == false);90 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoS16, i+3) == false);91 }92 93 uint32_t u32; 86 for (uint32_t j = 1; j < 4; j++) 87 RTTESTI_CHECK(DrvAudioHlpIsBytesAligned(&s_Cfg441StereoS16, i + j) == false); 88 for (uint32_t j = 0; j < 4; j++) 89 RTTESTI_CHECK(DrvAudioHlpFloorBytesToFrame(&s_Cfg441StereoS16, i + j) == i); 90 } 91 94 92 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpFramesToBytes(&s_Cfg441StereoS16, 44100)) == 44100 * 2 * 2, 95 93 ("cb=%RU32\n", u32));
Note:
See TracChangeset
for help on using the changeset viewer.