VirtualBox

Changeset 64565 in vbox


Ignore:
Timestamp:
Nov 4, 2016 12:26:57 PM (8 years ago)
Author:
vboxsync
Message:

Audio/AudioMixBuffer.cpp: Also take the used samples count into account in AudioMixBufFinish(). Converted some VINF_ return codes to VERR_ ones for easier error handling. Documentation, logging tweaks.

File:
1 edited

Legend:

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

    r64047 r64565  
    226226
    227227        pIter->cMixed -= RT_MIN(pIter->cMixed, cSamplesToClear);
     228        pIter->cUsed  -= RT_MIN(pIter->cUsed,  AUDIOMIXBUF_S2S_RATIO(pMixBuf, cSamplesToClear));
    228229    }
    229230
     
    974975 *
    975976 * @return  IPRT status code.
     977 *          VERR_NO_DATA if the source does not have any audio data.
     978 *          VERR_BUFFER_UNDERFLOW if the source did not have enough audio data.
     979 *          VERR_BUFFER_OVERFLOW if the destination did not have enough space to store the converted source audio data.
     980 *
    976981 * @param   pDst                    Destination mixing buffer.
    977982 * @param   pSrc                    Source mixing buffer.
     
    9961001        if (pcProcessed)
    9971002            *pcProcessed = 0;
    998         return VINF_SUCCESS;
     1003        return VERR_BUFFER_OVERFLOW;
    9991004    }
    10001005
     
    10091014    uint32_t offDstWrite  = pDst->offWrite;
    10101015
    1011     if (   !cSrcAvail
    1012         || !cDstAvail)
    1013     {
    1014         if (pcProcessed)
    1015             *pcProcessed = 0;
    1016         return VINF_SUCCESS;
    1017     }
     1016    if (!cSrcAvail)
     1017        return VERR_NO_DATA;
    10181018
    10191019    AUDMIXBUF_LOG(("cSrcSamples=%RU32, cSrcAvail=%RU32 -> cDstAvail=%RU32\n", cSrcSamples,  cSrcAvail, cDstAvail));
     
    10911091    if (pDst->cUsed > pDst->cSamples)
    10921092    {
    1093         LogFlowFunc(("Warning: Destination buffer used %RU32 / %RU32 samples\n", pDst->cUsed, pDst->cSamples));
     1093        LogFunc(("Warning: Destination buffer used %RU32 / %RU32 samples\n", pDst->cUsed, pDst->cSamples));
    10941094        pDst->offWrite     = 0;
    10951095        pDst->cUsed        = pDst->cSamples;
     
    10991099    else if (!cSrcToRead && cDstAvail)
    11001100    {
    1101         AUDMIXBUF_LOG(("Warning: Source buffer '%s' ran out of data\n", pSrc->pszName));
     1101        LogFunc(("Warning: Source buffer '%s' ran out of data\n", pSrc->pszName));
    11021102        rc = VERR_BUFFER_UNDERFLOW;
    11031103    }
    11041104    else if (cSrcAvail && !cDstAvail)
    11051105    {
    1106         AUDMIXBUF_LOG(("Warning: Destination buffer '%s' full (%RU32 source samples left)\n", pDst->pszName, cSrcAvail));
     1106        LogFunc(("Warning: Destination buffer '%s' full (%RU32 source samples left)\n", pDst->pszName, cSrcAvail));
    11071107        rc = VERR_BUFFER_OVERFLOW;
    11081108    }
     
    11241124 * Mixes audio samples down to the parent mixing buffer.
    11251125 *
    1126  * @return  IPRT status code.
     1126 * @return  IPRT status code. See audioMixBufMixTo() for a more detailed explanation.
    11271127 * @param   pMixBuf                 Mixing buffer to mix samples down to parent.
    11281128 * @param   cSamples                Number of audio samples of specified mixing buffer to to mix
     
    11531153DECL_FORCE_INLINE(void) audioMixBufDbgPrintSingle(PPDMAUDIOMIXBUF pMixBuf, bool fIsParent, uint16_t uIdtLvl)
    11541154{
    1155     AUDMIXBUF_LOG(("%*s[%s] %s: offRead=%RU32, offWrite=%RU32, cMixed=%RU32 -> %RU32/%RU32\n",
    1156                    uIdtLvl * 4, "", fIsParent ? "PARENT" : "CHILD",
    1157                    pMixBuf->pszName, pMixBuf->offRead, pMixBuf->offWrite, pMixBuf->cMixed, pMixBuf->cUsed, pMixBuf->cSamples));
     1155    LogFunc(("%*s[%s] %s: offRead=%RU32, offWrite=%RU32, cMixed=%RU32 -> %RU32/%RU32\n",
     1156             uIdtLvl * 4, "", fIsParent ? "PARENT" : "CHILD",
     1157             pMixBuf->pszName, pMixBuf->offRead, pMixBuf->offWrite, pMixBuf->cMixed, pMixBuf->cUsed, pMixBuf->cSamples));
    11581158}
    11591159
     
    12221222        pParent = pMixBuf->pParent;
    12231223
    1224     AUDMIXBUF_LOG(("***************************************************************************************\n"));
     1224    LogFunc(("***************************************************************************************\n"));
    12251225
    12261226    audioMixBufDbgPrintSingle(pMixBuf, pParent == pMixBuf /* fIsParent */, 0 /* iIdtLevel */);
     
    12341234    }
    12351235
    1236     AUDMIXBUF_LOG(("***************************************************************************************\n"));
     1236    LogFunc(("***************************************************************************************\n"));
    12371237}
    12381238
     
    12601260{
    12611261    AssertPtrReturn(pMixBuf, 0);
    1262 
    1263     AUDMIXBUF_LOG(("%s: cUsed=%RU32\n", pMixBuf->pszName, pMixBuf->cUsed));
    12641262    return pMixBuf->cUsed;
    12651263}
     
    17461744 * The sample format being written must match the format of the mixing buffer.
    17471745 *
    1748  * @return  IPRT status code, or VINF_BUFFER_OVERFLOW if samples which not have
     1746 * @return  IPRT status code, or VERR_BUFFER_OVERFLOW if samples which not have
    17491747 *          been processed yet have been overwritten (due to cyclic buffer).
    17501748 * @param   pMixBuf                 Pointer to mixing buffer to write to.
     
    17631761 * Writes audio samples of a specific format.
    17641762 *
    1765  * @return  IPRT status code, or VINF_BUFFER_OVERFLOW if samples which not have
     1763 * @return  IPRT status code, or VERR_BUFFER_OVERFLOW if samples which not have
    17661764 *          been processed yet have been overwritten (due to cyclic buffer).
    17671765 * @param   pMixBuf                 Pointer to mixing buffer to write to.
     
    17991797                       pMixBuf->pszName, pMixBuf->pParent->pszName));
    18001798
    1801         return VINF_BUFFER_OVERFLOW;
     1799        return VERR_BUFFER_OVERFLOW;
    18021800    }
    18031801
     
    19051903        pMixBuf->cUsed = pMixBuf->cSamples;
    19061904
    1907         rc = VINF_BUFFER_OVERFLOW;
     1905        rc = VERR_BUFFER_OVERFLOW;
    19081906    }
    19091907
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