- Timestamp:
- Aug 6, 2018 5:27:41 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
r73529 r73532 874 874 uint32_t DrvAudioHlpPCMPropsBytesPerFrame(const PPDMAUDIOPCMPROPS pProps) 875 875 { 876 return pProps->cBytes * pProps->cChannels;876 return PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); 877 877 } 878 878 … … 1137 1137 return 0; 1138 1138 1139 const uint32_t cbFrameSize = DrvAudioHlpPCMPropsBytesPerFrame(pProps); 1140 return (cbSize / cbFrameSize) * cbFrameSize; 1139 return PDMAUDIOPCMPROPS_B2F(pProps, cbSize) * PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); 1141 1140 } 1142 1141 … … 1155 1154 return true; 1156 1155 1157 return (cbSize % DrvAudioHlpPCMPropsBytesPerFrame(pProps) == 0); 1156 return (cbSize % PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */) == 0); 1157 } 1158 1159 /** 1160 * Returns the bytes per second for given PCM properties. 1161 * 1162 * @returns Bytes per second. 1163 * @param pProps PCM properties to retrieve size for. 1164 */ 1165 DECLINLINE(uint64_t) drvAudioHlpBytesPerSec(const PPDMAUDIOPCMPROPS pProps) 1166 { 1167 return PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */) * pProps->uHz; 1158 1168 } 1159 1169 … … 1169 1179 AssertPtrReturn(pProps, 0); 1170 1180 1171 return cbBytes / (pProps->cBytes * pProps->cChannels);1181 return PDMAUDIOPCMPROPS_B2F(pProps, cbBytes); 1172 1182 } 1173 1183 … … 1186 1196 return 0; 1187 1197 1188 const uint64_t cbBytesPerSec = pProps->cBytes * pProps->cChannels * pProps->uHz; 1189 const double dbBytesPerMs = (double)cbBytesPerSec / (double)RT_MS_1SEC; 1198 const double dbBytesPerMs = (double)drvAudioHlpBytesPerSec(pProps) / (double)RT_MS_1SEC; 1190 1199 Assert(dbBytesPerMs >= 0.0f); 1191 1200 if (!dbBytesPerMs) /* Prevent division by zero. */ … … 1209 1218 return 0; 1210 1219 1211 const double dbBytesPerMs = ( pProps->cBytes * pProps->cChannels* pProps->uHz) / RT_NS_1SEC;1220 const double dbBytesPerMs = (PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */) * pProps->uHz) / RT_NS_1SEC; 1212 1221 Assert(dbBytesPerMs >= 0.0f); 1213 1222 if (!dbBytesPerMs) /* Prevent division by zero. */ … … 1231 1240 return 0; 1232 1241 1233 return cFrames * pProps->cBytes * pProps->cChannels;1242 return cFrames * PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); 1234 1243 } 1235 1244 … … 1288 1297 return 0; 1289 1298 1290 const uint64_t cbBytesPerSec = pProps->cBytes * pProps->cChannels * pProps->uHz; 1291 return ((double)cbBytesPerSec / (double)RT_MS_1SEC) * uMs; 1299 return ((double)drvAudioHlpBytesPerSec(pProps) / (double)RT_MS_1SEC) * uMs; 1292 1300 } 1293 1301 … … 1306 1314 return 0; 1307 1315 1308 const uint64_t cbBytesPerSec = pProps->cBytes * pProps->cChannels * pProps->uHz; 1309 return ((double)cbBytesPerSec / (double)RT_NS_1SEC) * uNs; 1316 return ((double)drvAudioHlpBytesPerSec(pProps) / (double)RT_NS_1SEC) * uNs; 1310 1317 } 1311 1318 … … 1321 1328 AssertPtrReturn(pProps, 0); 1322 1329 1323 const uint32_t cbFrame = pProps->cBytes * pProps->cChannels;1330 const uint32_t cbFrame = PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); 1324 1331 if (!cbFrame) /* Prevent division by zero. */ 1325 1332 return 0; … … 1339 1346 AssertPtrReturn(pProps, 0); 1340 1347 1341 const uint32_t cbFrame = pProps->cBytes * pProps->cChannels;1348 const uint32_t cbFrame = PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */); 1342 1349 if (!cbFrame) /* Prevent division by zero. */ 1343 1350 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.