VirtualBox

Changeset 73532 in vbox for trunk/src


Ignore:
Timestamp:
Aug 6, 2018 5:27:41 PM (6 years ago)
Author:
vboxsync
Message:

Audio/DrvAudio: Few optimizations using the PDMAUDIOPCMPROPS_ macros.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp

    r73529 r73532  
    874874uint32_t DrvAudioHlpPCMPropsBytesPerFrame(const PPDMAUDIOPCMPROPS pProps)
    875875{
    876     return pProps->cBytes * pProps->cChannels;
     876    return PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */);
    877877}
    878878
     
    11371137        return 0;
    11381138
    1139     const uint32_t cbFrameSize = DrvAudioHlpPCMPropsBytesPerFrame(pProps);
    1140     return (cbSize / cbFrameSize) * cbFrameSize;
     1139    return PDMAUDIOPCMPROPS_B2F(pProps, cbSize) * PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */);
    11411140}
    11421141
     
    11551154        return true;
    11561155
    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 */
     1165DECLINLINE(uint64_t) drvAudioHlpBytesPerSec(const PPDMAUDIOPCMPROPS pProps)
     1166{
     1167    return PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */) * pProps->uHz;
    11581168}
    11591169
     
    11691179    AssertPtrReturn(pProps, 0);
    11701180
    1171     return cbBytes / (pProps->cBytes * pProps->cChannels);
     1181    return PDMAUDIOPCMPROPS_B2F(pProps, cbBytes);
    11721182}
    11731183
     
    11861196        return 0;
    11871197
    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;
    11901199    Assert(dbBytesPerMs >= 0.0f);
    11911200    if (!dbBytesPerMs) /* Prevent division by zero. */
     
    12091218        return 0;
    12101219
    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;
    12121221    Assert(dbBytesPerMs >= 0.0f);
    12131222    if (!dbBytesPerMs) /* Prevent division by zero. */
     
    12311240        return 0;
    12321241
    1233     return cFrames * pProps->cBytes * pProps->cChannels;
     1242    return cFrames * PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */);
    12341243}
    12351244
     
    12881297        return 0;
    12891298
    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;
    12921300}
    12931301
     
    13061314        return 0;
    13071315
    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;
    13101317}
    13111318
     
    13211328    AssertPtrReturn(pProps, 0);
    13221329
    1323     const uint32_t cbFrame = pProps->cBytes * pProps->cChannels;
     1330    const uint32_t cbFrame = PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */);
    13241331    if (!cbFrame) /* Prevent division by zero. */
    13251332        return 0;
     
    13391346    AssertPtrReturn(pProps, 0);
    13401347
    1341     const uint32_t cbFrame = pProps->cBytes * pProps->cChannels;
     1348    const uint32_t cbFrame = PDMAUDIOPCMPROPS_F2B(pProps, 1 /* Frame */);
    13421349    if (!cbFrame) /* Prevent division by zero. */
    13431350        return 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