VirtualBox

Ignore:
Timestamp:
Mar 8, 2021 5:50:57 PM (4 years ago)
Author:
vboxsync
Message:

Audio: Preparing to move some of the DrvAudio.h stuff into PDM. bugref:9890

File:
1 edited

Legend:

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

    r88017 r88022  
    801801{
    802802    AssertPtrReturn(pCfg, false);
    803     return DrvAudioHlpPcmPropsAreEqual(pProps, &pCfg->Props);
     803    return PDMAudioPropsAreEqual(pProps, &pCfg->Props);
    804804}
    805805
     
    997997 * @param   pProps              PCM properties to calculate bitrate for.
    998998 */
    999 uint32_t DrvAudioHlpGetBitrate(PCPDMAUDIOPCMPROPS pProps)
     999uint32_t PDMAudioPropsGetBitrate(PCPDMAUDIOPCMPROPS pProps)
    10001000{
    10011001    return DrvAudioHlpCalcBitrate(pProps->cbSample * 8, pProps->uHz, pProps->cChannels);
     
    10091009 * @param   cb          The size (in bytes) to round.
    10101010 */
    1011 uint32_t DrvAudioHlpFloorBytesToFrame(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)
     1011uint32_t PDMAudioPropsFloorBytesToFrame(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)
    10121012{
    10131013    AssertPtrReturn(pProps, 0);
     
    10221022 * @param   cb          The size (in bytes) to check.
    10231023 */
    1024 bool DrvAudioHlpIsBytesAligned(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)
     1024bool PDMAudioPropsIsSizeAligned(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)
    10251025{
    10261026    AssertPtrReturn(pProps, false);
     
    10371037 * @param   cb          The number of bytes to convert.
    10381038 */
    1039 uint32_t DrvAudioHlpBytesToFrames(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)
     1039uint32_t PDMAudioPropsBytesToFrames(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)
    10401040{
    10411041    AssertPtrReturn(pProps, 0);
     
    10521052 * @note    Rounds up the result.
    10531053 */
    1054 uint64_t DrvAudioHlpBytesToMilli(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)
     1054uint64_t PDMAudioPropsBytesToMilli(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)
    10551055{
    10561056    AssertPtrReturn(pProps, 0);
     
    10821082 * @note    Rounds up the result.
    10831083 */
    1084 uint64_t DrvAudioHlpBytesToMicro(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)
     1084uint64_t PDMAudioPropsBytesToMicro(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)
    10851085{
    10861086    AssertPtrReturn(pProps, 0);
     
    11121112 * @note    Rounds up the result.
    11131113 */
    1114 uint64_t DrvAudioHlpBytesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)
     1114uint64_t PDMAudioPropsBytesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cb)
    11151115{
    11161116    AssertPtrReturn(pProps, 0);
     
    11411141 * @sa      PDMAUDIOPCMPROPS_F2B
    11421142 */
    1143 uint32_t DrvAudioHlpFramesToBytes(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames)
     1143uint32_t PDMAudioPropsFramesToBytes(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames)
    11441144{
    11451145    AssertPtrReturn(pProps, 0);
     
    11551155 * @note    No rounding here, result is floored.
    11561156 */
    1157 uint64_t DrvAudioHlpFramesToMilli(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames)
     1157uint64_t PDMAudioPropsFramesToMilli(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames)
    11581158{
    11591159    AssertPtrReturn(pProps, 0);
     
    11741174 * @note    No rounding here, result is floored.
    11751175 */
    1176 uint64_t DrvAudioHlpFramesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames)
     1176uint64_t PDMAudioPropsFramesToNano(PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames)
    11771177{
    11781178    AssertPtrReturn(pProps, 0);
     
    11941194 * @note    The result is rounded rather than floored (hysterical raisins).
    11951195 */
    1196 uint32_t DrvAudioHlpMilliToFrames(PCPDMAUDIOPCMPROPS pProps, uint64_t cMs)
     1196uint32_t PDMAudioPropsMilliToFrames(PCPDMAUDIOPCMPROPS pProps, uint64_t cMs)
    11971197{
    11981198    AssertPtrReturn(pProps, 0);
     
    12201220 * @note    The result is rounded rather than floored (hysterical raisins).
    12211221 */
    1222 uint32_t DrvAudioHlpMilliToBytes(PCPDMAUDIOPCMPROPS pProps, uint64_t cMs)
    1223 {
    1224     return PDMAUDIOPCMPROPS_F2B(pProps, DrvAudioHlpMilliToFrames(pProps, cMs));
     1222uint32_t PDMAudioPropsMilliToBytes(PCPDMAUDIOPCMPROPS pProps, uint64_t cMs)
     1223{
     1224    return PDMAUDIOPCMPROPS_F2B(pProps, PDMAudioPropsMilliToFrames(pProps, cMs));
    12251225}
    12261226
     
    12341234 * @note    The result is rounded rather than floored (hysterical raisins).
    12351235 */
    1236 uint32_t DrvAudioHlpNanoToFrames(PCPDMAUDIOPCMPROPS pProps, uint64_t cNs)
     1236uint32_t PDMAudioPropsNanoToFrames(PCPDMAUDIOPCMPROPS pProps, uint64_t cNs)
    12371237{
    12381238    AssertPtrReturn(pProps, 0);
     
    12601260 * @note    The result is rounded rather than floored (hysterical raisins).
    12611261 */
    1262 uint32_t DrvAudioHlpNanoToBytes(PCPDMAUDIOPCMPROPS pProps, uint64_t cNs)
    1263 {
    1264     return PDMAUDIOPCMPROPS_F2B(pProps, DrvAudioHlpNanoToFrames(pProps, cNs));
     1262uint32_t PDMAudioPropsNanoToBytes(PCPDMAUDIOPCMPROPS pProps, uint64_t cNs)
     1263{
     1264    return PDMAUDIOPCMPROPS_F2B(pProps, PDMAudioPropsNanoToFrames(pProps, cNs));
    12651265}
    12661266
     
    12691269 * given by the PCM properties).
    12701270 *
    1271  * @param   pPCMProps               PCM properties to use for the buffer to clear.
    1272  * @param   pvBuf                   Buffer to clear.
    1273  * @param   cbBuf                   Size (in bytes) of the buffer.
    1274  * @param   cFrames                 Number of audio frames to clear in the buffer.
    1275  */
    1276 void DrvAudioHlpClearBuf(PCPDMAUDIOPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t cFrames)
     1271 * @param   pProps      The PCM properties to apply.
     1272 * @param   pvBuf       The buffer to clear.
     1273 * @param   cbBuf       The buffer size in bytes.
     1274 * @param   cFrames     The number of audio frames to clear.  Capped at @a cbBuf
     1275 *                      if exceeding the buffer.  If the size is an unaligned
     1276 *                      number of frames, the extra bytes may be left
     1277 *                      uninitialized in some configurations.
     1278 */
     1279void PDMAudioPropsClearBuffer(PCPDMAUDIOPCMPROPS pProps, void *pvBuf, size_t cbBuf, uint32_t cFrames)
    12771280{
    12781281    /*
    12791282     * Validate input
    12801283     */
    1281     AssertPtrReturnVoid(pPCMProps);
    1282     Assert(pPCMProps->cbSample);
     1284    AssertPtrReturnVoid(pProps);
     1285    Assert(pProps->cbSample);
    12831286    if (!cbBuf || !cFrames)
    12841287        return;
    12851288    AssertPtrReturnVoid(pvBuf);
    12861289
    1287     Assert(pPCMProps->fSwapEndian == false); /** @todo Swapping Endianness is not supported yet. */
     1290    Assert(pProps->fSwapEndian == false); /** @todo Swapping Endianness is not supported yet. */
    12881291
    12891292    /*
    12901293     * Decide how much needs clearing.
    12911294     */
    1292     size_t cbToClear = DrvAudioHlpFramesToBytes(pPCMProps, cFrames);
     1295    size_t cbToClear = PDMAudioPropsFramesToBytes(pProps, cFrames);
    12931296    AssertStmt(cbToClear <= cbBuf, cbToClear = cbBuf);
    12941297
    1295     Log2Func(("pPCMProps=%p, pvBuf=%p, cFrames=%RU32, fSigned=%RTbool, cBytes=%RU8\n",
    1296               pPCMProps, pvBuf, cFrames, pPCMProps->fSigned, pPCMProps->cbSample));
     1298    Log2Func(("pProps=%p, pvBuf=%p, cFrames=%RU32, fSigned=%RTbool, cBytes=%RU8\n",
     1299              pProps, pvBuf, cFrames, pProps->fSigned, pProps->cbSample));
    12971300
    12981301    /*
    12991302     * Do the job.
    13001303     */
    1301     if (pPCMProps->fSigned)
     1304    if (pProps->fSigned)
    13021305        RT_BZERO(pvBuf, cbToClear);
    13031306    else /* Unsigned formats. */
    13041307    {
    1305         switch (pPCMProps->cbSample)
     1308        switch (pProps->cbSample)
    13061309        {
    13071310            case 1: /* 8 bit */
     
    13251328
    13261329            default:
    1327                 AssertMsgFailed(("Invalid bytes per sample: %RU8\n", pPCMProps->cbSample));
     1330                AssertMsgFailed(("Invalid bytes per sample: %RU8\n", pProps->cbSample));
    13281331        }
    13291332    }
     
    13371340 * @param   pProps2     The second set of properties to compare.
    13381341 */
    1339 bool DrvAudioHlpPcmPropsAreEqual(PCPDMAUDIOPCMPROPS pProps1, PCPDMAUDIOPCMPROPS pProps2)
     1342bool PDMAudioPropsAreEqual(PCPDMAUDIOPCMPROPS pProps1, PCPDMAUDIOPCMPROPS pProps2)
    13401343{
    13411344    AssertPtrReturn(pProps1, false);
     
    14161419 * @sa      PDMAUDIOPCMPROPS_F2B
    14171420 */
    1418 uint32_t DrvAudioHlpBytesPerFrame(PCPDMAUDIOPCMPROPS pProps)
     1421uint32_t PDMAudioPropsBytesPerFrame(PCPDMAUDIOPCMPROPS pProps)
    14191422{
    14201423    return PDMAUDIOPCMPROPS_F2B(pProps, 1 /*cFrames*/);
     
    14261429 * @param   pProps              Stream configuration to log.
    14271430 */
    1428 void DrvAudioHlpPcmPropsLog(PCPDMAUDIOPCMPROPS pProps)
     1431void PDMAudioPropsLog(PCPDMAUDIOPCMPROPS pProps)
    14291432{
    14301433    AssertPtrReturnVoid(pProps);
     
    17141717            pData->Hdr.u16NumChannels   = pProps->cChannels;
    17151718            pData->Hdr.u32SampleRate    = pProps->uHz;
    1716             pData->Hdr.u32ByteRate      = DrvAudioHlpGetBitrate(pProps) / 8;
     1719            pData->Hdr.u32ByteRate      = PDMAudioPropsGetBitrate(pProps) / 8;
    17171720            pData->Hdr.u16BlockAlign    = pProps->cChannels * pProps->cbSample;
    17181721            pData->Hdr.u16BitsPerSample = pProps->cbSample * 8;
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