VirtualBox

Changeset 55920 in vbox for trunk


Ignore:
Timestamp:
May 18, 2015 7:11:51 PM (10 years ago)
Author:
vboxsync
Message:

PDM/Audio: AudioMixBuffer documentation, renaming.

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

Legend:

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

    r55852 r55920  
    8383
    8484
    85 /**   Logarithmic/exponential volume conversion table. */
    86 uint32_t aVolumeConv[256] = {
     85/** Logarithmic/exponential volume conversion table. */
     86static uint32_t s_aVolumeConv[256] = {
    8787        1,     1,     1,     1,     1,     1,     1,     1, /*   7 */
    8888        1,     2,     2,     2,     2,     2,     2,     2, /*  15 */
     
    120120
    121121/* Bit shift for fixed point conversion. */
    122 #define VOL_SHIFT       30
     122#define AUDIOMIXBUF_VOL_SHIFT       30
    123123
    124124/* Internal representation of 0dB volume (1.0 in fixed point). */
    125 #define VOL_0DB         (1 << VOL_SHIFT)
    126 
    127 AssertCompile(VOL_0DB <= 0x40000000);   /* Must always hold. */
    128 AssertCompile(VOL_0DB == 0x40000000);   /* For now -- when only attenuation is used. */
     125#define AUDIOMIXBUF_VOL_0DB         (1 << AUDIOMIXBUF_VOL_SHIFT)
     126
     127AssertCompile(AUDIOMIXBUF_VOL_0DB <= 0x40000000);   /* Must always hold. */
     128AssertCompile(AUDIOMIXBUF_VOL_0DB == 0x40000000);   /* For now -- when only attenuation is used. */
    129129
    130130/**
     
    155155#ifdef DEBUG
    156156static uint64_t s_cSamplesMixedTotal = 0;
     157static inline void audioMixBufPrint(PPDMAUDIOMIXBUF pMixBuf);
    157158#endif
    158 
    159 static void audioMixBufFreeBuf(PPDMAUDIOMIXBUF pMixBuf);
    160 static inline void audioMixBufPrint(PPDMAUDIOMIXBUF pMixBuf);
    161159
    162160typedef uint32_t (AUDMIXBUF_FN_CONVFROM) (PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, const PAUDMIXBUF_CONVOPTS pOpts);
     
    167165
    168166/* Can return VINF_TRY_AGAIN for getting next pointer at beginning (circular) */
    169 int audioMixBufAcquire(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamplesToRead,
     167
     168/**
     169 * Acquires (reads) a mutable pointer to the mixing buffer's audio samples without
     170 * any conversion done.
     171 ** @todo Rename to AudioMixBufPeek(Mutable/Raw)?
     172 ** @todo Protect the buffer's data?
     173 *
     174 * @return  IPRT status code.
     175 * @param   pMixBuf                 Mixing buffer to acquire audio samples from.
     176 * @param   cSamplesToRead          Number of audio samples to read.
     177 * @param   ppvSamples              Returns a mutable pointer to the buffer's audio sample data.
     178 * @param   pcSamplesRead           Number of audio samples read (acquired).
     179 *
     180 * @remark  This function is not thread safe!
     181 */
     182int AudioMixBufAcquire(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamplesToRead,
    170183                       PPDMAUDIOSAMPLE *ppvSamples, uint32_t *pcSamplesRead)
    171184{
     
    210223 * keeps track to eventually assigned children buffers.
    211224 *
    212  * @param   pMixBuf
    213  * @param   cSamplesToClear
    214  */
    215 void audioMixBufFinish(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamplesToClear)
     225 * @param   pMixBuf                 Mixing buffer to clear.
     226 * @param   cSamplesToClear         Number of audio samples to clear.
     227 */
     228void AudioMixBufFinish(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamplesToClear)
    216229{
    217230    AUDMIXBUF_LOG(("cSamples=%RU32\n", cSamplesToClear));
     
    255268}
    256269
    257 void audioMixBufDestroy(PPDMAUDIOMIXBUF pMixBuf)
     270/**
     271 * Destroys (uninitializes) a mixing buffer.
     272 *
     273 * @param   pMixBuf                 Mixing buffer to destroy.
     274 */
     275void AudioMixBufDestroy(PPDMAUDIOMIXBUF pMixBuf)
    258276{
    259277    if (!pMixBuf)
    260278        return;
    261279
    262     audioMixBufUnlink(pMixBuf);
     280    AudioMixBufUnlink(pMixBuf);
    263281
    264282    if (pMixBuf->pszName)
     
    276294    }
    277295
    278     audioMixBufFreeBuf(pMixBuf);
    279 }
    280 
    281 /** @todo Rename this function! Too confusing in combination with audioMixBufFreeBuf(). */
    282 uint32_t audioMixBufFree(PPDMAUDIOMIXBUF pMixBuf)
     296    if (pMixBuf->pSamples)
     297    {
     298        Assert(pMixBuf->cSamples);
     299
     300        RTMemFree(pMixBuf->pSamples);
     301        pMixBuf->pSamples = NULL;
     302    }
     303
     304    pMixBuf->cSamples = 0;
     305}
     306
     307/**
     308 * Returns the size (in audio samples) of free audio buffer space.
     309 *
     310 * @return  uint32_t                Size (in audio samples) of free audio buffer space.
     311 * @param   pMixBuf                 Mixing buffer to return free size for.
     312 */
     313uint32_t AudioMixBufFree(PPDMAUDIOMIXBUF pMixBuf)
    283314{
    284315    AssertPtrReturn(pMixBuf, 0);
    285316
    286     uint32_t cFree;
     317    uint32_t cSamplesFree;
    287318    if (pMixBuf->pParent)
    288319    {
     
    292323         */
    293324        Assert(pMixBuf->cMixed <= pMixBuf->pParent->cSamples);
    294         cFree = pMixBuf->pParent->cSamples - pMixBuf->cMixed;
    295     }
    296     else
    297         cFree = pMixBuf->cSamples - pMixBuf->cProcessed;
    298 
    299     AUDMIXBUF_LOG(("%s: cFree=%RU32\n", pMixBuf->pszName, cFree));
    300     return cFree;
    301 }
    302 
    303 uint32_t audioMixBufFreeBytes(PPDMAUDIOMIXBUF pMixBuf)
    304 {
    305     return AUDIOMIXBUF_S2B(pMixBuf, audioMixBufFree(pMixBuf));
    306 }
    307 
    308 static int audioMixBufAllocBuf(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamples)
     325        cSamplesFree = pMixBuf->pParent->cSamples - pMixBuf->cMixed;
     326    }
     327    else /* As a parent. */
     328    {
     329        Assert(pMixBuf->cSamples >= pMixBuf->cProcessed);
     330        cSamplesFree = pMixBuf->cSamples - pMixBuf->cProcessed;
     331    }
     332
     333    AUDMIXBUF_LOG(("%s: cSamplesFree=%RU32\n", pMixBuf->pszName, cSamplesFree));
     334    return cSamplesFree;
     335}
     336
     337/**
     338 * Returns the size (in bytes) of free audio buffer space.
     339 *
     340 * @return  uint32_t                Size (in bytes) of free audio buffer space.
     341 * @param   pMixBuf                 Mixing buffer to return free size for.
     342 */
     343uint32_t AudioMixBufFreeBytes(PPDMAUDIOMIXBUF pMixBuf)
     344{
     345    return AUDIOMIXBUF_S2B(pMixBuf, AudioMixBufFree(pMixBuf));
     346}
     347
     348/**
     349 * Allocates the internal audio sample buffer.
     350 *
     351 * @return  IPRT status code.
     352 * @param   pMixBuf                 Mixing buffer to allocate sample buffer for.
     353 * @param   cSamples                Number of audio samples to allocate.
     354 */
     355static int audioMixBufAlloc(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamples)
    309356{
    310357    AssertPtrReturn(pMixBuf, VERR_INVALID_POINTER);
     
    376423        { \
    377424            AUDMIXBUF_MACRO_LOG(("%p: l=%RI16, r=%RI16\n", paDst, *pSrc, *(pSrc + 1))); \
    378             paDst->i64LSample = ASMMult2xS32RetS64((int32_t)audioMixBufClipFrom##_aName(*pSrc++), pOpts->Volume.uLeft ) >> VOL_SHIFT; \
    379             paDst->i64RSample = ASMMult2xS32RetS64((int32_t)audioMixBufClipFrom##_aName(*pSrc++), pOpts->Volume.uRight) >> VOL_SHIFT; \
     425            paDst->i64LSample = ASMMult2xS32RetS64((int32_t)audioMixBufClipFrom##_aName(*pSrc++), pOpts->Volume.uLeft ) >> AUDIOMIXBUF_VOL_SHIFT; \
     426            paDst->i64RSample = ASMMult2xS32RetS64((int32_t)audioMixBufClipFrom##_aName(*pSrc++), pOpts->Volume.uRight) >> AUDIOMIXBUF_VOL_SHIFT; \
    380427            AUDMIXBUF_MACRO_LOG(("\t-> l=%RI64, r=%RI64\n", paDst->i64LSample, paDst->i64RSample)); \
    381428            paDst++; \
     
    395442        { \
    396443            AUDMIXBUF_MACRO_LOG(("%p: s=%RI16\n", paDst, *pSrc)); \
    397             paDst->i64LSample = ASMMult2xS32RetS64((int32_t)audioMixBufClipFrom##_aName(*pSrc), pOpts->Volume.uLeft) >> VOL_SHIFT; \
    398             paDst->i64RSample = ASMMult2xS32RetS64((int32_t)audioMixBufClipFrom##_aName(*pSrc), pOpts->Volume.uRight) >> VOL_SHIFT; \
     444            paDst->i64LSample = ASMMult2xS32RetS64((int32_t)audioMixBufClipFrom##_aName(*pSrc), pOpts->Volume.uLeft)  >> AUDIOMIXBUF_VOL_SHIFT; \
     445            paDst->i64RSample = ASMMult2xS32RetS64((int32_t)audioMixBufClipFrom##_aName(*pSrc), pOpts->Volume.uRight) >> AUDIOMIXBUF_VOL_SHIFT; \
    399446            ++pSrc; \
    400447            AUDMIXBUF_MACRO_LOG(("\t-> l=%RI64, r=%RI64\n", paDst->i64LSample, paDst->i64RSample)); \
     
    570617
    571618/**
     619 * Looks up the matching conversion (macro) routine for converting
     620 * audio samples from a source format.
    572621 *
    573622 ** @todo Speed up the lookup by binding it to the actual stream state.
    574623 *
    575  * @return  PAUDMIXBUF_FN_CONVFROM
    576  * @param   enmFmt      The source audio stream format
    577  * @param   fMuted      Flag determining whether the source is muted
     624 * @return  PAUDMIXBUF_FN_CONVFROM  Function pointer to conversion macro if found, NULL if not supported.
     625 * @param   enmFmt                  Audio format to lookup conversion macro for.
     626 * @param   fMuted                  Flag determining whether the source is muted.
    578627 */
    579628static inline PAUDMIXBUF_FN_CONVFROM audioMixBufConvFromLookup(PDMAUDIOMIXBUFFMT enmFmt, bool fMuted)
     
    633682
    634683/**
     684 * Looks up the matching conversion (macro) routine for converting
     685 * audio samples to a destination format.
    635686 *
    636687 ** @todo Speed up the lookup by binding it to the actual stream state.
    637688 *
    638  * @return  PAUDMIXBUF_FN_CONVTO
    639  * @param   enmFmt
     689 * @return  PAUDMIXBUF_FN_CONVTO    Function pointer to conversion macro if found, NULL if not supported.
     690 * @param   enmFmt                  Audio format to lookup conversion macro for.
    640691 */
    641692static inline PAUDMIXBUF_FN_CONVTO audioMixBufConvToLookup(PDMAUDIOMIXBUFFMT enmFmt)
     
    691742}
    692743
    693 static void audioMixBufFreeBuf(PPDMAUDIOMIXBUF pMixBuf)
    694 {
    695     if (pMixBuf)
    696     {
    697         if (pMixBuf->pSamples)
    698         {
    699             RTMemFree(pMixBuf->pSamples);
    700             pMixBuf->pSamples = NULL;
    701         }
    702 
    703         pMixBuf->cSamples = 0;
    704     }
    705 }
    706 
    707 int audioMixBufInit(PPDMAUDIOMIXBUF pMixBuf, const char *pszName, PPDMPCMPROPS pProps, uint32_t cSamples)
     744/**
     745 * Initializes a mixing buffer.
     746 *
     747 * @return  IPRT status code.
     748 * @param   pMixBuf                 Mixing buffer to initialize.
     749 * @param   pszName                 Name of mixing buffer for easier identification. Optional.
     750 * @param   pProps                  PCM audio properties to use for the mixing buffer.
     751 * @param   cSamples                Maximum number of audio samples the mixing buffer can hold.
     752 */
     753int AudioMixBufInit(PPDMAUDIOMIXBUF pMixBuf, const char *pszName, PPDMPCMPROPS pProps, uint32_t cSamples)
    708754{
    709755    AssertPtrReturn(pMixBuf, VERR_INVALID_POINTER);
     
    723769    /* Set initial volume to max. */
    724770    pMixBuf->Volume.fMuted = false;
    725     pMixBuf->Volume.uLeft  = VOL_0DB;
    726     pMixBuf->Volume.uRight = VOL_0DB;
     771    pMixBuf->Volume.uLeft  = AUDIOMIXBUF_VOL_0DB;
     772    pMixBuf->Volume.uRight = AUDIOMIXBUF_VOL_0DB;
    727773
    728774    /* Prevent division by zero.
     
    748794                   RT_BOOL(AUDMIXBUF_FMT_SIGNED(pMixBuf->AudioFmt))));
    749795
    750     return audioMixBufAllocBuf(pMixBuf, cSamples);
    751 }
    752 
    753 bool audioMixBufIsEmpty(PPDMAUDIOMIXBUF pMixBuf)
     796    return audioMixBufAlloc(pMixBuf, cSamples);
     797}
     798
     799/**
     800 * Returns @true if there are any audio samples available for processing,
     801 * @false if not.
     802 *
     803 * @return  bool                    @true if there are any audio samples available for processing, @false if not.
     804 * @param   pMixBuf                 Mixing buffer to return value for.
     805 */
     806bool AudioMixBufIsEmpty(PPDMAUDIOMIXBUF pMixBuf)
    754807{
    755808    AssertPtrReturn(pMixBuf, true);
     
    760813}
    761814
    762 int audioMixBufLinkTo(PPDMAUDIOMIXBUF pMixBuf, PPDMAUDIOMIXBUF pParent)
     815/**
     816 * Links an audio mixing buffer to a parent mixing buffer. A parent mixing
     817 * buffer can have multiple children mixing buffers [1:N], whereas a child only can
     818 * have one parent mixing buffer [N:1].
     819 *
     820 * The mixing direction always goes from the child/children buffer(s) to the
     821 * parent buffer.
     822 *
     823 * For guest audio output the host backend owns the parent mixing buffer, the
     824 * device emulation owns the child/children.
     825 *
     826 * The audio format of each mixing buffer can vary; the internal mixing code
     827 * then will autiomatically do the (needed) conversion.
     828 *
     829 * @return  IPRT status code.
     830 * @param   pMixBuf                 Mixing buffer to link parent to.
     831 * @param   pParent                 Parent mixing buffer to use for linking.
     832 *
     833 * @remark  Circular linking is not allowed.
     834 */
     835int AudioMixBufLinkTo(PPDMAUDIOMIXBUF pMixBuf, PPDMAUDIOMIXBUF pParent)
    763836{
    764837    AssertPtrReturn(pMixBuf, VERR_INVALID_POINTER);
     
    847920}
    848921
    849 uint32_t audioMixBufMixed(PPDMAUDIOMIXBUF pMixBuf)
     922/**
     923 * Returns the number of audio samples mixed (processed) from
     924 * the parent mixing buffer.
     925 *
     926 * @return  uint32_t                Number of audio samples mixed (processed).
     927 * @param   pMixBuf                 Mixing buffer to return number from.
     928 */
     929uint32_t AudioMixBufMixed(PPDMAUDIOMIXBUF pMixBuf)
    850930{
    851931    AssertPtrReturn(pMixBuf, 0);
     
    859939}
    860940
     941/**
     942 * Mixes audio samples from a source mixing buffer to a destination mixing buffer.
     943 *
     944 * @return  IPRT status code.
     945 * @param   pDst                    Destination mixing buffer.
     946 * @param   pSrc                    Source mixing buffer.
     947 * @param   cSamples                Number of source audio samples to mix.
     948 * @param   pcProcessed             Number of audio samples successfully mixed.
     949 */
    861950static int audioMixBufMixTo(PPDMAUDIOMIXBUF pDst, PPDMAUDIOMIXBUF pSrc, uint32_t cSamples, uint32_t *pcProcessed)
    862951{
     
    9421031}
    9431032
    944 int audioMixBufMixToChildren(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamples,
     1033/**
     1034 * Mixes (multiplexes) audio samples to all connected mixing buffer children.
     1035 *
     1036 * @return  IPRT status code.
     1037 * @param   pMixBuf                 Mixing buffer to use.
     1038 * @param   cSamples                Number of audio samples to mix to children.
     1039 * @param   pcProcessed             Maximum number of audio samples successfully mixed
     1040 *                                  to all children. Optional.
     1041 */
     1042int AudioMixBufMixToChildren(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamples,
    9451043                             uint32_t *pcProcessed)
    9461044{
     1045    AssertPtrReturn(pMixBuf, VERR_INVALID_POINTER);
     1046
     1047    if (!cSamples)
     1048    {
     1049        if (pcProcessed)
     1050            *pcProcessed = 0;
     1051        return VINF_SUCCESS;
     1052    }
     1053
    9471054    int rc = VINF_SUCCESS;
    9481055
     
    9661073}
    9671074
    968 int audioMixBufMixToParent(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamples,
     1075/**
     1076 * Mixes audio samples down to the parent mixing buffer.
     1077 *
     1078 * @return  IPRT status code.
     1079 * @param   pMixBuf                 Mixing buffer to mix samples down to parent.
     1080 * @param   cSamples                Number of audio samples to mix down.
     1081 * @param   pcProcessed             Number of audio samples successfully processed. Optional.
     1082 */
     1083int AudioMixBufMixToParent(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamples,
    9691084                           uint32_t *pcProcessed)
    9701085{
     
    9761091}
    9771092
     1093#ifdef DEBUG
     1094/**
     1095 * Prints statistics and status of a mixing buffer to the logger.
     1096 * For debug versions only.
     1097 *
     1098 * @return  IPRT status code.
     1099 * @param   pMixBuf                 Mixing buffer to print.
     1100 */
    9781101static inline void audioMixBufPrint(PPDMAUDIOMIXBUF pMixBuf)
    9791102{
    980 #ifdef DEBUG_DISABLED
    9811103    PPDMAUDIOMIXBUF pParent = pMixBuf;
    9821104    if (pMixBuf->pParent)
     
    9991121    AUDMIXBUF_LOG(("Total samples mixed: %RU64\n", s_cSamplesMixedTotal));
    10001122    AUDMIXBUF_LOG(("********************************************\n"));
     1123}
    10011124#endif
    1002 }
    10031125
    10041126/**
     
    10081130 * @param   pMixBuf
    10091131 */
    1010 uint32_t audioMixBufProcessed(PPDMAUDIOMIXBUF pMixBuf)
     1132uint32_t AudioMixBufProcessed(PPDMAUDIOMIXBUF pMixBuf)
    10111133{
    10121134    AssertPtrReturn(pMixBuf, 0);
     
    10161138}
    10171139
    1018 int audioMixBufReadAt(PPDMAUDIOMIXBUF pMixBuf,
     1140/**
     1141 * Reads audio samples at a specific offset.
     1142 *
     1143 * @return  IPRT status code.
     1144 * @param   pMixBuf                 Mixing buffer to read audio samples from.
     1145 * @param   offSamples              Offset (in audio samples) to start reading from.
     1146 * @param   pvBuf                   Pointer to buffer to write output to.
     1147 * @param   cbBuf                   Size (in bytes) of buffer to write to.
     1148 * @param   pcbRead                 Size (in bytes) of data read. Optional.
     1149 */
     1150int AudioMixBufReadAt(PPDMAUDIOMIXBUF pMixBuf,
    10191151                      uint32_t offSamples,
    10201152                      void *pvBuf, uint32_t cbBuf,
    10211153                      uint32_t *pcbRead)
    10221154{
    1023     return audioMixBufReadAtEx(pMixBuf, pMixBuf->AudioFmt,
     1155    return AudioMixBufReadAtEx(pMixBuf, pMixBuf->AudioFmt,
    10241156                               offSamples, pvBuf, cbBuf, pcbRead);
    10251157}
    10261158
    1027 int audioMixBufReadAtEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt,
     1159/**
     1160 * Reads audio samples at a specific offset.
     1161 * If the audio format of the mixing buffer and the requested audio format do
     1162 * not match the output will be converted accordingly.
     1163 *
     1164 * @return  IPRT status code.
     1165 * @param   pMixBuf                 Mixing buffer to read audio samples from.
     1166 * @param   enmFmt                  Audio format to use for output.
     1167 * @param   offSamples              Offset (in audio samples) to start reading from.
     1168 * @param   pvBuf                   Pointer to buffer to write output to.
     1169 * @param   cbBuf                   Size (in bytes) of buffer to write to.
     1170 * @param   pcbRead                 Size (in bytes) of data read. Optional.
     1171 */
     1172int AudioMixBufReadAtEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt,
    10281173                        uint32_t offSamples,
    10291174                        void *pvBuf, uint32_t cbBuf,
     
    10581203            rc = VERR_INVALID_PARAMETER;
    10591204
     1205#ifdef DEBUG
    10601206        audioMixBufPrint(pMixBuf);
     1207#endif
    10611208    }
    10621209    else
     
    10731220}
    10741221
    1075 int audioMixBufReadCirc(PPDMAUDIOMIXBUF pMixBuf,
     1222/**
     1223 * Reads audio samples. The audio format of the mixing buffer will be used.
     1224 *
     1225 * @return  IPRT status code.
     1226 * @param   pMixBuf                 Mixing buffer to read audio samples from.
     1227 * @param   pvBuf                   Pointer to buffer to write output to.
     1228 * @param   cbBuf                   Size (in bytes) of buffer to write to.
     1229 * @param   pcRead                  Number of audio samples read. Optional.
     1230 */
     1231int AudioMixBufReadCirc(PPDMAUDIOMIXBUF pMixBuf,
    10761232                        void *pvBuf, uint32_t cbBuf, uint32_t *pcRead)
    10771233{
    1078     return audioMixBufReadCircEx(pMixBuf, pMixBuf->AudioFmt,
     1234    return AudioMixBufReadCircEx(pMixBuf, pMixBuf->AudioFmt,
    10791235                                 pvBuf, cbBuf, pcRead);
    10801236}
    10811237
    1082 int audioMixBufReadCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt,
     1238/**
     1239 * Reads audio samples in a specific audio format.
     1240 * If the audio format of the mixing buffer and the requested audio format do
     1241 * not match the output will be converted accordingly.
     1242 *
     1243 * @return  IPRT status code.
     1244 * @param   pMixBuf                 Mixing buffer to read audio samples from.
     1245 * @param   enmFmt                  Audio format to use for output.
     1246 * @param   pvBuf                   Pointer to buffer to write output to.
     1247 * @param   cbBuf                   Size (in bytes) of buffer to write to.
     1248 * @param   pcRead                  Number of audio samples read. Optional.
     1249 */
     1250int AudioMixBufReadCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt,
    10831251                          void *pvBuf, uint32_t cbBuf, uint32_t *pcRead)
    10841252{
     
    10981266    if (!cToRead)
    10991267    {
     1268#ifdef DEBUG
    11001269        audioMixBufPrint(pMixBuf);
    1101 
     1270#endif
    11021271        if (pcRead)
    11031272            *pcRead = 0;
     
    11801349    }
    11811350
     1351#ifdef DEBUG
    11821352    audioMixBufPrint(pMixBuf);
     1353#endif
    11831354
    11841355    AUDMIXBUF_LOG(("cRead=%RU32 (%zu bytes), rc=%Rrc\n",
     
    11881359}
    11891360
    1190 void audioMixBufReset(PPDMAUDIOMIXBUF pMixBuf)
     1361/**
     1362 * Resets a mixing buffer.
     1363 *
     1364 * @param   pMixBuf                 Mixing buffer to reset.
     1365 */
     1366void AudioMixBufReset(PPDMAUDIOMIXBUF pMixBuf)
    11911367{
    11921368    AssertPtrReturnVoid(pMixBuf);
     
    12021378}
    12031379
    1204 void audioMixBufSetVolume(PPDMAUDIOMIXBUF pMixBuf, PPDMAUDIOVOLUME pVol)
     1380/**
     1381 * Sets the overall (master) volume.
     1382 *
     1383 * @param   pMixBuf                 Mixing buffer to set volume for.
     1384 * @param   pVol                    Pointer to volume structure to set.
     1385 */
     1386void AudioMixBufSetVolume(PPDMAUDIOMIXBUF pMixBuf, PPDMAUDIOVOLUME pVol)
    12051387{
    12061388    AssertPtrReturnVoid(pMixBuf);
     
    12101392
    12111393    pMixBuf->Volume.fMuted = pVol->fMuted;
    1212     //@todo: Ensure that the input is in the correct range/initialized!
    1213     pMixBuf->Volume.uLeft  = aVolumeConv[pVol->uLeft  & 0xFF] * (VOL_0DB >> 16);
    1214     pMixBuf->Volume.uRight = aVolumeConv[pVol->uRight & 0xFF] * (VOL_0DB >> 16);
     1394    /** @todo Ensure that the input is in the correct range/initialized! */
     1395    pMixBuf->Volume.uLeft  = s_aVolumeConv[pVol->uLeft  & 0xFF] * (AUDIOMIXBUF_VOL_0DB >> 16);
     1396    pMixBuf->Volume.uRight = s_aVolumeConv[pVol->uRight & 0xFF] * (AUDIOMIXBUF_VOL_0DB >> 16);
    12151397
    12161398    LogFlowFunc(("\t-> lVol=%#RX32, rVol=%#RX32\n", pMixBuf->Volume.uLeft, pMixBuf->Volume.uRight));
    12171399}
    12181400
    1219 uint32_t audioMixBufSize(PPDMAUDIOMIXBUF pMixBuf)
    1220 {
     1401/**
     1402 * Returns the maximum amount of audio samples this buffer can hold.
     1403 *
     1404 * @return  uint32_t                Size (in audio samples) the mixing buffer can hold.
     1405 * @param   pMixBuf                 Mixing buffer to retrieve maximum for.
     1406 */
     1407uint32_t AudioMixBufSize(PPDMAUDIOMIXBUF pMixBuf)
     1408{
     1409    AssertPtrReturn(pMixBuf, 0);
    12211410    return pMixBuf->cSamples;
    12221411}
     
    12251414 * Returns the maximum amount of bytes this buffer can hold.
    12261415 *
    1227  * @return  uint32_t
    1228  * @param   pMixBuf
    1229  */
    1230 uint32_t audioMixBufSizeBytes(PPDMAUDIOMIXBUF pMixBuf)
    1231 {
     1416 * @return  uint32_t                Size (in bytes) the mixing buffer can hold.
     1417 * @param   pMixBuf                 Mixing buffer to retrieve maximum for.
     1418 */
     1419uint32_t AudioMixBufSizeBytes(PPDMAUDIOMIXBUF pMixBuf)
     1420{
     1421    AssertPtrReturn(pMixBuf, 0);
    12321422    return AUDIOMIXBUF_S2B(pMixBuf, pMixBuf->cSamples);
    12331423}
    12341424
    1235 void audioMixBufUnlink(PPDMAUDIOMIXBUF pMixBuf)
     1425/**
     1426 * Unlinks a mixing buffer from its parent, if any.
     1427 *
     1428 * @return  IPRT status code.
     1429 * @param   pMixBuf                 Mixing buffer to unlink from parent.
     1430 */
     1431void AudioMixBufUnlink(PPDMAUDIOMIXBUF pMixBuf)
    12361432{
    12371433    if (!pMixBuf || !pMixBuf->pszName)
     
    12491445        /* Make sure to reset the parent mixing buffer each time it gets linked
    12501446         * to a new child. */
    1251         audioMixBufReset(pMixBuf->pParent);
     1447        AudioMixBufReset(pMixBuf->pParent);
    12521448        pMixBuf->pParent = NULL;
    12531449    }
     
    12601456        AUDMIXBUF_LOG(("\tUnlinking \"%s\"\n", pIter->pszName));
    12611457
    1262         audioMixBufReset(pIter->pParent);
     1458        AudioMixBufReset(pIter->pParent);
    12631459        pIter->pParent = NULL;
    12641460
     
    12751471}
    12761472
    1277 int audioMixBufWriteAt(PPDMAUDIOMIXBUF pMixBuf,
     1473/**
     1474 * Writes audio samples at a specific offset.
     1475 * The sample format being written must match the format of the mixing buffer.
     1476 *
     1477 * @return  IPRT status code.
     1478 * @param   pMixBuf                 Pointer to mixing buffer to write to.
     1479 * @param   enmFmt                  Audio format supplied in the buffer.
     1480 * @param   offSamples              Offset (in samples) starting to write at.
     1481 * @param   pvBuf                   Pointer to audio buffer to be written.
     1482 * @param   cbBuf                   Size (in bytes) of audio buffer.
     1483 * @param   pcWritten               Returns number of audio samples written. Optional.
     1484 */
     1485int AudioMixBufWriteAt(PPDMAUDIOMIXBUF pMixBuf,
    12781486                       uint32_t offSamples,
    12791487                       const void *pvBuf, uint32_t cbBuf,
    12801488                       uint32_t *pcWritten)
    12811489{
    1282     return audioMixBufWriteAtEx(pMixBuf, pMixBuf->AudioFmt,
     1490    return AudioMixBufWriteAtEx(pMixBuf, pMixBuf->AudioFmt,
    12831491                                offSamples, pvBuf, cbBuf, pcWritten);
    12841492}
    12851493
    12861494/**
    1287  * TODO
     1495 * Writes audio samples at a specific offset. The audio sample format
     1496 * to be written can be different from the audio format the mixing buffer
     1497 * operates on.
    12881498 *
    12891499 * @return  IPRT status code.
    1290  * @return  int
    1291  * @param   pMixBuf
    1292  * @param   enmFmt
    1293  * @param   offSamples
    1294  * @param   pvBuf
    1295  * @param   cbBuf
    1296  * @param   pcWritten           Returns number of samples written. Optional.
    1297  */
    1298 int audioMixBufWriteAtEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt,
     1500 * @param   pMixBuf                 Pointer to mixing buffer to write to.
     1501 * @param   enmFmt                  Audio format supplied in the buffer.
     1502 * @param   offSamples              Offset (in samples) starting to write at.
     1503 * @param   pvBuf                   Pointer to audio buffer to be written.
     1504 * @param   cbBuf                   Size (in bytes) of audio buffer.
     1505 * @param   pcWritten               Returns number of audio samples written. Optional.
     1506 */
     1507int AudioMixBufWriteAtEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt,
    12991508                         uint32_t offSamples,
    13001509                         const void *pvBuf, uint32_t cbBuf,
     
    13421551
    13431552        cWritten = pConv(pMixBuf->pSamples + offSamples, pvBuf, cbBuf, &convOpts);
     1553#ifdef DEBUG
    13441554        audioMixBufPrint(pMixBuf);
    1345 
     1555#endif
    13461556        rc = cWritten ? VINF_SUCCESS : VERR_GENERAL_FAILURE; /** @todo Fudge! */
    13471557    }
     
    13621572}
    13631573
    1364 int audioMixBufWriteCirc(PPDMAUDIOMIXBUF pMixBuf,
     1574/**
     1575 * Writes audio samples. The sample format being written must match the
     1576 * format of the mixing buffer.
     1577 *
     1578 * @return  IPRT status code.
     1579 * @param   pMixBuf                 Pointer to mixing buffer to write to.
     1580 * @param   pvBuf                   Pointer to audio buffer to be written.
     1581 * @param   cbBuf                   Size (in bytes) of audio buffer.
     1582 * @param   pcWritten               Returns number of audio samples written. Optional.
     1583 */
     1584int AudioMixBufWriteCirc(PPDMAUDIOMIXBUF pMixBuf,
    13651585                         const void *pvBuf, uint32_t cbBuf,
    13661586                         uint32_t *pcWritten)
    13671587{
    1368     return audioMixBufWriteCircEx(pMixBuf, pMixBuf->AudioFmt, pvBuf, cbBuf, pcWritten);
    1369 }
    1370 
    1371 int audioMixBufWriteCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt,
     1588    return AudioMixBufWriteCircEx(pMixBuf, pMixBuf->AudioFmt, pvBuf, cbBuf, pcWritten);
     1589}
     1590
     1591/**
     1592 * Writes audio samples of a specific format.
     1593 *
     1594 * @return  IPRT status code.
     1595 * @param   pMixBuf                 Pointer to mixing buffer to write to.
     1596 * @param   enmFmt                  Audio format supplied in the buffer.
     1597 * @param   pvBuf                   Pointer to audio buffer to be written.
     1598 * @param   cbBuf                   Size (in bytes) of audio buffer.
     1599 * @param   pcWritten               Returns number of audio samples written. Optional.
     1600 */
     1601int AudioMixBufWriteCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt,
    13721602                           const void *pvBuf, uint32_t cbBuf,
    13731603                           uint32_t *pcWritten)
     
    14781708    }
    14791709
     1710#ifdef DEBUG
    14801711    audioMixBufPrint(pMixBuf);
     1712#endif
    14811713
    14821714    AUDMIXBUF_LOG(("cWritten=%RU32 (%zu bytes), rc=%Rrc\n",
     
    14851717    return rc;
    14861718}
     1719
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.h

    r55340 r55920  
    11/* $Id$ */
    22/** @file
    3  * VBox audio: TODO
     3 * VBox audio: Mixing buffer to convert audio samples to/from different
     4 *             rates / formats.
    45 */
    56
     
    4950
    5051
    51 int audioMixBufAcquire(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamplesToRead, PPDMAUDIOSAMPLE *ppvSamples, uint32_t *pcSamplesRead);
    52 inline uint32_t audioMixBufBytesToSamples(PPDMAUDIOMIXBUF pMixBuf);
    53 void audioMixBufDestroy(PPDMAUDIOMIXBUF pMixBuf);
    54 void audioMixBufFinish(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamplesToClear);
    55 uint32_t audioMixBufFree(PPDMAUDIOMIXBUF pMixBuf);
    56 uint32_t audioMixBufFreeBytes(PPDMAUDIOMIXBUF pMixBuf);
    57 int audioMixBufInit(PPDMAUDIOMIXBUF pMixBuf, const char *pszName, PPDMPCMPROPS pProps, uint32_t cSamples);
    58 bool audioMixBufIsEmpty(PPDMAUDIOMIXBUF pMixBuf);
    59 int audioMixBufLinkTo(PPDMAUDIOMIXBUF pMixBuf, PPDMAUDIOMIXBUF pParent);
    60 uint32_t audioMixBufMixed(PPDMAUDIOMIXBUF pMixBuf);
    61 int audioMixBufMixToChildren(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamples, uint32_t *pcProcessed);
    62 int audioMixBufMixToParent(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamples, uint32_t *pcProcessed);
    63 uint32_t audioMixBufProcessed(PPDMAUDIOMIXBUF pMixBuf);
    64 int audioMixBufReadAt(PPDMAUDIOMIXBUF pMixBuf, uint32_t offSamples, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead);
    65 int audioMixBufReadAtEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt, uint32_t offSamples, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead);
    66 int audioMixBufReadCirc(PPDMAUDIOMIXBUF pMixBuf, void *pvBuf, uint32_t cbBuf, uint32_t *pcRead);
    67 int audioMixBufReadCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt, void *pvBuf, uint32_t cbBuf, uint32_t *pcRead);
    68 void audioMixBufReset(PPDMAUDIOMIXBUF pMixBuf);
    69 void audioMixBufSetVolume(PPDMAUDIOMIXBUF pMixBuf, PPDMAUDIOVOLUME pVol);
    70 uint32_t audioMixBufSize(PPDMAUDIOMIXBUF pMixBuf);
    71 uint32_t audioMixBufSizeBytes(PPDMAUDIOMIXBUF pMixBuf);
    72 void audioMixBufUnlink(PPDMAUDIOMIXBUF pMixBuf);
    73 int audioMixBufWriteAt(PPDMAUDIOMIXBUF pMixBuf, uint32_t offSamples, const void *pvBuf, uint32_t cbBuf, uint32_t *pcWritten);
    74 int audioMixBufWriteAtEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt, uint32_t offSamples, const void *pvBuf, uint32_t cbBuf, uint32_t *pcWritten);
    75 int audioMixBufWriteCirc(PPDMAUDIOMIXBUF pMixBuf, const void *pvBuf, uint32_t cbBuf, uint32_t *pcWritten);
    76 int audioMixBufWriteCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt, const void *pvBuf, uint32_t cbBuf, uint32_t *pcWritten);
     52int AudioMixBufAcquire(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamplesToRead, PPDMAUDIOSAMPLE *ppvSamples, uint32_t *pcSamplesRead);
     53inline uint32_t AudioMixBufBytesToSamples(PPDMAUDIOMIXBUF pMixBuf);
     54void AudioMixBufDestroy(PPDMAUDIOMIXBUF pMixBuf);
     55void AudioMixBufFinish(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamplesToClear);
     56uint32_t AudioMixBufFree(PPDMAUDIOMIXBUF pMixBuf);
     57uint32_t AudioMixBufFreeBytes(PPDMAUDIOMIXBUF pMixBuf);
     58int AudioMixBufInit(PPDMAUDIOMIXBUF pMixBuf, const char *pszName, PPDMPCMPROPS pProps, uint32_t cSamples);
     59bool AudioMixBufIsEmpty(PPDMAUDIOMIXBUF pMixBuf);
     60int AudioMixBufLinkTo(PPDMAUDIOMIXBUF pMixBuf, PPDMAUDIOMIXBUF pParent);
     61uint32_t AudioMixBufMixed(PPDMAUDIOMIXBUF pMixBuf);
     62int AudioMixBufMixToChildren(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamples, uint32_t *pcProcessed);
     63int AudioMixBufMixToParent(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamples, uint32_t *pcProcessed);
     64uint32_t AudioMixBufProcessed(PPDMAUDIOMIXBUF pMixBuf);
     65int AudioMixBufReadAt(PPDMAUDIOMIXBUF pMixBuf, uint32_t offSamples, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead);
     66int AudioMixBufReadAtEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt, uint32_t offSamples, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead);
     67int AudioMixBufReadCirc(PPDMAUDIOMIXBUF pMixBuf, void *pvBuf, uint32_t cbBuf, uint32_t *pcRead);
     68int AudioMixBufReadCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt, void *pvBuf, uint32_t cbBuf, uint32_t *pcRead);
     69void AudioMixBufReset(PPDMAUDIOMIXBUF pMixBuf);
     70void AudioMixBufSetVolume(PPDMAUDIOMIXBUF pMixBuf, PPDMAUDIOVOLUME pVol);
     71uint32_t AudioMixBufSize(PPDMAUDIOMIXBUF pMixBuf);
     72uint32_t AudioMixBufSizeBytes(PPDMAUDIOMIXBUF pMixBuf);
     73void AudioMixBufUnlink(PPDMAUDIOMIXBUF pMixBuf);
     74int AudioMixBufWriteAt(PPDMAUDIOMIXBUF pMixBuf, uint32_t offSamples, const void *pvBuf, uint32_t cbBuf, uint32_t *pcWritten);
     75int AudioMixBufWriteAtEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt, uint32_t offSamples, const void *pvBuf, uint32_t cbBuf, uint32_t *pcWritten);
     76int AudioMixBufWriteCirc(PPDMAUDIOMIXBUF pMixBuf, const void *pvBuf, uint32_t cbBuf, uint32_t *pcWritten);
     77int AudioMixBufWriteCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt, const void *pvBuf, uint32_t cbBuf, uint32_t *pcWritten);
    7778
    7879#endif /* AUDIO_MIXBUF_H */
  • trunk/src/VBox/Devices/Audio/AudioMixer.cpp

    r55387 r55920  
    4141
    4242
    43 int audioMixerAddSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PAUDMIXSINK *ppSink)
     43int AudioMixerAddSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PAUDMIXSINK *ppSink)
    4444{
    4545    AssertPtrReturn(pMixer, VERR_INVALID_POINTER);
     
    8686}
    8787
    88 int audioMixerAddStreamIn(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOGSTSTRMIN pStream,
     88int AudioMixerAddStreamIn(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOGSTSTRMIN pStream,
    8989                          uint32_t uFlags, PAUDMIXSTREAM *ppStream)
    9090{
     
    124124}
    125125
    126 int audioMixerAddStreamOut(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOGSTSTRMOUT pStream,
     126int AudioMixerAddStreamOut(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOGSTSTRMOUT pStream,
    127127                           uint32_t uFlags, PAUDMIXSTREAM *ppStream)
    128128{
     
    162162}
    163163
    164 int audioMixerControlStream(PAUDIOMIXER pMixer, PAUDMIXSTREAM pHandle)
     164int AudioMixerControlStream(PAUDIOMIXER pMixer, PAUDMIXSTREAM pHandle)
    165165{
    166166    return VERR_NOT_IMPLEMENTED;
    167167}
    168168
    169 int audioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer)
     169int AudioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer)
    170170{
    171171    AssertPtrReturn(pszName, VERR_INVALID_POINTER);
     
    205205}
    206206
    207 void audioMixerDestroy(PAUDIOMIXER pMixer)
     207void AudioMixerDestroy(PAUDIOMIXER pMixer)
    208208{
    209209    if (pMixer)
     
    217217            bool fLast = RTListNodeIsLast(&pMixer->lstSinks, &pSink->Node);
    218218
    219             audioMixerRemoveSink(pMixer, pSink);
     219            AudioMixerRemoveSink(pMixer, pSink);
    220220
    221221            if (fLast)
     
    253253}
    254254
    255 uint32_t audioMixerGetStreamCount(PAUDIOMIXER pMixer)
     255uint32_t AudioMixerGetStreamCount(PAUDIOMIXER pMixer)
    256256{
    257257    AssertPtrReturn(pMixer, 0);
     
    266266}
    267267
    268 void audioMixerInvalidate(PAUDIOMIXER pMixer)
     268void AudioMixerInvalidate(PAUDIOMIXER pMixer)
    269269{
    270270    AssertPtrReturnVoid(pMixer);
     
    281281}
    282282
    283 int audioMixerProcessSinkIn(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, uint32_t cbBuf, uint32_t *pcbProcessed)
     283int AudioMixerProcessSinkIn(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, uint32_t cbBuf, uint32_t *pcbProcessed)
    284284{
    285285    AssertPtrReturn(pSink, VERR_INVALID_POINTER);
     
    344344}
    345345
    346 int audioMixerProcessSinkOut(PAUDMIXSINK pSink, AUDMIXOP enmOp, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbProcessed)
     346int AudioMixerProcessSinkOut(PAUDMIXSINK pSink, AUDMIXOP enmOp, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbProcessed)
    347347{
    348348    return VERR_NOT_IMPLEMENTED;
    349349}
    350350
    351 void audioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink)
     351void AudioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink)
    352352{
    353353    AssertPtrReturnVoid(pMixer);
     
    361361        bool fLast = RTListNodeIsLast(&pSink->lstStreams, &pStream->Node);
    362362
    363         audioMixerRemoveStream(pSink, pStream);
     363        AudioMixerRemoveStream(pSink, pStream);
    364364
    365365        if (fLast)
     
    381381}
    382382
    383 void audioMixerRemoveStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream)
     383void AudioMixerRemoveStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream)
    384384{
    385385    AssertPtrReturnVoid(pSink);
     
    400400}
    401401
    402 int audioMixerSetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg)
     402int AudioMixerSetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg)
    403403{
    404404    AssertPtrReturn(pMixer, VERR_INVALID_POINTER);
     
    438438    {
    439439        if (fOut)
    440             audioMixBufSetVolume(&pStream->pOut->MixBuf, &volSink);
     440            AudioMixBufSetVolume(&pStream->pOut->MixBuf, &volSink);
    441441        else
    442             audioMixBufSetVolume(&pStream->pIn->MixBuf,  &volSink);
     442            AudioMixBufSetVolume(&pStream->pIn->MixBuf,  &volSink);
    443443    }
    444444
     
    447447
    448448/** Set the master volume of the mixer. */
    449 int audioMixerSetMasterVolume(PAUDIOMIXER pMixer, PPDMAUDIOVOLUME pVol)
     449int AudioMixerSetMasterVolume(PAUDIOMIXER pMixer, PPDMAUDIOVOLUME pVol)
    450450{
    451451    AssertPtrReturn(pMixer, VERR_INVALID_POINTER);
     
    458458                 pMixer->VolMaster.fMuted, pMixer->VolMaster.uLeft, pMixer->VolMaster.uRight));
    459459
    460     audioMixerInvalidate(pMixer);
     460    AudioMixerInvalidate(pMixer);
    461461    return VINF_SUCCESS;
    462462}
    463463
    464464/** Set the volume of an individual sink. */
    465 int audioMixerSetSinkVolume(PAUDMIXSINK pSink, PPDMAUDIOVOLUME pVol)
     465int AudioMixerSetSinkVolume(PAUDMIXSINK pSink, PPDMAUDIOVOLUME pVol)
    466466{
    467467    AssertPtrReturn(pSink, VERR_INVALID_POINTER);
  • trunk/src/VBox/Devices/Audio/AudioMixer.h

    r55340 r55920  
    9292
    9393
    94 int audioMixerAddSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PAUDMIXSINK *ppSink);
    95 int audioMixerAddStreamIn(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOGSTSTRMIN pStream, uint32_t uFlags, PAUDMIXSTREAM *ppStream);
    96 int audioMixerAddStreamOut(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOGSTSTRMOUT pStream, uint32_t uFlags, PAUDMIXSTREAM *ppStream);
    97 int audioMixerControlStream(AUDMIXSTREAM pHandle); /** @todo Implement me. */
    98 int audioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer);
    99 void audioMixerDestroy(PAUDIOMIXER pMixer);
    100 uint32_t audioMixerGetStreamCount(PAUDIOMIXER pMixer);
    101 void audioMixerInvalidate(PAUDIOMIXER pMixer);
    102 int audioMixerProcessSinkIn(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, uint32_t cbBuf, uint32_t *pcbProcessed);
    103 int audioMixerProcessSinkOut(PAUDMIXSINK pSink, AUDMIXOP enmOp, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbProcessed);
    104 void audioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink);
    105 void audioMixerRemoveStream(PAUDMIXSINK pMixer, PAUDMIXSTREAM pStream);
    106 int audioMixerSetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg);
    107 int audioMixerSetMasterVolume(PAUDIOMIXER pMixer, PPDMAUDIOVOLUME pVol);
    108 int audioMixerSetSinkVolume(PAUDMIXSINK pSink, PPDMAUDIOVOLUME pVol);
     94int AudioMixerAddSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PAUDMIXSINK *ppSink);
     95int AudioMixerAddStreamIn(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOGSTSTRMIN pStream, uint32_t uFlags, PAUDMIXSTREAM *ppStream);
     96int AudioMixerAddStreamOut(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOGSTSTRMOUT pStream, uint32_t uFlags, PAUDMIXSTREAM *ppStream);
     97int AudioMixerControlStream(AUDMIXSTREAM pHandle); /** @todo Implement me. */
     98int AudioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer);
     99void AudioMixerDestroy(PAUDIOMIXER pMixer);
     100uint32_t AudioMixerGetStreamCount(PAUDIOMIXER pMixer);
     101void AudioMixerInvalidate(PAUDIOMIXER pMixer);
     102int AudioMixerProcessSinkIn(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, uint32_t cbBuf, uint32_t *pcbProcessed);
     103int AudioMixerProcessSinkOut(PAUDMIXSINK pSink, AUDMIXOP enmOp, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbProcessed);
     104void AudioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink);
     105void AudioMixerRemoveStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream);
     106int AudioMixerSetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg);
     107int AudioMixerSetMasterVolume(PAUDIOMIXER pMixer, PPDMAUDIOVOLUME pVol);
     108int AudioMixerSetSinkVolume(PAUDMIXSINK pSink, PPDMAUDIOVOLUME pVol);
    109109
    110110#endif /* AUDIO_MIXER_H */
  • trunk/src/VBox/Devices/Audio/DevIchAc97.cpp

    r55430 r55920  
    582582                    if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
    583583                    {
    584                         audioMixerRemoveStream(pThis->pSinkLineIn, pDrv->LineIn.phStrmIn);
    585                         rc = audioMixerAddStreamIn(pThis->pSinkLineIn,
     584                        AudioMixerRemoveStream(pThis->pSinkLineIn, pDrv->LineIn.phStrmIn);
     585                        rc = AudioMixerAddStreamIn(pThis->pSinkLineIn,
    586586                                                   pDrv->pConnector, pDrv->LineIn.pStrmIn,
    587587                                                   0 /* uFlags */,
     
    609609                    if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
    610610                    {
    611                         audioMixerRemoveStream(pThis->pSinkOutput, pDrv->Out.phStrmOut);
    612                         rc = audioMixerAddStreamOut(pThis->pSinkOutput,
     611                        AudioMixerRemoveStream(pThis->pSinkOutput, pDrv->Out.phStrmOut);
     612                        rc = AudioMixerAddStreamOut(pThis->pSinkOutput,
    613613                                                    pDrv->pConnector, pDrv->Out.pStrmOut,
    614614                                                    0 /* uFlags */,
     
    637637                    if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
    638638                    {
    639                         audioMixerRemoveStream(pThis->pSinkMicIn, pDrv->MicIn.phStrmIn);
    640                         rc = audioMixerAddStreamIn(pThis->pSinkMicIn,
     639                        AudioMixerRemoveStream(pThis->pSinkMicIn, pDrv->MicIn.phStrmIn);
     640                        rc = AudioMixerAddStreamIn(pThis->pSinkMicIn,
    641641                                                   pDrv->pConnector, pDrv->MicIn.pStrmIn,
    642642                                                   0 /* uFlags */,
     
    665665                {
    666666                    pDrv->pConnector->pfnCloseIn(pDrv->pConnector, pDrv->LineIn.pStrmIn);
    667                     audioMixerRemoveStream(pThis->pSinkLineIn, pDrv->LineIn.phStrmIn);
     667                    AudioMixerRemoveStream(pThis->pSinkLineIn, pDrv->LineIn.phStrmIn);
    668668
    669669                    pDrv->LineIn.pStrmIn  = NULL;
     
    680680                {
    681681                    pDrv->pConnector->pfnCloseOut(pDrv->pConnector, pDrv->Out.pStrmOut);
    682                     audioMixerRemoveStream(pThis->pSinkOutput, pDrv->Out.phStrmOut);
     682                    AudioMixerRemoveStream(pThis->pSinkOutput, pDrv->Out.phStrmOut);
    683683
    684684                    pDrv->Out.pStrmOut  = NULL;
     
    695695                {
    696696                    pDrv->pConnector->pfnCloseIn(pDrv->pConnector, pDrv->MicIn.pStrmIn);
    697                     audioMixerRemoveStream(pThis->pSinkMicIn, pDrv->MicIn.phStrmIn);
     697                    AudioMixerRemoveStream(pThis->pSinkMicIn, pDrv->MicIn.phStrmIn);
    698698
    699699                    pDrv->MicIn.pStrmIn  = NULL;
     
    713713    }
    714714
    715     audioMixerInvalidate(pThis->pMixer);
     715    AudioMixerInvalidate(pThis->pMixer);
    716716#else
    717717    if (freq)
     
    863863        {
    864864            case PDMAUDIOMIXERCTL_VOLUME:
    865                 audioMixerSetMasterVolume(pThis->pMixer, &vol);
     865                AudioMixerSetMasterVolume(pThis->pMixer, &vol);
    866866                break;
    867867
    868868            case PDMAUDIOMIXERCTL_PCM:
    869                 audioMixerSetSinkVolume(pThis->pSinkOutput, &vol);
     869                AudioMixerSetSinkVolume(pThis->pSinkOutput, &vol);
    870870                break;
    871871
    872872            case PDMAUDIOMIXERCTL_MIC_IN:
    873                 audioMixerSetSinkVolume(pThis->pSinkMicIn, &vol);
     873                AudioMixerSetSinkVolume(pThis->pSinkMicIn, &vol);
    874874                break;
    875875
    876876            case PDMAUDIOMIXERCTL_LINE_IN:
    877                 audioMixerSetSinkVolume(pThis->pSinkLineIn, &vol);
     877                AudioMixerSetSinkVolume(pThis->pSinkLineIn, &vol);
    878878                break;
    879879
     
    982982    if (pThis->pMixer)
    983983    {
    984         audioMixerDestroy(pThis->pMixer);
     984        AudioMixerDestroy(pThis->pMixer);
    985985        pThis->pMixer = NULL;
    986986    }
    987987
    988     int rc2 = audioMixerCreate("AC'97 Mixer", 0 /* uFlags */, &pThis->pMixer);
     988    int rc2 = AudioMixerCreate("AC'97 Mixer", 0 /* uFlags */, &pThis->pMixer);
    989989    if (RT_SUCCESS(rc2))
    990990    {
     
    996996        streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;
    997997
    998         rc2 = audioMixerSetDeviceFormat(pThis->pMixer, &streamCfg);
     998        rc2 = AudioMixerSetDeviceFormat(pThis->pMixer, &streamCfg);
    999999        AssertRC(rc2);
    10001000
    10011001        /* Add all required audio sinks. */
    1002         rc2 = audioMixerAddSink(pThis->pMixer, "[Playback] PCM Output",
     1002        rc2 = AudioMixerAddSink(pThis->pMixer, "[Playback] PCM Output",
    10031003                               AUDMIXSINKDIR_OUTPUT, &pThis->pSinkOutput);
    10041004        AssertRC(rc2);
    10051005
    1006         rc2 = audioMixerAddSink(pThis->pMixer, "[Recording] Line In",
     1006        rc2 = AudioMixerAddSink(pThis->pMixer, "[Recording] Line In",
    10071007                                AUDMIXSINKDIR_INPUT, &pThis->pSinkLineIn);
    10081008        AssertRC(rc2);
    10091009
    1010         rc2 = audioMixerAddSink(pThis->pMixer, "[Recording] Microphone In",
     1010        rc2 = AudioMixerAddSink(pThis->pMixer, "[Recording] Microphone In",
    10111011                                AUDMIXSINKDIR_INPUT, &pThis->pSinkMicIn);
    10121012        AssertRC(rc2);
     
    12431243    if (pvMixBuf)
    12441244    {
    1245         rc = audioMixerProcessSinkIn(pSink, AUDMIXOP_BLEND, pvMixBuf, cbToRead, &cbRead);
     1245        rc = AudioMixerProcessSinkIn(pSink, AUDMIXOP_BLEND, pvMixBuf, cbToRead, &cbRead);
    12461246        if (   RT_SUCCESS(rc)
    12471247            && cbRead)
     
    22062206    if (pThis->pMixer)
    22072207    {
    2208         audioMixerDestroy(pThis->pMixer);
     2208        AudioMixerDestroy(pThis->pMixer);
    22092209        pThis->pMixer = NULL;
    22102210    }
  • trunk/src/VBox/Devices/Audio/DevIchHda.cpp

    r55828 r55920  
    22102210    {
    22112211        uint32_t cbRead = 0;
    2212         rc = audioMixerProcessSinkIn(pSink, AUDMIXOP_BLEND, pBdle->au8HdaBuffer, cb2Copy, &cbRead);
     2212        rc = AudioMixerProcessSinkIn(pSink, AUDMIXOP_BLEND, pBdle->au8HdaBuffer, cb2Copy, &cbRead);
    22132213        if (RT_SUCCESS(rc))
    22142214        {
     
    24752475        if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
    24762476        {
    2477             audioMixerRemoveStream(pSink, pDrv->LineIn.phStrmIn);
    2478             rc = audioMixerAddStreamIn(pSink,
     2477            AudioMixerRemoveStream(pSink, pDrv->LineIn.phStrmIn);
     2478            rc = AudioMixerAddStreamIn(pSink,
    24792479                                       pDrv->pConnector, pDrv->LineIn.pStrmIn,
    24802480                                       0 /* uFlags */, &pDrv->LineIn.phStrmIn);
     
    25072507        if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
    25082508        {
    2509             audioMixerRemoveStream(pThis->pSinkOutput, pDrv->Out.phStrmOut);
    2510             rc = audioMixerAddStreamOut(pThis->pSinkOutput,
     2509            AudioMixerRemoveStream(pThis->pSinkOutput, pDrv->Out.phStrmOut);
     2510            rc = AudioMixerAddStreamOut(pThis->pSinkOutput,
    25112511                                        pDrv->pConnector, pDrv->Out.pStrmOut,
    25122512                                        0 /* uFlags */, &pDrv->Out.phStrmOut);
     
    25432543
    25442544    /* Set the volume. Codec already converted it to the correct range. */
    2545     audioMixerSetSinkVolume(pSink, &vol);
     2545    AudioMixerSetSinkVolume(pSink, &vol);
    25462546
    25472547    LogFlowFuncLeaveRC(rc);
     
    35893589    if (pThis->pMixer)
    35903590    {
    3591         audioMixerDestroy(pThis->pMixer);
     3591        AudioMixerDestroy(pThis->pMixer);
    35923592        pThis->pMixer = NULL;
    35933593    }
     
    38583858    if (RT_SUCCESS(rc))
    38593859    {
    3860         rc = audioMixerCreate("HDA Mixer", 0 /* uFlags */, &pThis->pMixer);
     3860        rc = AudioMixerCreate("HDA Mixer", 0 /* uFlags */, &pThis->pMixer);
    38613861        if (RT_SUCCESS(rc))
    38623862        {
     
    38683868            streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;
    38693869
    3870             rc = audioMixerSetDeviceFormat(pThis->pMixer, &streamCfg);
     3870            rc = AudioMixerSetDeviceFormat(pThis->pMixer, &streamCfg);
    38713871            AssertRC(rc);
    38723872
    38733873            /* Add all required audio sinks. */
    3874             rc = audioMixerAddSink(pThis->pMixer, "[Playback] PCM Output",
     3874            rc = AudioMixerAddSink(pThis->pMixer, "[Playback] PCM Output",
    38753875                                   AUDMIXSINKDIR_OUTPUT, &pThis->pSinkOutput);
    38763876            AssertRC(rc);
    38773877
    3878             rc = audioMixerAddSink(pThis->pMixer, "[Recording] Line In",
     3878            rc = AudioMixerAddSink(pThis->pMixer, "[Recording] Line In",
    38793879                                   AUDMIXSINKDIR_INPUT, &pThis->pSinkLineIn);
    38803880            AssertRC(rc);
    38813881
    3882             rc = audioMixerAddSink(pThis->pMixer, "[Recording] Microphone In",
     3882            rc = AudioMixerAddSink(pThis->pMixer, "[Recording] Microphone In",
    38833883                                   AUDMIXSINKDIR_INPUT, &pThis->pSinkMicIn);
    38843884            AssertRC(rc);
     
    38863886            /* There is no master volume control. Set the master to max. */
    38873887            PDMAUDIOVOLUME vol = { false, 255, 255 };
    3888             rc = audioMixerSetMasterVolume(pThis->pMixer, &vol);
     3888            rc = AudioMixerSetMasterVolume(pThis->pMixer, &vol);
    38893889            AssertRC(rc);
    38903890        }
  • trunk/src/VBox/Devices/Audio/DevSB16.cpp

    r55908 r55920  
    10751075    uint8_t rvol = sb16MixRegToVol(pThis, 0x31);
    10761076    PDMAUDIOVOLUME vol = { false, lvol, rvol };
    1077     audioMixerSetMasterVolume(pThis->pMixer, &vol);
     1077    AudioMixerSetMasterVolume(pThis->pMixer, &vol);
    10781078#else
    10791079    int     mute = 0;
     
    10921092    uint8_t rvol = sb16MixRegToVol(pThis, 0x33);
    10931093    PDMAUDIOVOLUME vol = { false, lvol, rvol };
    1094     audioMixerSetSinkVolume(pThis->pSinkOutput, &vol);
     1094    AudioMixerSetSinkVolume(pThis->pSinkOutput, &vol);
    10951095#else
    10961096    int     mute = 0;
     
    13481348    if (pThis->pMixer)
    13491349    {
    1350         audioMixerDestroy(pThis->pMixer);
     1350        AudioMixerDestroy(pThis->pMixer);
    13511351        pThis->pMixer = NULL;
    13521352    }
     
    13831383
    13841384#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    1385     int rc2 = audioMixerCreate("SB16 Mixer", 0 /* uFlags */, &pThis->pMixer);
     1385    int rc2 = AudioMixerCreate("SB16 Mixer", 0 /* uFlags */, &pThis->pMixer);
    13861386    if (RT_SUCCESS(rc2))
    13871387    {
     
    13931393        streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;
    13941394
    1395         rc2 = audioMixerSetDeviceFormat(pThis->pMixer, &streamCfg);
     1395        rc2 = AudioMixerSetDeviceFormat(pThis->pMixer, &streamCfg);
    13961396        AssertRC(rc2);
    13971397
    13981398        /* Add all required audio sinks. */
    1399         rc2 = audioMixerAddSink(pThis->pMixer, "[Playback] PCM Output",
     1399        rc2 = AudioMixerAddSink(pThis->pMixer, "[Playback] PCM Output",
    14001400                                AUDMIXSINKDIR_OUTPUT, &pThis->pSinkOutput);
    14011401        AssertRC(rc2);
     
    21192119        if (rc2 == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
    21202120        {
    2121             audioMixerRemoveStream(pThis->pSinkOutput, pDrv->Out.phStrmOut);
    2122             rc = audioMixerAddStreamOut(pThis->pSinkOutput,
     2121            AudioMixerRemoveStream(pThis->pSinkOutput, pDrv->Out.phStrmOut);
     2122            rc = AudioMixerAddStreamOut(pThis->pSinkOutput,
    21232123                                        pDrv->pConnector, pDrv->Out.pStrmOut,
    21242124                                        0 /* uFlags */,
     
    21382138    }
    21392139    /* Ensure volume gets propagated. */
    2140     audioMixerInvalidate(pThis->pMixer);
     2140    AudioMixerInvalidate(pThis->pMixer);
    21412141
    21422142    return rc;
     
    22062206    if (pThis->pMixer)
    22072207    {
    2208         audioMixerDestroy(pThis->pMixer);
     2208        AudioMixerDestroy(pThis->pMixer);
    22092209        pThis->pMixer = NULL;
    22102210    }
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r55355 r55920  
    490490            return VERR_NO_MEMORY;
    491491
    492         rc = audioMixBufInit(&pGstStrmOut->MixBuf, pszTemp, &pGstStrmOut->Props, audioMixBufSize(&pHostStrmOut->MixBuf));
     492        rc = AudioMixBufInit(&pGstStrmOut->MixBuf, pszTemp, &pGstStrmOut->Props, AudioMixBufSize(&pHostStrmOut->MixBuf));
    493493        if (RT_SUCCESS(rc))
    494             rc = audioMixBufLinkTo(&pGstStrmOut->MixBuf, &pHostStrmOut->MixBuf);
     494            rc = AudioMixBufLinkTo(&pGstStrmOut->MixBuf, &pHostStrmOut->MixBuf);
    495495
    496496        RTStrFree(pszTemp);
     
    564564        }
    565565
    566         rc = audioMixBufInit(&pHstStrmOut->MixBuf, pszTemp, &pHstStrmOut->Props, cSamples);
     566        rc = AudioMixBufInit(&pHstStrmOut->MixBuf, pszTemp, &pHstStrmOut->Props, cSamples);
    567567        if (RT_SUCCESS(rc))
    568568        {
     
    742742            return VERR_NO_MEMORY;
    743743
    744         rc = audioMixBufInit(&pGstStrmIn->MixBuf, pszTemp, &pGstStrmIn->Props, audioMixBufSize(&pHstStrmIn->MixBuf));
     744        rc = AudioMixBufInit(&pGstStrmIn->MixBuf, pszTemp, &pGstStrmIn->Props, AudioMixBufSize(&pHstStrmIn->MixBuf));
    745745        if (RT_SUCCESS(rc))
    746             rc = audioMixBufLinkTo(&pHstStrmIn->MixBuf, &pGstStrmIn->MixBuf);
     746            rc = AudioMixBufLinkTo(&pHstStrmIn->MixBuf, &pGstStrmIn->MixBuf);
    747747
    748748        RTStrFree(pszTemp);
     
    816816        }
    817817
    818         rc = audioMixBufInit(&pHstStrmIn->MixBuf, pszTemp, &pHstStrmIn->Props, cSamples);
     818        rc = AudioMixBufInit(&pHstStrmIn->MixBuf, pszTemp, &pHstStrmIn->Props, cSamples);
    819819        if (RT_SUCCESS(rc))
    820820        {
     
    885885     */
    886886    uint32_t cWritten;
    887     int rc = audioMixBufWriteAt(&pGstStrmOut->MixBuf, 0 /* Offset in samples */, pvBuf, cbBuf, &cWritten);
     887    int rc = AudioMixBufWriteAt(&pGstStrmOut->MixBuf, 0 /* Offset in samples */, pvBuf, cbBuf, &cWritten);
    888888
    889889    /*
     
    895895        && cWritten)
    896896    {
    897         rc = audioMixBufMixToParent(&pGstStrmOut->MixBuf, cWritten, &cMixed);
     897        rc = AudioMixBufMixToParent(&pGstStrmOut->MixBuf, cWritten, &cMixed);
    898898    }
    899899    else
     
    10781078                 * so that it can start writing PCM data to us. */
    10791079                cbFree2 = RT_MIN(cbFree2, AUDIOMIXBUF_S2B_RATIO(&pGstStrmOut->MixBuf,
    1080                                                                 audioMixBufFree(&pGstStrmOut->MixBuf)));
     1080                                                                AudioMixBufFree(&pGstStrmOut->MixBuf)));
    10811081
    10821082                LogFlowFunc(("\t[%s] cbFree=%RU32\n", pGstStrmOut->MixBuf.pszName, cbFree2));
     
    11081108        {
    11091109            cbAvailIn = RT_MAX(cbAvailIn, AUDIOMIXBUF_S2B(&pHstStrmIn->MixBuf,
    1110                                                           audioMixBufMixed(&pHstStrmIn->MixBuf)));
     1110                                                          AudioMixBufMixed(&pHstStrmIn->MixBuf)));
    11111111
    11121112            LogFlowFunc(("\t[%s] cbFree=%RU32\n", pHstStrmIn->MixBuf.pszName, cbAvailIn));
     
    11941194                continue;
    11951195
    1196             if (audioMixBufIsEmpty(&pGstStrmOut->MixBuf))
     1196            if (AudioMixBufIsEmpty(&pGstStrmOut->MixBuf))
    11971197            {
    11981198                pGstStrmOut->State.fEmpty = true;
     
    14281428     */
    14291429    uint32_t cRead;
    1430     int rc = audioMixBufReadCirc(&pGstStrmIn->MixBuf,
     1430    int rc = AudioMixBufReadCirc(&pGstStrmIn->MixBuf,
    14311431                                 pvBuf, cbBuf, &cRead);
    14321432    if (RT_SUCCESS(rc))
    14331433    {
    1434         audioMixBufFinish(&pGstStrmIn->MixBuf, cRead);
     1434        AudioMixBufFinish(&pGstStrmIn->MixBuf, cRead);
    14351435
    14361436        if (pcbRead)
  • trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp

    r55335 r55920  
    147147    }
    148148
    149     audioMixBufDestroy(&pGstStrmIn->MixBuf);
     149    AudioMixBufDestroy(&pGstStrmIn->MixBuf);
    150150}
    151151
     
    153153{
    154154    AssertPtrReturnVoid(pHstStrmIn);
    155     audioMixBufDestroy(&pHstStrmIn->MixBuf);
     155    AudioMixBufDestroy(&pHstStrmIn->MixBuf);
    156156}
    157157
     
    167167    }
    168168
    169     audioMixBufDestroy(&pGstStrmOut->MixBuf);
     169    AudioMixBufDestroy(&pGstStrmOut->MixBuf);
    170170}
    171171
     
    226226{
    227227    AssertPtrReturnVoid(pHstStrmOut);
    228     audioMixBufDestroy(&pHstStrmOut->MixBuf);
     228    AudioMixBufDestroy(&pHstStrmOut->MixBuf);
    229229}
    230230
     
    438438            || !pGstStrmOut->State.fEmpty)
    439439        {
    440             cSamples = audioMixBufMixed(&pGstStrmOut->MixBuf);
     440            cSamples = AudioMixBufMixed(&pGstStrmOut->MixBuf);
    441441            cMinSamplesMixed = RT_MIN(cMinSamplesMixed, cSamples);
    442442
     
    473473    {
    474474        if (   cSamplesMin == UINT32_MAX
    475             || cSamplesMin > audioMixBufSize(&pHstStrmOut->MixBuf))
     475            || cSamplesMin > AudioMixBufSize(&pHstStrmOut->MixBuf))
    476476        {
    477477            LogFlowFunc(("Error: cSamplesMin=%RU32\n", cSamplesMin));
  • trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp

    r55335 r55920  
    801801        {
    802802            case SND_PCM_STATE_PREPARED:
    803                 cAvail = audioMixBufFree(&pHstStrmIn->MixBuf);
     803                cAvail = AudioMixBufFree(&pHstStrmIn->MixBuf);
    804804                break;
    805805
     
    882882        {
    883883            uint32_t cWritten;
    884             rc = audioMixBufWriteCirc(&pHstStrmIn->MixBuf,
     884            rc = AudioMixBufWriteCirc(&pHstStrmIn->MixBuf,
    885885                                      pThisStrmIn->pvBuf, AUDIOMIXBUF_S2B(&pHstStrmIn->MixBuf, cRead),
    886886                                      &cWritten);
     
    900900        uint32_t cProcessed = 0;
    901901        if (cWrittenTotal)
    902             rc = audioMixBufMixToParent(&pHstStrmIn->MixBuf, cWrittenTotal,
     902            rc = AudioMixBufMixToParent(&pHstStrmIn->MixBuf, cWrittenTotal,
    903903                                        &cProcessed);
    904904
     
    946946        while (cbToRead)
    947947        {
    948             rc = audioMixBufReadCirc(&pHstStrmOut->MixBuf, pThisStrmOut->pvBuf, cbToRead, &cRead);
     948            rc = AudioMixBufReadCirc(&pHstStrmOut->MixBuf, pThisStrmOut->pvBuf, cbToRead, &cRead);
    949949            if (RT_FAILURE(rc))
    950950                break;
     
    10111011        uint32_t cReadTotal = AUDIOMIXBUF_B2S(&pHstStrmOut->MixBuf, cbReadTotal);
    10121012        if (cReadTotal)
    1013             audioMixBufFinish(&pHstStrmOut->MixBuf, cReadTotal);
     1013            AudioMixBufFinish(&pHstStrmOut->MixBuf, cReadTotal);
    10141014
    10151015        if (pcSamplesPlayed)
  • trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp

    r55035 r55920  
    13201320    do
    13211321    {
    1322         size_t cbBuf = audioMixBufSizeBytes(&pHstStrmIn->MixBuf);
     1322        size_t cbBuf = AudioMixBufSizeBytes(&pHstStrmIn->MixBuf);
    13231323        size_t cbToWrite = RT_MIN(cbBuf, RTCircBufFree(pStreamIn->pBuf));
    13241324        LogFlowFunc(("cbToWrite=%zu\n", cbToWrite));
     
    13381338            }
    13391339
    1340             rc = audioMixBufWriteCirc(&pHstStrmIn->MixBuf, puBuf, cbToRead, &cWritten);
     1340            rc = AudioMixBufWriteCirc(&pHstStrmIn->MixBuf, puBuf, cbToRead, &cWritten);
    13411341            if (RT_FAILURE(rc))
    13421342                break;
     
    13581358        uint32_t cWrittenTotal = AUDIOMIXBUF_B2S(&pHstStrmIn->MixBuf, cbWrittenTotal);
    13591359        if (cWrittenTotal)
    1360             audioMixBufFinish(&pHstStrmIn->MixBuf, cWrittenTotal);
     1360            AudioMixBufFinish(&pHstStrmIn->MixBuf, cWrittenTotal);
    13611361
    13621362        LogFlowFunc(("cWrittenTotal=%RU32 (%RU32 bytes)\n", cWrittenTotal, cbWrittenTotal));
     
    14771477    do
    14781478    {
    1479         size_t cbBuf = RT_MIN(audioMixBufSizeBytes(&pHstStrmOut->MixBuf), pStreamOut->cbPCMBuf);
     1479        size_t cbBuf = RT_MIN(AudioMixBufSizeBytes(&pHstStrmOut->MixBuf), pStreamOut->cbPCMBuf);
    14801480        size_t cbToRead = RT_MIN(cbBuf, RTCircBufFree(pStreamOut->pBuf));
    14811481        LogFlowFunc(("cbToRead=%zu\n", cbToRead));
     
    14871487        while (cbToRead)
    14881488        {
    1489             rc = audioMixBufReadCirc(&pHstStrmOut->MixBuf,
     1489            rc = AudioMixBufReadCirc(&pHstStrmOut->MixBuf,
    14901490                                     pStreamOut->pvPCMBuf, cbToRead, &cRead);
    14911491            if (   RT_FAILURE(rc)
     
    15221522        uint32_t cReadTotal = AUDIOMIXBUF_B2S(&pHstStrmOut->MixBuf, cbReadTotal);
    15231523        if (cReadTotal)
    1524             audioMixBufFinish(&pHstStrmOut->MixBuf, cReadTotal);
     1524            AudioMixBufFinish(&pHstStrmOut->MixBuf, cReadTotal);
    15251525
    15261526        LogFlowFunc(("cReadTotal=%RU32 (%RU32 bytes)\n", cReadTotal, cbReadTotal));
  • trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp

    r55335 r55920  
    11671167    if (pv1 && cb1)
    11681168    {
    1169         rc = audioMixBufReadCirc(&pHstStrmOut->MixBuf, pv1, cb1, &cRead);
     1169        rc = AudioMixBufReadCirc(&pHstStrmOut->MixBuf, pv1, cb1, &cRead);
    11701170        if (RT_SUCCESS(rc))
    11711171            cReadTotal += cRead;
     
    11761176        && pv2 && cb2)
    11771177    {
    1178         rc = audioMixBufReadCirc(&pHstStrmOut->MixBuf, pv2, cb2, &cRead);
     1178        rc = AudioMixBufReadCirc(&pHstStrmOut->MixBuf, pv2, cb2, &cRead);
    11791179        if (RT_SUCCESS(rc))
    11801180            cReadTotal += cRead;
     
    11921192    if (cReadTotal)
    11931193    {
    1194         audioMixBufFinish(&pHstStrmOut->MixBuf, cReadTotal);
     1194        AudioMixBufFinish(&pHstStrmOut->MixBuf, cReadTotal);
    11951195        rc = VINF_SUCCESS; /* Played something. */
    11961196    }
     
    13521352
    13531353    /* Using as an intermediate not circular buffer. */
    1354     audioMixBufReset(&pHstStrmIn->MixBuf);
     1354    AudioMixBufReset(&pHstStrmIn->MixBuf);
    13551355
    13561356    /* Get number of free samples in the mix buffer and check that is has free space */
    1357     uint32_t csMixFree = audioMixBufFree(&pHstStrmIn->MixBuf);
     1357    uint32_t csMixFree = AudioMixBufFree(&pHstStrmIn->MixBuf);
    13581358    if (csMixFree == 0)
    13591359    {
     
    13921392    if (pv1 && len1)
    13931393    {
    1394         rc = audioMixBufWriteAt(&pHstStrmIn->MixBuf, 0 /* offWrite */,
     1394        rc = AudioMixBufWriteAt(&pHstStrmIn->MixBuf, 0 /* offWrite */,
    13951395                                pv1, cb1, &csWritten);
    13961396        if (RT_SUCCESS(rc))
     
    14021402        && pv2 && len2)
    14031403    {
    1404         rc = audioMixBufWriteAt(&pHstStrmIn->MixBuf, csWrittenTotal,
     1404        rc = AudioMixBufWriteAt(&pHstStrmIn->MixBuf, csWrittenTotal,
    14051405                                pv2, cb2, &csWritten);
    14061406        if (RT_SUCCESS(rc))
     
    14141414    {
    14151415        /* Captured something. */
    1416         rc = audioMixBufMixToParent(&pHstStrmIn->MixBuf, csWrittenTotal,
     1416        rc = AudioMixBufMixToParent(&pHstStrmIn->MixBuf, csWrittenTotal,
    14171417                                    &csProcessed);
    14181418    }
  • trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp

    r55649 r55920  
    175175        cSamplesPlayed = csLive;
    176176
    177     audioMixBufFinish(&pHstStrmOut->MixBuf, cSamplesPlayed);
     177    AudioMixBufFinish(&pHstStrmOut->MixBuf, cSamplesPlayed);
    178178
    179179    if (pcSamplesPlayed)
  • trunk/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp

    r55335 r55920  
    366366        {
    367367            audio_pcm_info_clear_buf(&pHstStrmOut->Props,
    368                                      pThisStrmOut->pvPCMBuf, audioMixBufSize(&pHstStrmOut->MixBuf));
     368                                     pThisStrmOut->pvPCMBuf, AudioMixBufSize(&pHstStrmOut->MixBuf));
    369369
    370370            mask = PCM_ENABLE_OUTPUT;
     
    419419    int rc = VINF_SUCCESS;
    420420    size_t cbToRead = RT_MIN(pThisStrmIn->cbBuf,
    421                              audioMixBufFreeBytes(&pHstStrmIn->MixBuf));
     421                             AudioMixBufFreeBytes(&pHstStrmIn->MixBuf));
    422422
    423423    LogFlowFunc(("cbToRead=%zu\n", cbToRead));
     
    466466        {
    467467            uint32_t cWritten;
    468             rc = audioMixBufWriteCirc(&pHstStrmIn->MixBuf,
     468            rc = AudioMixBufWriteCirc(&pHstStrmIn->MixBuf,
    469469                                      pThisStrmIn->pvBuf, cbRead,
    470470                                      &cWritten);
     
    490490        uint32_t cProcessed = 0;
    491491        if (cWrittenTotal)
    492             rc = audioMixBufMixToParent(&pHstStrmIn->MixBuf, cWrittenTotal,
     492            rc = AudioMixBufMixToParent(&pHstStrmIn->MixBuf, cWrittenTotal,
    493493                                        &cProcessed);
    494494
     
    786786    do
    787787    {
    788         size_t cbBuf = audioMixBufSizeBytes(&pHstStrmOut->MixBuf);
     788        size_t cbBuf = AudioMixBufSizeBytes(&pHstStrmOut->MixBuf);
    789789
    790790        uint32_t cLive = drvAudioHstOutSamplesLive(pHstStrmOut,
     
    861861        while (cbToRead)
    862862        {
    863             rc = audioMixBufReadCirc(&pHstStrmOut->MixBuf,
     863            rc = AudioMixBufReadCirc(&pHstStrmOut->MixBuf,
    864864                                     pThisStrmOut->pvPCMBuf, cbToRead, &cRead);
    865865            if (RT_FAILURE(rc))
     
    893893        uint32_t cReadTotal = AUDIOMIXBUF_B2S(&pHstStrmOut->MixBuf, cbReadTotal);
    894894        if (cReadTotal)
    895             audioMixBufFinish(&pHstStrmOut->MixBuf, cReadTotal);
     895            AudioMixBufFinish(&pHstStrmOut->MixBuf, cReadTotal);
    896896
    897897        if (pcSamplesPlayed)
  • trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp

    r55339 r55920  
    723723
    724724    int rc = VINF_SUCCESS;
    725     size_t cbToRead = RT_MIN(cbAvail, audioMixBufFreeBytes(&pHstStrmIn->MixBuf));
     725    size_t cbToRead = RT_MIN(cbAvail, AudioMixBufFreeBytes(&pHstStrmIn->MixBuf));
    726726
    727727    LogFlowFunc(("cbToRead=%zu, cbAvail=%zu, offPeekBuf=%zu, cbPeekBuf=%zu\n",
     
    763763        {
    764764            uint32_t cWritten;
    765             rc = audioMixBufWriteCirc(&pHstStrmIn->MixBuf,
     765            rc = AudioMixBufWriteCirc(&pHstStrmIn->MixBuf,
    766766                                      pThisStrmIn->pu8PeekBuf + pThisStrmIn->offPeekBuf,
    767767                                      cbToWrite, &cWritten);
     
    796796        uint32_t cProcessed = 0;
    797797        if (cWrittenTotal)
    798             rc = audioMixBufMixToParent(&pHstStrmIn->MixBuf, cWrittenTotal,
     798            rc = AudioMixBufMixToParent(&pHstStrmIn->MixBuf, cWrittenTotal,
    799799                                        &cProcessed);
    800800
     
    852852        while (cbToRead)
    853853        {
    854             rc = audioMixBufReadCirc(&pHstStrmOut->MixBuf, pThisStrmOut->pvPCMBuf,
     854            rc = AudioMixBufReadCirc(&pHstStrmOut->MixBuf, pThisStrmOut->pvPCMBuf,
    855855                                     RT_MIN(cbToRead, pThisStrmOut->cbPCMBuf), &cRead);
    856856            if (   !cRead
     
    884884        uint32_t cReadTotal = AUDIOMIXBUF_B2S(&pHstStrmOut->MixBuf, cbReadTotal);
    885885        if (cReadTotal)
    886             audioMixBufFinish(&pHstStrmOut->MixBuf, cReadTotal);
     886            AudioMixBufFinish(&pHstStrmOut->MixBuf, cReadTotal);
    887887
    888888        if (pcSamplesPlayed)
  • trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp

    r55495 r55920  
    5959     */
    6060    PDMAUDIOMIXBUF mb;
    61     RTTESTI_CHECK_RC_OK(audioMixBufInit(&mb, "Single", &props, cBufSize));
    62     RTTESTI_CHECK(audioMixBufSize(&mb) == cBufSize);
    63     RTTESTI_CHECK(AUDIOMIXBUF_B2S(&mb, audioMixBufSizeBytes(&mb)) == cBufSize);
    64     RTTESTI_CHECK(AUDIOMIXBUF_S2B(&mb, audioMixBufSize(&mb)) == audioMixBufSizeBytes(&mb));
    65     RTTESTI_CHECK(audioMixBufFree(&mb) == cBufSize);
    66     RTTESTI_CHECK(AUDIOMIXBUF_S2B(&mb, audioMixBufFree(&mb)) == audioMixBufFreeBytes(&mb));
     61    RTTESTI_CHECK_RC_OK(AudioMixBufInit(&mb, "Single", &props, cBufSize));
     62    RTTESTI_CHECK(AudioMixBufSize(&mb) == cBufSize);
     63    RTTESTI_CHECK(AUDIOMIXBUF_B2S(&mb, AudioMixBufSizeBytes(&mb)) == cBufSize);
     64    RTTESTI_CHECK(AUDIOMIXBUF_S2B(&mb, AudioMixBufSize(&mb)) == AudioMixBufSizeBytes(&mb));
     65    RTTESTI_CHECK(AudioMixBufFree(&mb) == cBufSize);
     66    RTTESTI_CHECK(AUDIOMIXBUF_S2B(&mb, AudioMixBufFree(&mb)) == AudioMixBufFreeBytes(&mb));
    6767
    6868    /*
     
    7575    int64_t samples64[2] = { 0xEE, 0xFF };
    7676
    77     RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&mb, 0, &samples8, sizeof(samples8), &written));
     77    RTTESTI_CHECK_RC_OK(AudioMixBufWriteAt(&mb, 0, &samples8, sizeof(samples8), &written));
    7878    RTTESTI_CHECK(written == 0 /* Samples */);
    7979
    80     RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&mb, 0, &samples16, sizeof(samples16), &written));
     80    RTTESTI_CHECK_RC_OK(AudioMixBufWriteAt(&mb, 0, &samples16, sizeof(samples16), &written));
    8181    RTTESTI_CHECK(written == 1 /* Samples */);
    8282
    83     RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&mb, 2, &samples32, sizeof(samples32), &written));
     83    RTTESTI_CHECK_RC_OK(AudioMixBufWriteAt(&mb, 2, &samples32, sizeof(samples32), &written));
    8484    RTTESTI_CHECK(written == 2 /* Samples */);
    8585    written_abs = 0;
    8686
    8787    /* Beyond buffer. */
    88     RTTESTI_CHECK_RC(audioMixBufWriteAt(&mb, audioMixBufSize(&mb) + 1, &samples16, sizeof(samples16),
     88    RTTESTI_CHECK_RC(AudioMixBufWriteAt(&mb, AudioMixBufSize(&mb) + 1, &samples16, sizeof(samples16),
    8989                                        &written), VERR_BUFFER_OVERFLOW);
    9090
     
    9292     * Circular writes.
    9393     */
    94     uint32_t cToWrite = audioMixBufSize(&mb) - written_abs - 1; /* -1 as padding plus -2 samples for above. */
     94    uint32_t cToWrite = AudioMixBufSize(&mb) - written_abs - 1; /* -1 as padding plus -2 samples for above. */
    9595    for (uint32_t i = 0; i < cToWrite; i++)
    9696    {
    97         RTTESTI_CHECK_RC_OK(audioMixBufWriteCirc(&mb, &samples16, sizeof(samples16), &written));
     97        RTTESTI_CHECK_RC_OK(AudioMixBufWriteCirc(&mb, &samples16, sizeof(samples16), &written));
    9898        RTTESTI_CHECK(written == 1);
    9999    }
    100     RTTESTI_CHECK(!audioMixBufIsEmpty(&mb));
    101     RTTESTI_CHECK(audioMixBufFree(&mb) == 1);
    102     RTTESTI_CHECK(audioMixBufFreeBytes(&mb) == AUDIOMIXBUF_S2B(&mb, 1U));
    103     RTTESTI_CHECK(audioMixBufProcessed(&mb) == cToWrite + written_abs /* + last absolute write */);
    104 
    105     RTTESTI_CHECK_RC_OK(audioMixBufWriteCirc(&mb, &samples16, sizeof(samples16), &written));
     100    RTTESTI_CHECK(!AudioMixBufIsEmpty(&mb));
     101    RTTESTI_CHECK(AudioMixBufFree(&mb) == 1);
     102    RTTESTI_CHECK(AudioMixBufFreeBytes(&mb) == AUDIOMIXBUF_S2B(&mb, 1U));
     103    RTTESTI_CHECK(AudioMixBufProcessed(&mb) == cToWrite + written_abs /* + last absolute write */);
     104
     105    RTTESTI_CHECK_RC_OK(AudioMixBufWriteCirc(&mb, &samples16, sizeof(samples16), &written));
    106106    RTTESTI_CHECK(written == 1);
    107     RTTESTI_CHECK(audioMixBufFree(&mb) == 0);
    108     RTTESTI_CHECK(audioMixBufFreeBytes(&mb) == AUDIOMIXBUF_S2B(&mb, 0));
    109     RTTESTI_CHECK(audioMixBufProcessed(&mb) == cBufSize);
     107    RTTESTI_CHECK(AudioMixBufFree(&mb) == 0);
     108    RTTESTI_CHECK(AudioMixBufFreeBytes(&mb) == AUDIOMIXBUF_S2B(&mb, 0));
     109    RTTESTI_CHECK(AudioMixBufProcessed(&mb) == cBufSize);
    110110
    111111    /* Circular reads. */
    112     uint32_t cToRead = audioMixBufSize(&mb) - written_abs - 1;
     112    uint32_t cToRead = AudioMixBufSize(&mb) - written_abs - 1;
    113113    for (uint32_t i = 0; i < cToWrite; i++)
    114114    {
    115         RTTESTI_CHECK_RC_OK(audioMixBufReadCirc(&mb, &samples16, sizeof(samples16), &read));
     115        RTTESTI_CHECK_RC_OK(AudioMixBufReadCirc(&mb, &samples16, sizeof(samples16), &read));
    116116        RTTESTI_CHECK(read == 1);
    117         audioMixBufFinish(&mb, read);
    118     }
    119     RTTESTI_CHECK(!audioMixBufIsEmpty(&mb));
    120     RTTESTI_CHECK(audioMixBufFree(&mb) == audioMixBufSize(&mb) - written_abs - 1);
    121     RTTESTI_CHECK(audioMixBufFreeBytes(&mb) == AUDIOMIXBUF_S2B(&mb, cBufSize - written_abs - 1));
    122     RTTESTI_CHECK(audioMixBufProcessed(&mb) == cBufSize - cToRead + written_abs);
    123 
    124     RTTESTI_CHECK_RC_OK(audioMixBufReadCirc(&mb, &samples16, sizeof(samples16), &read));
     117        AudioMixBufFinish(&mb, read);
     118    }
     119    RTTESTI_CHECK(!AudioMixBufIsEmpty(&mb));
     120    RTTESTI_CHECK(AudioMixBufFree(&mb) == AudioMixBufSize(&mb) - written_abs - 1);
     121    RTTESTI_CHECK(AudioMixBufFreeBytes(&mb) == AUDIOMIXBUF_S2B(&mb, cBufSize - written_abs - 1));
     122    RTTESTI_CHECK(AudioMixBufProcessed(&mb) == cBufSize - cToRead + written_abs);
     123
     124    RTTESTI_CHECK_RC_OK(AudioMixBufReadCirc(&mb, &samples16, sizeof(samples16), &read));
    125125    RTTESTI_CHECK(read == 1);
    126     audioMixBufFinish(&mb, read);
    127     RTTESTI_CHECK(audioMixBufFree(&mb) == cBufSize - written_abs);
    128     RTTESTI_CHECK(audioMixBufFreeBytes(&mb) == AUDIOMIXBUF_S2B(&mb, cBufSize - written_abs));
    129     RTTESTI_CHECK(audioMixBufProcessed(&mb) == written_abs);
    130 
    131     audioMixBufDestroy(&mb);
     126    AudioMixBufFinish(&mb, read);
     127    RTTESTI_CHECK(AudioMixBufFree(&mb) == cBufSize - written_abs);
     128    RTTESTI_CHECK(AudioMixBufFreeBytes(&mb) == AUDIOMIXBUF_S2B(&mb, cBufSize - written_abs));
     129    RTTESTI_CHECK(AudioMixBufProcessed(&mb) == written_abs);
     130
     131    AudioMixBufDestroy(&mb);
    132132
    133133    return RTTestSubErrorCount(hTest) ? VERR_GENERAL_FAILURE : VINF_SUCCESS;
     
    153153
    154154    PDMAUDIOMIXBUF parent;
    155     RTTESTI_CHECK_RC_OK(audioMixBufInit(&parent, "Parent", &props, cBufSize));
     155    RTTESTI_CHECK_RC_OK(AudioMixBufInit(&parent, "Parent", &props, cBufSize));
    156156
    157157    PDMAUDIOSTREAMCFG cfg_c1 = /* Upmixing to parent */
     
    167167
    168168    PDMAUDIOMIXBUF child1;
    169     RTTESTI_CHECK_RC_OK(audioMixBufInit(&child1, "Child1", &props, cBufSize));
    170     RTTESTI_CHECK_RC_OK(audioMixBufLinkTo(&child1, &parent));
     169    RTTESTI_CHECK_RC_OK(AudioMixBufInit(&child1, "Child1", &props, cBufSize));
     170    RTTESTI_CHECK_RC_OK(AudioMixBufLinkTo(&child1, &parent));
    171171
    172172    PDMAUDIOSTREAMCFG cfg_c2 = /* Downmixing to parent */
     
    182182
    183183    PDMAUDIOMIXBUF child2;
    184     RTTESTI_CHECK_RC_OK(audioMixBufInit(&child2, "Child2", &props, cBufSize));
    185     RTTESTI_CHECK_RC_OK(audioMixBufLinkTo(&child2, &parent));
     184    RTTESTI_CHECK_RC_OK(AudioMixBufInit(&child2, "Child2", &props, cBufSize));
     185    RTTESTI_CHECK_RC_OK(AudioMixBufLinkTo(&child2, &parent));
    186186
    187187    /*
     
    208208    {
    209209        RTTestPrintf(hTest, RTTESTLVL_DEBUG, "i=%RU32\n", i);
    210         RTTESTI_CHECK_RC_OK_BREAK(audioMixBufWriteAt(&child1, 0, &samples, sizeof(samples), &written));
     210        RTTESTI_CHECK_RC_OK_BREAK(AudioMixBufWriteAt(&child1, 0, &samples, sizeof(samples), &written));
    211211        RTTESTI_CHECK_MSG_BREAK(written == cSamplesChild1, ("Child1: Expected %RU32 written samples, got %RU32\n", cSamplesChild1, written));
    212         RTTESTI_CHECK_RC_OK_BREAK(audioMixBufMixToParent(&child1, written, &mixed));
    213         temp = audioMixBufProcessed(&parent) - audioMixBufMixed(&child2);
    214         RTTESTI_CHECK_MSG_BREAK(audioMixBufMixed(&child1) == temp, ("Child1: Expected %RU32 mixed samples, got %RU32\n", audioMixBufMixed(&child1), temp));
    215 
    216         RTTESTI_CHECK_RC_OK_BREAK(audioMixBufWriteAt(&child2, 0, &samples, sizeof(samples), &written));
     212        RTTESTI_CHECK_RC_OK_BREAK(AudioMixBufMixToParent(&child1, written, &mixed));
     213        temp = AudioMixBufProcessed(&parent) - AudioMixBufMixed(&child2);
     214        RTTESTI_CHECK_MSG_BREAK(AudioMixBufMixed(&child1) == temp, ("Child1: Expected %RU32 mixed samples, got %RU32\n", AudioMixBufMixed(&child1), temp));
     215
     216        RTTESTI_CHECK_RC_OK_BREAK(AudioMixBufWriteAt(&child2, 0, &samples, sizeof(samples), &written));
    217217        RTTESTI_CHECK_MSG_BREAK(written == cSamplesChild2, ("Child2: Expected %RU32 written samples, got %RU32\n", cSamplesChild2, written));
    218         RTTESTI_CHECK_RC_OK_BREAK(audioMixBufMixToParent(&child2, written, &mixed));
    219         temp = audioMixBufProcessed(&parent) - audioMixBufMixed(&child1);
    220         RTTESTI_CHECK_MSG_BREAK(audioMixBufMixed(&child2) == temp, ("Child2: Expected %RU32 mixed samples, got %RU32\n", audioMixBufMixed(&child2), temp));
    221     }
    222 
    223     RTTESTI_CHECK(audioMixBufProcessed(&parent) == audioMixBufMixed(&child1) + audioMixBufMixed(&child2));
     218        RTTESTI_CHECK_RC_OK_BREAK(AudioMixBufMixToParent(&child2, written, &mixed));
     219        temp = AudioMixBufProcessed(&parent) - AudioMixBufMixed(&child1);
     220        RTTESTI_CHECK_MSG_BREAK(AudioMixBufMixed(&child2) == temp, ("Child2: Expected %RU32 mixed samples, got %RU32\n", AudioMixBufMixed(&child2), temp));
     221    }
     222
     223    RTTESTI_CHECK(AudioMixBufProcessed(&parent) == AudioMixBufMixed(&child1) + AudioMixBufMixed(&child2));
    224224
    225225    for (;;)
    226226    {
    227         RTTESTI_CHECK_RC_OK_BREAK(audioMixBufReadCirc(&parent, pvBuf, cbBuf, &read));
     227        RTTESTI_CHECK_RC_OK_BREAK(AudioMixBufReadCirc(&parent, pvBuf, cbBuf, &read));
    228228        if (!read)
    229229            break;
    230         audioMixBufFinish(&parent, read);
    231     }
    232 
    233     RTTESTI_CHECK(audioMixBufProcessed(&parent) == 0);
    234     RTTESTI_CHECK(audioMixBufMixed(&child1) == 0);
    235     RTTESTI_CHECK(audioMixBufMixed(&child2) == 0);
    236 
    237     audioMixBufDestroy(&parent);
    238     audioMixBufDestroy(&child1);
    239     audioMixBufDestroy(&child2);
     230        AudioMixBufFinish(&parent, read);
     231    }
     232
     233    RTTESTI_CHECK(AudioMixBufProcessed(&parent) == 0);
     234    RTTESTI_CHECK(AudioMixBufMixed(&child1) == 0);
     235    RTTESTI_CHECK(AudioMixBufMixed(&child2) == 0);
     236
     237    AudioMixBufDestroy(&parent);
     238    AudioMixBufDestroy(&child1);
     239    AudioMixBufDestroy(&child2);
    240240
    241241    return RTTestSubErrorCount(hTest) ? VERR_GENERAL_FAILURE : VINF_SUCCESS;
     
    264264
    265265    PDMAUDIOMIXBUF parent;
    266     RTTESTI_CHECK_RC_OK(audioMixBufInit(&parent, "Parent", &props, cBufSize));
     266    RTTESTI_CHECK_RC_OK(AudioMixBufInit(&parent, "Parent", &props, cBufSize));
    267267
    268268    /* Child uses half the sample rate; that ensures the mixing engine can't
     
    285285
    286286    PDMAUDIOMIXBUF child;
    287     RTTESTI_CHECK_RC_OK(audioMixBufInit(&child, "Child", &props, cBufSize));
    288     RTTESTI_CHECK_RC_OK(audioMixBufLinkTo(&child, &parent));
     287    RTTESTI_CHECK_RC_OK(AudioMixBufInit(&child, "Child", &props, cBufSize));
     288    RTTESTI_CHECK_RC_OK(AudioMixBufLinkTo(&child, &parent));
    289289
    290290    /* 8-bit unsigned samples. Often used with SB16 device. */
     
    307307    /**** 8-bit unsigned samples ****/
    308308    RTTestPrintf(hTest, RTTESTLVL_DEBUG, "Conversion test %uHz %uch 8-bit\n", cfg_c.uHz, cfg_c.cChannels);
    309     RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child, 0, &samples, sizeof(samples), &written));
     309    RTTESTI_CHECK_RC_OK(AudioMixBufWriteAt(&child, 0, &samples, sizeof(samples), &written));
    310310    RTTESTI_CHECK_MSG(written == cSamplesChild, ("Child: Expected %RU32 written samples, got %RU32\n", cSamplesChild, written));
    311     RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child, written, &mixed));
    312     temp = audioMixBufProcessed(&parent);
    313     RTTESTI_CHECK_MSG(audioMixBufMixed(&child) == temp, ("Child: Expected %RU32 mixed samples, got %RU32\n", audioMixBufMixed(&child), temp));
    314 
    315     RTTESTI_CHECK(audioMixBufProcessed(&parent) == audioMixBufMixed(&child));
     311    RTTESTI_CHECK_RC_OK(AudioMixBufMixToParent(&child, written, &mixed));
     312    temp = AudioMixBufProcessed(&parent);
     313    RTTESTI_CHECK_MSG(AudioMixBufMixed(&child) == temp, ("Child: Expected %RU32 mixed samples, got %RU32\n", AudioMixBufMixed(&child), temp));
     314
     315    RTTESTI_CHECK(AudioMixBufProcessed(&parent) == AudioMixBufMixed(&child));
    316316
    317317    for (;;)
    318318    {
    319         RTTESTI_CHECK_RC_OK_BREAK(audioMixBufReadCirc(&parent, achBuf, cbBuf, &read));
     319        RTTESTI_CHECK_RC_OK_BREAK(AudioMixBufReadCirc(&parent, achBuf, cbBuf, &read));
    320320        if (!read)
    321321            break;
    322322        cSamplesRead += read;
    323         audioMixBufFinish(&parent, read);
     323        AudioMixBufFinish(&parent, read);
    324324    }
    325325    RTTESTI_CHECK_MSG(cSamplesRead == cSamplesParent, ("Parent: Expected %RU32 mixed samples, got %RU32\n", cSamplesParent, cSamplesRead));
     
    337337    }
    338338
    339     RTTESTI_CHECK(audioMixBufProcessed(&parent) == 0);
    340     RTTESTI_CHECK(audioMixBufMixed(&child) == 0);
    341 
    342     audioMixBufDestroy(&parent);
    343     audioMixBufDestroy(&child);
     339    RTTESTI_CHECK(AudioMixBufProcessed(&parent) == 0);
     340    RTTESTI_CHECK(AudioMixBufMixed(&child) == 0);
     341
     342    AudioMixBufDestroy(&parent);
     343    AudioMixBufDestroy(&child);
    344344
    345345    return RTTestSubErrorCount(hTest) ? VERR_GENERAL_FAILURE : VINF_SUCCESS;
     
    368368
    369369    PDMAUDIOMIXBUF parent;
    370     RTTESTI_CHECK_RC_OK(audioMixBufInit(&parent, "Parent", &props, cBufSize));
     370    RTTESTI_CHECK_RC_OK(AudioMixBufInit(&parent, "Parent", &props, cBufSize));
    371371
    372372    PDMAUDIOSTREAMCFG cfg_c =   /* Upmixing to parent */
     
    382382
    383383    PDMAUDIOMIXBUF child;
    384     RTTESTI_CHECK_RC_OK(audioMixBufInit(&child, "Child", &props, cBufSize));
    385     RTTESTI_CHECK_RC_OK(audioMixBufLinkTo(&child, &parent));
     384    RTTESTI_CHECK_RC_OK(AudioMixBufInit(&child, "Child", &props, cBufSize));
     385    RTTESTI_CHECK_RC_OK(AudioMixBufLinkTo(&child, &parent));
    386386
    387387    /* 16-bit signed. More or less exclusively used as output, and usually as input, too. */
     
    404404    /**** 16-bit signed samples ****/
    405405    RTTestPrintf(hTest, RTTESTLVL_DEBUG, "Conversion test %uHz %uch 16-bit\n", cfg_c.uHz, cfg_c.cChannels);
    406     RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child, 0, &samples, sizeof(samples), &written));
     406    RTTESTI_CHECK_RC_OK(AudioMixBufWriteAt(&child, 0, &samples, sizeof(samples), &written));
    407407    RTTESTI_CHECK_MSG(written == cSamplesChild, ("Child: Expected %RU32 written samples, got %RU32\n", cSamplesChild, written));
    408     RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child, written, &mixed));
    409     temp = audioMixBufProcessed(&parent);
    410     RTTESTI_CHECK_MSG(audioMixBufMixed(&child) == temp, ("Child: Expected %RU32 mixed samples, got %RU32\n", audioMixBufMixed(&child), temp));
    411 
    412     RTTESTI_CHECK(audioMixBufProcessed(&parent) == audioMixBufMixed(&child));
     408    RTTESTI_CHECK_RC_OK(AudioMixBufMixToParent(&child, written, &mixed));
     409    temp = AudioMixBufProcessed(&parent);
     410    RTTESTI_CHECK_MSG(AudioMixBufMixed(&child) == temp, ("Child: Expected %RU32 mixed samples, got %RU32\n", AudioMixBufMixed(&child), temp));
     411
     412    RTTESTI_CHECK(AudioMixBufProcessed(&parent) == AudioMixBufMixed(&child));
    413413
    414414    for (;;)
    415415    {
    416         RTTESTI_CHECK_RC_OK_BREAK(audioMixBufReadCirc(&parent, achBuf, cbBuf, &read));
     416        RTTESTI_CHECK_RC_OK_BREAK(AudioMixBufReadCirc(&parent, achBuf, cbBuf, &read));
    417417        if (!read)
    418418            break;
    419419        cSamplesRead += read;
    420         audioMixBufFinish(&parent, read);
     420        AudioMixBufFinish(&parent, read);
    421421    }
    422422    RTTESTI_CHECK_MSG(cSamplesRead == cSamplesParent, ("Parent: Expected %RU32 mixed samples, got %RU32\n", cSamplesParent, cSamplesRead));
     
    434434    }
    435435
    436     RTTESTI_CHECK(audioMixBufProcessed(&parent) == 0);
    437     RTTESTI_CHECK(audioMixBufMixed(&child) == 0);
    438    
    439     audioMixBufDestroy(&parent);
    440     audioMixBufDestroy(&child);
     436    RTTESTI_CHECK(AudioMixBufProcessed(&parent) == 0);
     437    RTTESTI_CHECK(AudioMixBufMixed(&child) == 0);
     438
     439    AudioMixBufDestroy(&parent);
     440    AudioMixBufDestroy(&child);
    441441
    442442    return RTTestSubErrorCount(hTest) ? VERR_GENERAL_FAILURE : VINF_SUCCESS;
     
    467467    PDMAUDIOVOLUME vol = { false, 0, 0 };   /* Not muted. */
    468468    PDMAUDIOMIXBUF parent;
    469     RTTESTI_CHECK_RC_OK(audioMixBufInit(&parent, "Parent", &props, cBufSize));
     469    RTTESTI_CHECK_RC_OK(AudioMixBufInit(&parent, "Parent", &props, cBufSize));
    470470
    471471    PDMAUDIOMIXBUF child;
    472     RTTESTI_CHECK_RC_OK(audioMixBufInit(&child, "Child", &props, cBufSize));
    473     RTTESTI_CHECK_RC_OK(audioMixBufLinkTo(&child, &parent));
     472    RTTESTI_CHECK_RC_OK(AudioMixBufInit(&child, "Child", &props, cBufSize));
     473    RTTESTI_CHECK_RC_OK(AudioMixBufLinkTo(&child, &parent));
    474474
    475475    /* A few 16-bit signed samples. */
     
    497497    /* 1) Full volume/0dB attenuation (255). */
    498498    vol.uLeft = vol.uRight = 255;
    499     audioMixBufSetVolume(&child, &vol);
    500 
    501     RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child, 0, &samples, sizeof(samples), &written));
     499    AudioMixBufSetVolume(&child, &vol);
     500
     501    RTTESTI_CHECK_RC_OK(AudioMixBufWriteAt(&child, 0, &samples, sizeof(samples), &written));
    502502    RTTESTI_CHECK_MSG(written == cSamplesChild, ("Child: Expected %RU32 written samples, got %RU32\n", cSamplesChild, written));
    503     RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child, written, &mixed));
     503    RTTESTI_CHECK_RC_OK(AudioMixBufMixToParent(&child, written, &mixed));
    504504
    505505    cSamplesRead = 0;
    506506    for (;;)
    507507    {
    508         RTTESTI_CHECK_RC_OK_BREAK(audioMixBufReadCirc(&parent, achBuf, cbBuf, &read));
     508        RTTESTI_CHECK_RC_OK_BREAK(AudioMixBufReadCirc(&parent, achBuf, cbBuf, &read));
    509509        if (!read)
    510510            break;
    511511        cSamplesRead += read;
    512         audioMixBufFinish(&parent, read);
     512        AudioMixBufFinish(&parent, read);
    513513    }
    514514    RTTESTI_CHECK_MSG(cSamplesRead == cSamplesParent, ("Parent: Expected %RU32 mixed samples, got %RU32\n", cSamplesParent, cSamplesRead));
     
    524524        ++pDst16;
    525525    }
    526     audioMixBufReset(&child);
     526    AudioMixBufReset(&child);
    527527
    528528    /* 2) Half volume/-6dB attenuation (16 steps down). */
    529529    vol.uLeft = vol.uRight = 255 - 16;
    530     audioMixBufSetVolume(&child, &vol);
    531 
    532     RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child, 0, &samples, sizeof(samples), &written));
     530    AudioMixBufSetVolume(&child, &vol);
     531
     532    RTTESTI_CHECK_RC_OK(AudioMixBufWriteAt(&child, 0, &samples, sizeof(samples), &written));
    533533    RTTESTI_CHECK_MSG(written == cSamplesChild, ("Child: Expected %RU32 written samples, got %RU32\n", cSamplesChild, written));
    534     RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child, written, &mixed));
     534    RTTESTI_CHECK_RC_OK(AudioMixBufMixToParent(&child, written, &mixed));
    535535
    536536    cSamplesRead = 0;
    537537    for (;;)
    538538    {
    539         RTTESTI_CHECK_RC_OK_BREAK(audioMixBufReadCirc(&parent, achBuf, cbBuf, &read));
     539        RTTESTI_CHECK_RC_OK_BREAK(AudioMixBufReadCirc(&parent, achBuf, cbBuf, &read));
    540540        if (!read)
    541541            break;
    542542        cSamplesRead += read;
    543         audioMixBufFinish(&parent, read);
     543        AudioMixBufFinish(&parent, read);
    544544    }
    545545    RTTESTI_CHECK_MSG(cSamplesRead == cSamplesParent, ("Parent: Expected %RU32 mixed samples, got %RU32\n", cSamplesParent, cSamplesRead));
     
    557557    }
    558558
    559     audioMixBufDestroy(&parent);
    560     audioMixBufDestroy(&child);
     559    AudioMixBufDestroy(&parent);
     560    AudioMixBufDestroy(&child);
    561561
    562562    return RTTestSubErrorCount(hTest) ? VERR_GENERAL_FAILURE : VINF_SUCCESS;
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