VirtualBox

Changeset 73207 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jul 18, 2018 2:56:36 PM (6 years ago)
Author:
vboxsync
Message:

Audio/DrvAudio: Implemented DrvAudioHlpBytesToFrames(), DrvAudioHlpFramesToBytes() and DrvAudioHlpPCMPropsBytesPerFrame().

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

Legend:

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

    r73097 r73207  
    154154uint32_t DrvAudioHlpCalcBitrate(uint8_t cBits, uint32_t uHz, uint8_t cChannels);
    155155uint32_t DrvAudioHlpCalcBitrate(const PPDMAUDIOPCMPROPS pProps);
     156uint32_t DrvAudioHlpBytesToFrames(const PPDMAUDIOPCMPROPS pProps, uint32_t cbBytes);
    156157uint64_t DrvAudioHlpBytesToMs(const PPDMAUDIOPCMPROPS pProps, size_t cbBytes);
     158uint32_t DrvAudioHlpFramesToBytes(const PPDMAUDIOPCMPROPS pProps, uint32_t cFrames);
    157159float DrvAudioHlpFramesToMs(const PPDMAUDIOPCMPROPS pProps, size_t cFrames);
    158160uint32_t DrvAudioHlpMsToBytes(const PPDMAUDIOPCMPROPS pProps, uint32_t uMs);
     
    161163bool DrvAudioHlpPCMPropsAreEqual(const PPDMAUDIOPCMPROPS pPCMProps, const PPDMAUDIOSTREAMCFG pCfg);
    162164bool DrvAudioHlpPCMPropsAreValid(const PPDMAUDIOPCMPROPS pProps);
     165uint32_t DrvAudioHlpPCMPropsBytesPerFrame(const PPDMAUDIOPCMPROPS pProps);
    163166void DrvAudioHlpPCMPropsPrint(const PPDMAUDIOPCMPROPS pProps);
    164167int DrvAudioHlpPCMPropsToStreamCfg(const PPDMAUDIOPCMPROPS pPCMProps, PPDMAUDIOSTREAMCFG pCfg);
  • trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp

    r73059 r73207  
    869869
    870870/**
     871 * Returns the bytes per frame for given PCM properties.
     872 *
     873 * @return Bytes per (audio) frame.
     874 * @param  pProps               PCM properties to retrieve bytes per frame for.
     875 */
     876uint32_t DrvAudioHlpPCMPropsBytesPerFrame(const PPDMAUDIOPCMPROPS pProps)
     877{
     878    return (pProps->cBits / 8) * pProps->cChannels;
     879}
     880
     881/**
    871882 * Prints PCM properties to the debug log.
    872883 *
     
    10531064
    10541065/**
     1066 * Returns the number of audio frames for a given amount of bytes.
     1067 *
     1068 * @return Calculated audio frames for given bytes.
     1069 * @param  pProps               PCM properties to calulate frames for.
     1070 * @param  cbBytes              Bytes to convert to audio frames.
     1071 */
     1072uint32_t DrvAudioHlpBytesToFrames(const PPDMAUDIOPCMPROPS pProps, uint32_t cbBytes)
     1073{
     1074    AssertPtrReturn(pProps, 0);
     1075
     1076    return cbBytes / ((pProps->cBits / 8) * pProps->cChannels);
     1077}
     1078
     1079/**
    10551080 * Returns the time (in ms) for given byte amount and PCM properties.
    10561081 *
     
    10721097
    10731098    return cbBytes / dbBytesPerMs;
     1099}
     1100
     1101/**
     1102 * Returns the bytes for a given audio frames amount and PCM properties.
     1103 *
     1104 * @return Calculated bytes for given audio frames.
     1105 * @param  pProps               PCM properties to calculate bytes for.
     1106 * @param  cFrames              Amount of audio frames to calculate bytes for.
     1107 */
     1108uint32_t DrvAudioHlpFramesToBytes(const PPDMAUDIOPCMPROPS pProps, uint32_t cFrames)
     1109{
     1110    AssertPtrReturn(pProps, 0);
     1111
     1112    if (!cFrames)
     1113        return 0;
     1114
     1115    return cFrames * ((pProps->cBits / 2) * pProps->cChannels);
    10741116}
    10751117
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