Changeset 87990 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Mar 7, 2021 2:29:40 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143113
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r87861 r87990 2088 2088 return 0; 2089 2089 2090 const uint64_t usBytes = DrvAudioHlpBytesToMicro( cbBytes, &pStreamCC->State.Cfg.Props);2090 const uint64_t usBytes = DrvAudioHlpBytesToMicro(&pStreamCC->State.Cfg.Props, cbBytes); 2091 2091 const uint64_t cTransferTicks = PDMDevHlpTimerFromMicro(pDevIns, pStream->hTimer, usBytes); 2092 2092 -
trunk/src/VBox/Devices/Audio/DrvAudio.h
r87875 r87990 195 195 /** @name Audio calculation helper methods. 196 196 * @{ */ 197 void DrvAudioHlpClearBuf( const PPDMAUDIOPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t cFrames);197 void DrvAudioHlpClearBuf(PCPDMAUDIOPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t cFrames); 198 198 uint32_t DrvAudioHlpCalcBitrate(uint8_t cBits, uint32_t uHz, uint8_t cChannels); 199 uint32_t DrvAudioHlpCalcBitrate( const PPDMAUDIOPCMPROPS pProps);200 uint32_t DrvAudioHlpBytesAlign(uint32_t cbSize, const PPDMAUDIOPCMPROPS pProps);201 bool DrvAudioHlpBytesIsAligned(uint32_t cbSize, const PPDMAUDIOPCMPROPS pProps);202 uint32_t DrvAudioHlpBytesToFrames(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps);203 uint64_t DrvAudioHlpBytesToMilli(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps);204 uint64_t DrvAudioHlpBytesToMicro( uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps);205 uint64_t DrvAudioHlpBytesToNano( uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps);206 uint32_t DrvAudioHlpFramesToBytes(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps);207 uint64_t DrvAudioHlpFramesToMilli(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps);208 uint64_t DrvAudioHlpFramesToNano(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps);209 uint32_t DrvAudioHlpMilliToBytes(uint64_t uMs, const PPDMAUDIOPCMPROPS pProps);210 uint32_t DrvAudioHlpNanoToBytes(uint64_t uNs, const PPDMAUDIOPCMPROPS pProps);211 uint32_t DrvAudioHlpMilliToFrames(uint64_t uMs, const PPDMAUDIOPCMPROPS pProps);212 uint32_t DrvAudioHlpNanoToFrames(uint64_t uNs, const PPDMAUDIOPCMPROPS pProps);199 uint32_t DrvAudioHlpCalcBitrate(PCPDMAUDIOPCMPROPS pProps); 200 uint32_t DrvAudioHlpBytesAlign(uint32_t cbSize, PCPDMAUDIOPCMPROPS pProps); 201 bool DrvAudioHlpBytesIsAligned(uint32_t cbSize, PCPDMAUDIOPCMPROPS pProps); 202 uint32_t DrvAudioHlpBytesToFrames(uint32_t cbBytes, PCPDMAUDIOPCMPROPS pProps); 203 uint64_t DrvAudioHlpBytesToMilli(uint32_t cbBytes, PCPDMAUDIOPCMPROPS pProps); 204 uint64_t DrvAudioHlpBytesToMicro(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 205 uint64_t DrvAudioHlpBytesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cb); 206 uint32_t DrvAudioHlpFramesToBytes(uint32_t cFrames, PCPDMAUDIOPCMPROPS pProps); 207 uint64_t DrvAudioHlpFramesToMilli(uint32_t cFrames, PCPDMAUDIOPCMPROPS pProps); 208 uint64_t DrvAudioHlpFramesToNano(uint32_t cFrames, PCPDMAUDIOPCMPROPS pProps); 209 uint32_t DrvAudioHlpMilliToBytes(uint64_t uMs, PCPDMAUDIOPCMPROPS pProps); 210 uint32_t DrvAudioHlpNanoToBytes(uint64_t uNs, PCPDMAUDIOPCMPROPS pProps); 211 uint32_t DrvAudioHlpMilliToFrames(uint64_t uMs, PCPDMAUDIOPCMPROPS pProps); 212 uint32_t DrvAudioHlpNanoToFrames(uint64_t uNs, PCPDMAUDIOPCMPROPS pProps); 213 213 /** @} */ 214 214 215 215 /** @name Audio PCM properties helper methods. 216 216 * @{ */ 217 bool DrvAudioHlpPCMPropsAreEqual( const PPDMAUDIOPCMPROPS pPCMProps1, const PPDMAUDIOPCMPROPS pPCMProps2);218 bool DrvAudioHlpPCMPropsAreEqual( const PPDMAUDIOPCMPROPS pPCMProps, const PPDMAUDIOSTREAMCFG pCfg);219 bool DrvAudioHlpPCMPropsAreValid( const PPDMAUDIOPCMPROPS pProps);220 uint32_t DrvAudioHlpPCMPropsBytesPerFrame( const PPDMAUDIOPCMPROPS pProps);221 void DrvAudioHlpPCMPropsPrint( const PPDMAUDIOPCMPROPS pProps);222 int DrvAudioHlpPCMPropsToStreamCfg( const PPDMAUDIOPCMPROPS pPCMProps, PPDMAUDIOSTREAMCFG pCfg);217 bool DrvAudioHlpPCMPropsAreEqual(PCPDMAUDIOPCMPROPS pPCMProps1, PCPDMAUDIOPCMPROPS pPCMProps2); 218 bool DrvAudioHlpPCMPropsAreEqual(PCPDMAUDIOPCMPROPS pPCMProps, PCPDMAUDIOSTREAMCFG pCfg); 219 bool DrvAudioHlpPCMPropsAreValid(PCPDMAUDIOPCMPROPS pProps); 220 uint32_t DrvAudioHlpPCMPropsBytesPerFrame(PCPDMAUDIOPCMPROPS pProps); 221 void DrvAudioHlpPCMPropsPrint(PCPDMAUDIOPCMPROPS pProps); 222 int DrvAudioHlpPCMPropsToStreamCfg(PCPDMAUDIOPCMPROPS pPCMProps, PPDMAUDIOSTREAMCFG pCfg); 223 223 /** @} */ 224 224 … … 226 226 * @{ */ 227 227 void DrvAudioHlpStreamCfgInit(PPDMAUDIOSTREAMCFG pCfg); 228 bool DrvAudioHlpStreamCfgIsValid( const PPDMAUDIOSTREAMCFG pCfg);229 int DrvAudioHlpStreamCfgCopy(PPDMAUDIOSTREAMCFG pDstCfg, const PPDMAUDIOSTREAMCFG pSrcCfg);230 PPDMAUDIOSTREAMCFG DrvAudioHlpStreamCfgDup( const PPDMAUDIOSTREAMCFG pCfg);228 bool DrvAudioHlpStreamCfgIsValid(PCPDMAUDIOSTREAMCFG pCfg); 229 int DrvAudioHlpStreamCfgCopy(PPDMAUDIOSTREAMCFG pDstCfg, PCPDMAUDIOSTREAMCFG pSrcCfg); 230 PPDMAUDIOSTREAMCFG DrvAudioHlpStreamCfgDup(PCPDMAUDIOSTREAMCFG pCfg); 231 231 void DrvAudioHlpStreamCfgFree(PPDMAUDIOSTREAMCFG pCfg); 232 void DrvAudioHlpStreamCfgPrint( const PPDMAUDIOSTREAMCFG pCfg);232 void DrvAudioHlpStreamCfgPrint(PCPDMAUDIOSTREAMCFG pCfg); 233 233 /** @} */ 234 234 … … 287 287 int DrvAudioHlpFileCreate(PDMAUDIOFILETYPE enmType, const char *pszFile, uint32_t fFlags, PPDMAUDIOFILE *ppFile); 288 288 void DrvAudioHlpFileDestroy(PPDMAUDIOFILE pFile); 289 int DrvAudioHlpFileOpen(PPDMAUDIOFILE pFile, uint32_t fOpen, const PPDMAUDIOPCMPROPS pProps);289 int DrvAudioHlpFileOpen(PPDMAUDIOFILE pFile, uint32_t fOpen, PCPDMAUDIOPCMPROPS pProps); 290 290 int DrvAudioHlpFileClose(PPDMAUDIOFILE pFile); 291 291 int DrvAudioHlpFileDelete(PPDMAUDIOFILE pFile); -
trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
r87987 r87990 128 128 * @param cFrames Number of audio frames to clear in the buffer. 129 129 */ 130 void DrvAudioHlpClearBuf( const PPDMAUDIOPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t cFrames)130 void DrvAudioHlpClearBuf(PCPDMAUDIOPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t cFrames) 131 131 { 132 132 AssertPtrReturnVoid(pPCMProps); … … 822 822 * @param pProps2 Second properties to compare. 823 823 */ 824 bool DrvAudioHlpPCMPropsAreEqual( const PPDMAUDIOPCMPROPS pProps1, const PPDMAUDIOPCMPROPS pProps2)824 bool DrvAudioHlpPCMPropsAreEqual(PCPDMAUDIOPCMPROPS pProps1, PCPDMAUDIOPCMPROPS pProps2) 825 825 { 826 826 AssertPtrReturn(pProps1, false); … … 843 843 * @param pProps PCM properties to check. 844 844 */ 845 bool DrvAudioHlpPCMPropsAreValid( const PPDMAUDIOPCMPROPS pProps)845 bool DrvAudioHlpPCMPropsAreValid(PCPDMAUDIOPCMPROPS pProps) 846 846 { 847 847 AssertPtrReturn(pProps, false); … … 892 892 * @param pCfg Stream configuration to compare. 893 893 */ 894 bool DrvAudioHlpPCMPropsAreEqual( const PPDMAUDIOPCMPROPS pProps, const PPDMAUDIOSTREAMCFG pCfg)894 bool DrvAudioHlpPCMPropsAreEqual(PCPDMAUDIOPCMPROPS pProps, PCPDMAUDIOSTREAMCFG pCfg) 895 895 { 896 896 AssertPtrReturn(pProps, false); … … 906 906 * @param pProps PCM properties to retrieve bytes per frame for. 907 907 */ 908 uint32_t DrvAudioHlpPCMPropsBytesPerFrame( const PPDMAUDIOPCMPROPS pProps)908 uint32_t DrvAudioHlpPCMPropsBytesPerFrame(PCPDMAUDIOPCMPROPS pProps) 909 909 { 910 910 return PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); … … 916 916 * @param pProps Stream configuration to log. 917 917 */ 918 void DrvAudioHlpPCMPropsPrint( const PPDMAUDIOPCMPROPS pProps)918 void DrvAudioHlpPCMPropsPrint(PCPDMAUDIOPCMPROPS pProps) 919 919 { 920 920 AssertPtrReturnVoid(pProps); … … 931 931 * @param pCfg Stream configuration to store result into. 932 932 */ 933 int DrvAudioHlpPCMPropsToStreamCfg( const PPDMAUDIOPCMPROPS pProps, PPDMAUDIOSTREAMCFG pCfg)933 int DrvAudioHlpPCMPropsToStreamCfg(PCPDMAUDIOPCMPROPS pProps, PPDMAUDIOSTREAMCFG pCfg) 934 934 { 935 935 AssertPtrReturn(pProps, VERR_INVALID_POINTER); … … 962 962 * @param pCfg Stream configuration to check. 963 963 */ 964 bool DrvAudioHlpStreamCfgIsValid( const PPDMAUDIOSTREAMCFG pCfg)964 bool DrvAudioHlpStreamCfgIsValid(PCPDMAUDIOSTREAMCFG pCfg) 965 965 { 966 966 AssertPtrReturn(pCfg, false); … … 999 999 * @param pSrcCfg Source stream configuration to copy to destination. 1000 1000 */ 1001 int DrvAudioHlpStreamCfgCopy(PPDMAUDIOSTREAMCFG pDstCfg, const PPDMAUDIOSTREAMCFG pSrcCfg)1001 int DrvAudioHlpStreamCfgCopy(PPDMAUDIOSTREAMCFG pDstCfg, PCPDMAUDIOSTREAMCFG pSrcCfg) 1002 1002 { 1003 1003 AssertPtrReturn(pDstCfg, VERR_INVALID_POINTER); … … 1024 1024 * @param pCfg Audio stream configuration to duplicate. 1025 1025 */ 1026 PPDMAUDIOSTREAMCFG DrvAudioHlpStreamCfgDup( const PPDMAUDIOSTREAMCFG pCfg)1026 PPDMAUDIOSTREAMCFG DrvAudioHlpStreamCfgDup(PCPDMAUDIOSTREAMCFG pCfg) 1027 1027 { 1028 1028 AssertPtrReturn(pCfg, NULL); … … 1056 1056 * @param pCfg Stream configuration to log. 1057 1057 */ 1058 void DrvAudioHlpStreamCfgPrint( const PPDMAUDIOSTREAMCFG pCfg)1058 void DrvAudioHlpStreamCfgPrint(PCPDMAUDIOSTREAMCFG pCfg) 1059 1059 { 1060 1060 if (!pCfg) … … 1168 1168 * @remark 1169 1169 */ 1170 uint32_t DrvAudioHlpCalcBitrate( const PPDMAUDIOPCMPROPS pProps)1170 uint32_t DrvAudioHlpCalcBitrate(PCPDMAUDIOPCMPROPS pProps) 1171 1171 { 1172 1172 return DrvAudioHlpCalcBitrate(pProps->cbSample * 8, pProps->uHz, pProps->cChannels); … … 1181 1181 * @param pProps PCM properties to align size to. 1182 1182 */ 1183 uint32_t DrvAudioHlpBytesAlign(uint32_t cbSize, const PPDMAUDIOPCMPROPS pProps)1183 uint32_t DrvAudioHlpBytesAlign(uint32_t cbSize, PCPDMAUDIOPCMPROPS pProps) 1184 1184 { 1185 1185 AssertPtrReturn(pProps, 0); … … 1198 1198 * @param pProps PCM properties to use for checking the alignment. 1199 1199 */ 1200 bool DrvAudioHlpBytesIsAligned(uint32_t cbSize, const PPDMAUDIOPCMPROPS pProps)1200 bool DrvAudioHlpBytesIsAligned(uint32_t cbSize, PCPDMAUDIOPCMPROPS pProps) 1201 1201 { 1202 1202 AssertPtrReturn(pProps, 0); … … 1214 1214 * @param pProps PCM properties to retrieve size for. 1215 1215 */ 1216 DECLINLINE(uint64_t) drvAudioHlpBytesPerSec( const PPDMAUDIOPCMPROPS pProps)1216 DECLINLINE(uint64_t) drvAudioHlpBytesPerSec(PCPDMAUDIOPCMPROPS pProps) 1217 1217 { 1218 1218 return PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */) * pProps->uHz; … … 1226 1226 * @param pProps PCM properties to calulate frames for. 1227 1227 */ 1228 uint32_t DrvAudioHlpBytesToFrames(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps)1228 uint32_t DrvAudioHlpBytesToFrames(uint32_t cbBytes, PCPDMAUDIOPCMPROPS pProps) 1229 1229 { 1230 1230 AssertPtrReturn(pProps, 0); … … 1234 1234 1235 1235 /** 1236 * Returns the time (in ms) for given byte amount and PCM properties.1237 * 1238 * @return uint64_t Calculated time (in ms).1239 * @param cbBytes Amount of bytes to calculate time for.1240 * @param pProps PCM properties to calculate amount of bytes for.1241 * 1242 * @note Does roundingup the result.1243 */ 1244 uint64_t DrvAudioHlpBytesToMilli(uint32_t cb Bytes, const PPDMAUDIOPCMPROPS pProps)1236 * Converts bytes to milliseconds. 1237 * 1238 * @return Number milliseconds @a cb takes to play or record. 1239 * @param pProps PCM properties to use. 1240 * @param cb The number of bytes to convert. 1241 * 1242 * @note Rounds up the result. 1243 */ 1244 uint64_t DrvAudioHlpBytesToMilli(uint32_t cb, PCPDMAUDIOPCMPROPS pProps) 1245 1245 { 1246 1246 AssertPtrReturn(pProps, 0); 1247 1247 1248 if (!pProps->uHz) /* Prevent division by zero. */ 1249 return 0; 1250 1251 const unsigned cbFrame = PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); 1252 1253 if (!cbFrame) /* Prevent division by zero. */ 1254 return 0; 1255 1256 uint64_t uTimeMs = ((cbBytes + cbFrame - 1) / cbFrame) * RT_MS_1SEC; 1257 1258 return (uTimeMs + pProps->uHz - 1) / pProps->uHz; 1259 } 1260 1261 /** 1262 * Returns the time (in us) for given byte amount and PCM properties. 1263 * 1264 * @return uint64_t Calculated time (in us). 1265 * @param cbBytes Amount of bytes to calculate time for. 1266 * @param pProps PCM properties to calculate amount of bytes for. 1267 * 1268 * @note Does rounding up the result. 1269 */ 1270 uint64_t DrvAudioHlpBytesToMicro(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps) 1248 /* Check parameters to prevent division by chainsaw: */ 1249 uint32_t const uHz = pProps->uHz; 1250 if (uHz) 1251 { 1252 const unsigned cbFrame = PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); 1253 if (cbFrame) 1254 { 1255 /* Round cb up to closest frame size: */ 1256 cb = (cb + cbFrame - 1) / cbFrame; 1257 1258 /* Convert to milliseconds. */ 1259 return (cb * (uint64_t)RT_MS_1SEC + uHz - 1) / uHz; 1260 } 1261 } 1262 return 0; 1263 } 1264 1265 /** 1266 * Converts bytes to microseconds. 1267 * 1268 * @return Number microseconds @a cb takes to play or record. 1269 * @param pProps PCM properties to use. 1270 * @param cb The number of bytes to convert. 1271 * 1272 * @note Rounds up the result. 1273 */ 1274 uint64_t DrvAudioHlpBytesToMicro(PCPDMAUDIOPCMPROPS pProps, uint32_t cb) 1271 1275 { 1272 1276 AssertPtrReturn(pProps, 0); 1273 1277 1274 if (!pProps->uHz) /* Prevent division by zero. */ 1275 return 0; 1276 1277 const unsigned cbFrame = PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); 1278 1279 if (!cbFrame) /* Prevent division by zero. */ 1280 return 0; 1281 1282 uint64_t uTimeUs = ((cbBytes + cbFrame - 1) / cbFrame) * RT_US_1SEC; 1283 1284 return (uTimeUs + pProps->uHz - 1) / pProps->uHz; 1285 } 1286 1287 /** 1288 * Returns the time (in ns) for given byte amount and PCM properties. 1289 * 1290 * @return uint64_t Calculated time (in ns). 1291 * @param cbBytes Amount of bytes to calculate time for. 1292 * @param pProps PCM properties to calculate amount of bytes for. 1293 * 1294 * @note Does rounding up the result. 1295 */ 1296 uint64_t DrvAudioHlpBytesToNano(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps) 1278 /* Check parameters to prevent division by chainsaw: */ 1279 uint32_t const uHz = pProps->uHz; 1280 if (uHz) 1281 { 1282 const unsigned cbFrame = PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); 1283 if (cbFrame) 1284 { 1285 /* Round cb up to closest frame size: */ 1286 cb = (cb + cbFrame - 1) / cbFrame; 1287 1288 /* Convert to microseconds. */ 1289 return (cb * (uint64_t)RT_US_1SEC + uHz - 1) / uHz; 1290 } 1291 } 1292 return 0; 1293 } 1294 1295 /** 1296 * Converts bytes to nanoseconds. 1297 * 1298 * @return Number nanoseconds @a cb takes to play or record. 1299 * @param pProps PCM properties to use. 1300 * @param cb The number of bytes to convert. 1301 * 1302 * @note Rounds up the result. 1303 */ 1304 uint64_t DrvAudioHlpBytesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cb) 1297 1305 { 1298 1306 AssertPtrReturn(pProps, 0); 1299 1307 1300 if (!pProps->uHz) /* Prevent division by zero. */ 1301 return 0; 1302 1303 const unsigned cbFrame = PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); 1304 1305 if (!cbFrame) /* Prevent division by zero. */ 1306 return 0; 1307 1308 uint64_t uTimeNs = ((cbBytes + cbFrame - 1) / cbFrame) * RT_NS_1SEC; 1309 1310 return (uTimeNs + pProps->uHz - 1) / pProps->uHz; 1308 /* Check parameters to prevent division by chainsaw: */ 1309 uint32_t const uHz = pProps->uHz; 1310 if (uHz) 1311 { 1312 const unsigned cbFrame = PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); 1313 if (cbFrame) 1314 { 1315 /* Round cb up to closest frame size: */ 1316 cb = (cb + cbFrame - 1) / cbFrame; 1317 1318 /* Convert to nanoseconds. */ 1319 return (cb * (uint64_t)RT_NS_1SEC + uHz - 1) / uHz; 1320 } 1321 } 1322 return 0; 1311 1323 } 1312 1324 … … 1318 1330 * @param pProps PCM properties to calculate bytes for. 1319 1331 */ 1320 uint32_t DrvAudioHlpFramesToBytes(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps)1332 uint32_t DrvAudioHlpFramesToBytes(uint32_t cFrames, PCPDMAUDIOPCMPROPS pProps) 1321 1333 { 1322 1334 AssertPtrReturn(pProps, 0); … … 1335 1347 * @param pProps PCM properties to calculate time (in ms) for. 1336 1348 */ 1337 uint64_t DrvAudioHlpFramesToMilli(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps)1349 uint64_t DrvAudioHlpFramesToMilli(uint32_t cFrames, PCPDMAUDIOPCMPROPS pProps) 1338 1350 { 1339 1351 AssertPtrReturn(pProps, 0); … … 1362 1374 * @param pProps PCM properties to calculate time (in ns) for. 1363 1375 */ 1364 uint64_t DrvAudioHlpFramesToNano(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps)1376 uint64_t DrvAudioHlpFramesToNano(uint32_t cFrames, PCPDMAUDIOPCMPROPS pProps) 1365 1377 { 1366 1378 AssertPtrReturn(pProps, 0); … … 1384 1396 * @param pProps PCM properties to calculate amount of bytes for. 1385 1397 */ 1386 uint32_t DrvAudioHlpMilliToBytes(uint64_t uMs, const PPDMAUDIOPCMPROPS pProps)1398 uint32_t DrvAudioHlpMilliToBytes(uint64_t uMs, PCPDMAUDIOPCMPROPS pProps) 1387 1399 { 1388 1400 AssertPtrReturn(pProps, 0); … … 1411 1423 * @param pProps PCM properties to calculate amount of bytes for. 1412 1424 */ 1413 uint32_t DrvAudioHlpNanoToBytes(uint64_t uNs, const PPDMAUDIOPCMPROPS pProps)1425 uint32_t DrvAudioHlpNanoToBytes(uint64_t uNs, PCPDMAUDIOPCMPROPS pProps) 1414 1426 { 1415 1427 AssertPtrReturn(pProps, 0); … … 1436 1448 * @param pProps PCM properties to calculate amount of frames for. 1437 1449 */ 1438 uint32_t DrvAudioHlpMilliToFrames(uint64_t uMs, const PPDMAUDIOPCMPROPS pProps)1450 uint32_t DrvAudioHlpMilliToFrames(uint64_t uMs, PCPDMAUDIOPCMPROPS pProps) 1439 1451 { 1440 1452 AssertPtrReturn(pProps, 0); … … 1454 1466 * @param pProps PCM properties to calculate amount of frames for. 1455 1467 */ 1456 uint32_t DrvAudioHlpNanoToFrames(uint64_t uNs, const PPDMAUDIOPCMPROPS pProps)1468 uint32_t DrvAudioHlpNanoToFrames(uint64_t uNs, PCPDMAUDIOPCMPROPS pProps) 1457 1469 { 1458 1470 AssertPtrReturn(pProps, 0); … … 1704 1716 * @param pProps PCM properties to use. 1705 1717 */ 1706 int DrvAudioHlpFileOpen(PPDMAUDIOFILE pFile, uint32_t fOpen, const PPDMAUDIOPCMPROPS pProps)1718 int DrvAudioHlpFileOpen(PPDMAUDIOFILE pFile, uint32_t fOpen, PCPDMAUDIOPCMPROPS pProps) 1707 1719 { 1708 1720 AssertPtrReturn(pFile, VERR_INVALID_POINTER); -
trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
r82968 r87990 33 33 34 34 35 /********************************************************************************************************************************* 36 * Structures and Typedefs * 37 *********************************************************************************************************************************/ 35 static void tstBasics(RTTEST hTest) 36 { 37 RTTestSubF(hTest, "Single buffer"); 38 39 static const PDMAUDIOPCMPROPS s_Cfg441StereoS16 = PDMAUDIOPCMPROPS_INITIALIZOR( 40 /* a_cb: */ 2, 41 /* a_fSigned: */ true, 42 /* a_cChannels: */ 2, 43 /* a_uHz: */ 44100, 44 /* a_cShift: */ PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(2 /* cb */, 2 /* cChannels */), 45 /* a_fSwapEndian: */ false 46 ); 47 48 RTTESTI_CHECK_MSG(PDMAUDIOPCMPROPS_F2B(&s_Cfg441StereoS16, 1) == 4, 49 ("got %x, expected 4\n", PDMAUDIOPCMPROPS_F2B(&s_Cfg441StereoS16, 1))); 50 51 uint32_t u32; 52 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpFramesToBytes(44100, &s_Cfg441StereoS16)) == 44100 * 2 * 2, 53 ("cb=%RU32\n", u32)); 54 RTTESTI_CHECK_MSG((u32 = DrvAudioHlpFramesToBytes(2, &s_Cfg441StereoS16)) == 2 * 2 * 2, 55 ("cb=%RU32\n", u32)); 56 57 uint64_t u64; 58 RTTESTI_CHECK_MSG((u64 = DrvAudioHlpBytesToNano(&s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_NS_1SEC, 59 ("ns=%RU64\n", u64)); 60 RTTESTI_CHECK_MSG((u64 = DrvAudioHlpBytesToMicro(&s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_US_1SEC, 61 ("us=%RU64\n", u64)); 62 RTTESTI_CHECK_MSG((u64 = DrvAudioHlpBytesToMilli(44100 * 2 * 2, &s_Cfg441StereoS16)) == RT_MS_1SEC, 63 ("ms=%RU64\n", u64)); 64 65 66 67 } 68 38 69 39 70 static int tstSingle(RTTEST hTest) 40 71 { 41 RTTestSub F(hTest, "Single buffer");72 RTTestSub(hTest, "Single buffer"); 42 73 43 74 /* 44100Hz, 2 Channels, S16 */ … … 232 263 * Using AudioMixBufWriteAt for writing to children. 233 264 */ 234 RTTestSub F(hTest, "2 Children -> Parent (AudioMixBufWriteAt)");265 RTTestSub(hTest, "2 Children -> Parent (AudioMixBufWriteAt)"); 235 266 236 267 uint32_t cChildrenSamplesMixedTotal = 0; … … 308 339 uint32_t cBufSize = 256; 309 340 310 RTTestSub F(hTest, "Sample conversion (U8)");341 RTTestSub(hTest, "Sample conversion (U8)"); 311 342 312 343 /* 44100Hz, 1 Channel, U8 */ … … 413 444 uint32_t cBufSize = 256; 414 445 415 RTTestSub F(hTest, "Sample conversion (S16)");446 RTTestSub(hTest, "Sample conversion (S16)"); 416 447 417 448 /* 44100Hz, 1 Channel, S16 */ … … 509 540 uint32_t cBufSize = 256; 510 541 511 RTTestSub F(hTest, "Volume control");542 RTTestSub(hTest, "Volume control"); 512 543 513 544 /* Same for parent/child. */ … … 635 666 RTTestBanner(hTest); 636 667 637 rc = tstSingle(hTest); 638 if (RT_SUCCESS(rc)) 639 rc = tstParentChild(hTest); 640 if (RT_SUCCESS(rc)) 641 rc = tstConversion8(hTest); 642 if (RT_SUCCESS(rc)) 643 rc = tstConversion16(hTest); 644 if (RT_SUCCESS(rc)) 645 rc = tstVolume(hTest); 668 tstBasics(hTest); 669 tstSingle(hTest); 670 tstParentChild(hTest); 671 tstConversion8(hTest); 672 tstConversion16(hTest); 673 tstVolume(hTest); 646 674 647 675 /*
Note:
See TracChangeset
for help on using the changeset viewer.