- Timestamp:
- Jul 11, 2018 10:12:55 AM (7 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.h
r71113 r73058 155 155 uint32_t DrvAudioHlpCalcBitrate(const PPDMAUDIOPCMPROPS pProps); 156 156 uint64_t DrvAudioHlpBytesToMs(const PPDMAUDIOPCMPROPS pProps, size_t cbBytes); 157 float DrvAudioHlpFramesToMs(const PPDMAUDIOPCMPROPS pProps, size_t cFrames); 157 158 uint32_t DrvAudioHlpMsToBytes(const PPDMAUDIOPCMPROPS pProps, uint32_t uMs); 159 uint32_t DrvAudioHlpMsToFrames(const PPDMAUDIOPCMPROPS pProps, uint32_t uMs); 158 160 bool DrvAudioHlpPCMPropsAreEqual(const PPDMAUDIOPCMPROPS pPCMProps1, const PPDMAUDIOPCMPROPS pPCMProps2); 159 161 bool DrvAudioHlpPCMPropsAreEqual(const PPDMAUDIOPCMPROPS pPCMProps, const PPDMAUDIOSTREAMCFG pCfg); -
trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
r72111 r73058 1075 1075 1076 1076 /** 1077 * Returns the time (in ms) for given audio frames amount and PCM properties. 1078 * 1079 * @return float Calculated time (in ms). 1080 * @param pProps PCM properties to calculate time (in ms) for. 1081 * @param cFrames Amount of audio frames to calculate time for. 1082 */ 1083 float DrvAudioHlpFramesToMs(const PPDMAUDIOPCMPROPS pProps, size_t cFrames) 1084 { 1085 AssertPtrReturn(pProps, 0); 1086 1087 if (!cFrames) 1088 return 0; 1089 1090 if (!pProps->uHz) /* Prevent division by zero. */ 1091 return 0; 1092 1093 return float(cFrames / (pProps->uHz / 1000 /* ms */)); 1094 } 1095 1096 /** 1077 1097 * Returns the amount of bytes for a given time (in ms) and PCM properties. 1078 1098 * … … 1089 1109 1090 1110 return float(((pProps->cBits / 8) * pProps->cChannels * pProps->uHz) / 1000) * uMs; 1111 } 1112 1113 /** 1114 * Returns the amount of audio for a given time (in ms) and PCM properties. 1115 * 1116 * @return uint32_t Calculated amount of audio frames. 1117 * @param pProps PCM properties to calculate amount of bytes for. 1118 * @param uMs Time (in ms) to calculate amount of bytes for. 1119 */ 1120 uint32_t DrvAudioHlpMsToFrames(const PPDMAUDIOPCMPROPS pProps, uint32_t uMs) 1121 { 1122 AssertPtrReturn(pProps, 0); 1123 1124 const size_t cbFrame = (pProps->cBits / 8) * pProps->cChannels; 1125 if (!cbFrame) /* Prevent division by zero. */ 1126 return 0; 1127 1128 return DrvAudioHlpMsToBytes(pProps, uMs) / cbFrame; 1091 1129 } 1092 1130
Note:
See TracChangeset
for help on using the changeset viewer.