Changeset 88022 in vbox for trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
- Timestamp:
- Mar 8, 2021 5:50:57 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.