VirtualBox

Changeset 73420 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 1, 2018 12:35:28 PM (6 years ago)
Author:
vboxsync
Message:

Audio/DrvAudio: Misc fixes for the timing helper functions.

Location:
trunk/src/VBox/Devices/Audio
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DrvAudio.h

    r73408 r73420  
    192192uint64_t DrvAudioHlpFramesToMilli(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps);
    193193uint64_t DrvAudioHlpFramesToNano(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps);
    194 uint32_t DrvAudioHlpMilliToBytes(uint32_t uMs, const PPDMAUDIOPCMPROPS pProps);
    195 uint32_t DrvAudioHlpNanoToBytes(uint32_t uNs, const PPDMAUDIOPCMPROPS pProps);
    196 uint32_t DrvAudioHlpMilliToFrames(uint32_t uMs, const PPDMAUDIOPCMPROPS pProps);
    197 uint32_t DrvAudioHlpNanoToFrames(uint32_t uNs, const PPDMAUDIOPCMPROPS pProps);
     194uint32_t DrvAudioHlpMilliToBytes(uint64_t uMs, const PPDMAUDIOPCMPROPS pProps);
     195uint32_t DrvAudioHlpNanoToBytes(uint64_t uNs, const PPDMAUDIOPCMPROPS pProps);
     196uint32_t DrvAudioHlpMilliToFrames(uint64_t uMs, const PPDMAUDIOPCMPROPS pProps);
     197uint32_t DrvAudioHlpNanoToFrames(uint64_t uNs, const PPDMAUDIOPCMPROPS pProps);
    198198/** @}  */
    199199
  • trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp

    r73409 r73420  
    11271127        return 0;
    11281128
    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;
    11301131    Assert(dbBytesPerMs >= 0.0f);
    11311132    if (!dbBytesPerMs) /* Prevent division by zero. */
    11321133        return 0;
    11331134
    1134     return cbBytes / dbBytesPerMs;
     1135    return (double)cbBytes / (double)dbBytesPerMs;
    11351136}
    11361137
     
    11491150        return 0;
    11501151
    1151     const float dbBytesPerMs = ((pProps->cBits / 8) * pProps->cChannels * pProps->uHz) / RT_NS_1SEC;
     1152    const double dbBytesPerMs = ((pProps->cBits / 8) * pProps->cChannels * pProps->uHz) / RT_NS_1SEC;
    11521153    Assert(dbBytesPerMs >= 0.0f);
    11531154    if (!dbBytesPerMs) /* Prevent division by zero. */
     
    11711172        return 0;
    11721173
    1173     return cFrames * ((pProps->cBits / 8) * pProps->cChannels);
     1174    const uint32_t cbFrame = (pProps->cBits / 8) * pProps->cChannels;
     1175    return cFrames * cbFrame;
    11741176}
    11751177
     
    11911193        return 0;
    11921194
    1193     return cFrames / (pProps->uHz / RT_MS_1SEC);
     1195    return cFrames / ((double)pProps->uHz / (double)RT_MS_1SEC);
    11941196}
    11951197
     
    12111213        return 0;
    12121214
    1213     return cFrames / float(pProps->uHz / RT_NS_1SEC);
     1215    return cFrames / ((double)pProps->uHz / (double)RT_NS_1SEC);
    12141216}
    12151217
     
    12211223 * @param   pProps              PCM properties to calculate amount of bytes for.
    12221224 */
    1223 uint32_t DrvAudioHlpMilliToBytes(uint32_t uMs, const PPDMAUDIOPCMPROPS pProps)
     1225uint32_t DrvAudioHlpMilliToBytes(uint64_t uMs, const PPDMAUDIOPCMPROPS pProps)
    12241226{
    12251227    AssertPtrReturn(pProps, 0);
     
    12281230        return 0;
    12291231
    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;
    12311234}
    12321235
     
    12381241 * @param   pProps              PCM properties to calculate amount of bytes for.
    12391242 */
    1240 uint32_t DrvAudioHlpNanoToBytes(uint32_t uNs, const PPDMAUDIOPCMPROPS pProps)
     1243uint32_t DrvAudioHlpNanoToBytes(uint64_t uNs, const PPDMAUDIOPCMPROPS pProps)
    12411244{
    12421245    AssertPtrReturn(pProps, 0);
     
    12451248        return 0;
    12461249
    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;
    12481252}
    12491253
     
    12551259 * @param   pProps              PCM properties to calculate amount of frames for.
    12561260 */
    1257 uint32_t DrvAudioHlpMilliToFrames(uint32_t uMs, const PPDMAUDIOPCMPROPS pProps)
     1261uint32_t DrvAudioHlpMilliToFrames(uint64_t uMs, const PPDMAUDIOPCMPROPS pProps)
    12581262{
    12591263    AssertPtrReturn(pProps, 0);
     
    12731277 * @param   pProps              PCM properties to calculate amount of frames for.
    12741278 */
    1275 uint32_t DrvAudioHlpNanoToFrames(uint32_t uNs, const PPDMAUDIOPCMPROPS pProps)
     1279uint32_t DrvAudioHlpNanoToFrames(uint64_t uNs, const PPDMAUDIOPCMPROPS pProps)
    12761280{
    12771281    AssertPtrReturn(pProps, 0);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette