Changeset 73420 in vbox for trunk/src/VBox
- Timestamp:
- Aug 1, 2018 12:35:28 PM (6 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.h
r73408 r73420 192 192 uint64_t DrvAudioHlpFramesToMilli(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps); 193 193 uint64_t DrvAudioHlpFramesToNano(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps); 194 uint32_t DrvAudioHlpMilliToBytes(uint 32_t uMs, const PPDMAUDIOPCMPROPS pProps);195 uint32_t DrvAudioHlpNanoToBytes(uint 32_t uNs, const PPDMAUDIOPCMPROPS pProps);196 uint32_t DrvAudioHlpMilliToFrames(uint 32_t uMs, const PPDMAUDIOPCMPROPS pProps);197 uint32_t DrvAudioHlpNanoToFrames(uint 32_t uNs, const PPDMAUDIOPCMPROPS pProps);194 uint32_t DrvAudioHlpMilliToBytes(uint64_t uMs, const PPDMAUDIOPCMPROPS pProps); 195 uint32_t DrvAudioHlpNanoToBytes(uint64_t uNs, const PPDMAUDIOPCMPROPS pProps); 196 uint32_t DrvAudioHlpMilliToFrames(uint64_t uMs, const PPDMAUDIOPCMPROPS pProps); 197 uint32_t DrvAudioHlpNanoToFrames(uint64_t uNs, const PPDMAUDIOPCMPROPS pProps); 198 198 /** @} */ 199 199 -
trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
r73409 r73420 1127 1127 return 0; 1128 1128 1129 const float dbBytesPerMs = ((pProps->cBits / 8) * pProps->cChannels * pProps->uHz) / RT_MS_1SEC; 1129 const uint64_t cbBytesPerSec = (pProps->cBits / 8) * pProps->cChannels * pProps->uHz; 1130 const double dbBytesPerMs = (double)cbBytesPerSec / (double)RT_MS_1SEC; 1130 1131 Assert(dbBytesPerMs >= 0.0f); 1131 1132 if (!dbBytesPerMs) /* Prevent division by zero. */ 1132 1133 return 0; 1133 1134 1134 return cbBytes /dbBytesPerMs;1135 return (double)cbBytes / (double)dbBytesPerMs; 1135 1136 } 1136 1137 … … 1149 1150 return 0; 1150 1151 1151 const floatdbBytesPerMs = ((pProps->cBits / 8) * pProps->cChannels * pProps->uHz) / RT_NS_1SEC;1152 const double dbBytesPerMs = ((pProps->cBits / 8) * pProps->cChannels * pProps->uHz) / RT_NS_1SEC; 1152 1153 Assert(dbBytesPerMs >= 0.0f); 1153 1154 if (!dbBytesPerMs) /* Prevent division by zero. */ … … 1171 1172 return 0; 1172 1173 1173 return cFrames * ((pProps->cBits / 8) * pProps->cChannels); 1174 const uint32_t cbFrame = (pProps->cBits / 8) * pProps->cChannels; 1175 return cFrames * cbFrame; 1174 1176 } 1175 1177 … … 1191 1193 return 0; 1192 1194 1193 return cFrames / ( pProps->uHz /RT_MS_1SEC);1195 return cFrames / ((double)pProps->uHz / (double)RT_MS_1SEC); 1194 1196 } 1195 1197 … … 1211 1213 return 0; 1212 1214 1213 return cFrames / float(pProps->uHz /RT_NS_1SEC);1215 return cFrames / ((double)pProps->uHz / (double)RT_NS_1SEC); 1214 1216 } 1215 1217 … … 1221 1223 * @param pProps PCM properties to calculate amount of bytes for. 1222 1224 */ 1223 uint32_t DrvAudioHlpMilliToBytes(uint 32_t uMs, const PPDMAUDIOPCMPROPS pProps)1225 uint32_t DrvAudioHlpMilliToBytes(uint64_t uMs, const PPDMAUDIOPCMPROPS pProps) 1224 1226 { 1225 1227 AssertPtrReturn(pProps, 0); … … 1228 1230 return 0; 1229 1231 1230 return float(((pProps->cBits / 8) * pProps->cChannels * pProps->uHz) / RT_MS_1SEC) * uMs; 1232 const uint64_t cbBytesPerSec = (pProps->cBits / 8) * pProps->cChannels * pProps->uHz; 1233 return ((double)cbBytesPerSec / (double)RT_MS_1SEC) * uMs; 1231 1234 } 1232 1235 … … 1238 1241 * @param pProps PCM properties to calculate amount of bytes for. 1239 1242 */ 1240 uint32_t DrvAudioHlpNanoToBytes(uint 32_t uNs, const PPDMAUDIOPCMPROPS pProps)1243 uint32_t DrvAudioHlpNanoToBytes(uint64_t uNs, const PPDMAUDIOPCMPROPS pProps) 1241 1244 { 1242 1245 AssertPtrReturn(pProps, 0); … … 1245 1248 return 0; 1246 1249 1247 return float(((pProps->cBits / 8) * pProps->cChannels * pProps->uHz) / RT_NS_1SEC) * uNs; 1250 const uint64_t cbBytesPerSec = (pProps->cBits / 8) * pProps->cChannels * pProps->uHz; 1251 return ((double)cbBytesPerSec / (double)RT_NS_1SEC) * uNs; 1248 1252 } 1249 1253 … … 1255 1259 * @param pProps PCM properties to calculate amount of frames for. 1256 1260 */ 1257 uint32_t DrvAudioHlpMilliToFrames(uint 32_t uMs, const PPDMAUDIOPCMPROPS pProps)1261 uint32_t DrvAudioHlpMilliToFrames(uint64_t uMs, const PPDMAUDIOPCMPROPS pProps) 1258 1262 { 1259 1263 AssertPtrReturn(pProps, 0); … … 1273 1277 * @param pProps PCM properties to calculate amount of frames for. 1274 1278 */ 1275 uint32_t DrvAudioHlpNanoToFrames(uint 32_t uNs, const PPDMAUDIOPCMPROPS pProps)1279 uint32_t DrvAudioHlpNanoToFrames(uint64_t uNs, const PPDMAUDIOPCMPROPS pProps) 1276 1280 { 1277 1281 AssertPtrReturn(pProps, 0);
Note:
See TracChangeset
for help on using the changeset viewer.