VirtualBox

Changeset 73378 in vbox


Ignore:
Timestamp:
Jul 27, 2018 8:48:37 AM (6 years ago)
Author:
vboxsync
Message:

Audio/DrvAudioCommon.cpp: Fixes / docs for DrvAudioHlpClearBuf().

File:
1 edited

Legend:

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

    r73345 r73378  
    120120
    121121/**
    122  * Clears a sample buffer by the given amount of audio samples.
    123  *
    124  * @return  IPRT status code.
     122 * Clears a sample buffer by the given amount of audio frames with silence (according to the format
     123 * given by the PCM properties).
     124 *
    125125 * @param   pPCMProps               PCM properties to use for the buffer to clear.
    126126 * @param   pvBuf                   Buffer to clear.
    127127 * @param   cbBuf                   Size (in bytes) of the buffer.
    128  * @param   cSamples                Number of audio samples to clear in the buffer.
    129  */
    130 void DrvAudioHlpClearBuf(const PPDMAUDIOPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t cSamples)
     128 * @param   cFrames                 Number of audio frames to clear in the buffer.
     129 */
     130void DrvAudioHlpClearBuf(const PPDMAUDIOPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t cFrames)
    131131{
    132132    AssertPtrReturnVoid(pPCMProps);
    133133    AssertPtrReturnVoid(pvBuf);
    134134
    135     if (!cbBuf || !cSamples)
     135    if (!cbBuf || !cFrames)
    136136        return;
    137137
    138138    Assert(pPCMProps->cBits);
    139     size_t cbToClear = cSamples * (pPCMProps->cBits / 8 /* Bytes */);
     139    size_t cbToClear = DrvAudioHlpFramesToBytes(pPCMProps, cFrames);
    140140    Assert(cbBuf >= cbToClear);
    141141
     
    143143        cbToClear = cbBuf;
    144144
    145     Log2Func(("pPCMProps=%p, pvBuf=%p, cSamples=%RU32, fSigned=%RTbool, cBits=%RU8\n",
    146               pPCMProps, pvBuf, cSamples, pPCMProps->fSigned, pPCMProps->cBits));
     145    Log2Func(("pPCMProps=%p, pvBuf=%p, cFrames=%RU32, fSigned=%RTbool, cBits=%RU8\n",
     146              pPCMProps, pvBuf, cFrames, pPCMProps->fSigned, pPCMProps->cBits));
     147
     148    Assert(pPCMProps->fSwapEndian == false); /** @todo Swapping Endianness is not supported yet. */
    147149
    148150    if (pPCMProps->fSigned)
     
    163165            {
    164166                uint16_t *p = (uint16_t *)pvBuf;
    165                 int16_t   s = INT16_MAX;
    166 
    167                 if (pPCMProps->fSwapEndian)
    168                     s = RT_BSWAP_U16(s);
    169 
    170                 for (uint32_t i = 0; i < cSamples; i++)
     167                uint16_t  s = 0x8000;
     168
     169                for (uint32_t i = 0; i < DrvAudioHlpBytesToFrames(pPCMProps, (uint32_t)cbToClear); i++)
    171170                    p[i] = s;
    172171
    173172                break;
    174173            }
     174
     175            /** @todo Add 24 bit? */
    175176
    176177            case 32:
    177178            {
    178179                uint32_t *p = (uint32_t *)pvBuf;
    179                 int32_t   s = INT32_MAX;
    180 
    181                 if (pPCMProps->fSwapEndian)
    182                     s = RT_BSWAP_U32(s);
    183 
    184                 for (uint32_t i = 0; i < cSamples; i++)
     180                uint32_t  s = 0x80000000;
     181
     182                for (uint32_t i = 0; i < DrvAudioHlpBytesToFrames(pPCMProps, (uint32_t)cbToClear); i++)
    185183                    p[i] = s;
    186184
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