VirtualBox

Changeset 61352 in vbox


Ignore:
Timestamp:
Jun 1, 2016 12:58:14 AM (9 years ago)
Author:
vboxsync
Message:

AudioMixBuffer,tstAudioMixBuffer,pdmaudioifs.h: Fixed buffer overflow in AudioMixBufWriteAtEx during testcase run due to incomplete checking. Fixed some coding convesion issues. Made the debug build of the testcsae always use the electric fence heap.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmaudioifs.h

    r61320 r61352  
    9292    int64_t i64LSample;
    9393    int64_t i64RSample;
    94 } PDMAUDIOSAMPLE, *PPDMAUDIOSAMPLE;
     94} PDMAUDIOSAMPLE;
     95/** Pointer to a single (stereo) audio sample.   */
     96typedef PDMAUDIOSAMPLE *PPDMAUDIOSAMPLE;
     97/** Pointer to a const single (stereo) audio sample.   */
     98typedef PDMAUDIOSAMPLE const *PCPDMAUDIOSAMPLE;
    9599
    96100typedef enum PDMAUDIOENDIANNESS
     
    344348 * the audioMixBufConvFromXXX / audioMixBufConvToXXX macros.
    345349 */
    346 typedef struct PDMAUDMIXBUF_CONVOPTS
     350typedef struct PDMAUDMIXBUFCONVOPTS
    347351{
    348352    /** Number of audio samples to convert. */
     
    352356     *  all conversion functions. */
    353357    PDMAUDIOVOLUME Volume;
    354 } PDMAUDMIXBUF_CONVOPTS, *PPDMAUDMIXBUF_CONVOPTS;
     358} PDMAUDMIXBUFCONVOPTS;
     359/** Pointer to conversion parameters for the audio mixer.   */
     360typedef PDMAUDMIXBUFCONVOPTS *PPDMAUDMIXBUFCONVOPTS;
     361/** Pointer to const conversion parameters for the audio mixer.   */
     362typedef PDMAUDMIXBUFCONVOPTS const *PCPDMAUDMIXBUFCONVOPTS;
    355363
    356364/**
     
    361369typedef PDMAUDIOMIXBUFFMT *PPDMAUDIOMIXBUFFMT;
    362370
    363 /** Function pointer definition for a conversion-from routine
    364  *  used by the PDM audio mixing buffer. */
    365 typedef uint32_t (PDMAUDMIXBUF_FN_CONVFROM) (PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, const PPDMAUDMIXBUF_CONVOPTS pOpts);
    366 typedef PDMAUDMIXBUF_FN_CONVFROM *PPDMAUDMIXBUF_FN_CONVFROM;
    367 
    368 /** Function definition for a conversion-to routine
    369  *  used by the PDM audio mixing buffer. */
    370 typedef void (PDMAUDMIXBUF_FN_CONVTO) (void *pvDst, const PPDMAUDIOSAMPLE paSrc, const PPDMAUDMIXBUF_CONVOPTS pOpts);
    371 typedef PDMAUDMIXBUF_FN_CONVTO *PPDMAUDMIXBUF_FN_CONVTO;
     371/**
     372 * Convertion-from function used by the PDM audio buffer mixer.
     373 *
     374 * @returns Number of samples returned.
     375 * @param   paDst           Where to return the converted samples.
     376 * @param   pvSrc           The source samples bytes.
     377 * @param   cbSrc           Number of bytes to convert.
     378 * @param   pOpts           Conversion options.
     379 */
     380typedef DECLCALLBACK(uint32_t) FNPDMAUDIOMIXBUFCONVFROM(PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc,
     381                                                        PCPDMAUDMIXBUFCONVOPTS pOpts);
     382/** Pointer to a convertion-from function used by the PDM audio buffer mixer. */
     383typedef FNPDMAUDIOMIXBUFCONVFROM *PFNPDMAUDIOMIXBUFCONVFROM;
     384
     385/**
     386 * Convertion-to function used by the PDM audio buffer mixer.
     387 *
     388 * @param   pvDst           Output buffer.
     389 * @param   paSrc           The input samples.
     390 * @param   pOpts           Conversion options.
     391 */
     392typedef DECLCALLBACK(void) FNPDMAUDIOMIXBUFCONVTO(void *pvDst, PCPDMAUDIOSAMPLE paSrc, PCPDMAUDMIXBUFCONVOPTS pOpts);
     393/** Pointer to a convertion-to function used by the PDM audio buffer mixer. */
     394typedef FNPDMAUDIOMIXBUFCONVTO *PFNPDMAUDIOMIXBUFCONVTO;
    372395
    373396typedef struct PDMAUDIOMIXBUF *PPDMAUDIOMIXBUF;
     
    408431    PDMAUDIOMIXBUFFMT         AudioFmt;
    409432    /** Standard conversion-to function for set AudioFmt. */
    410     PPDMAUDMIXBUF_FN_CONVTO   pConvTo;
     433    PFNPDMAUDIOMIXBUFCONVTO   pfnConvTo;
    411434    /** Standard conversion-from function for set AudioFmt. */
    412     PPDMAUDMIXBUF_FN_CONVFROM pConvFrom;
     435    PFNPDMAUDIOMIXBUFCONVFROM pfnConvFrom;
    413436    /**
    414437     * Ratio of the associated parent stream's frequency by this stream's
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp

    r61346 r61352  
    132132AssertCompile(AUDIOMIXBUF_VOL_0DB == 0x40000000);   /* For now -- when only attenuation is used. */
    133133
    134 /*
    135  * When running the audio testcases we want to verfiy
    136  * the macro-generated routines separately, so unmark them as being
    137  * inlined + static.
    138  */
    139 #ifdef VBOX_AUDIO_TESTCASE
    140 # define AUDMIXBUF_MACRO_FN
    141 #else
    142 # define AUDMIXBUF_MACRO_FN static inline
    143 #endif
    144 
    145134#ifdef DEBUG
    146135static uint64_t s_cSamplesMixedTotal = 0;
     
    385374
    386375    size_t cbSamples = cSamples * sizeof(PDMAUDIOSAMPLE);
    387     if (!cbSamples)
    388         return VERR_INVALID_PARAMETER;
    389 
    390376    pMixBuf->pSamples = (PPDMAUDIOSAMPLE)RTMemAllocZ(cbSamples);
    391     if (!pMixBuf->pSamples)
    392         return VERR_NO_MEMORY;
    393 
    394     pMixBuf->cSamples = cSamples;
    395 
    396     return VINF_SUCCESS;
     377    if (pMixBuf->pSamples)
     378    {
     379        pMixBuf->cSamples = cSamples;
     380        return VINF_SUCCESS;
     381    }
     382    return VERR_NO_MEMORY;
    397383}
    398384
     
    414400#define AUDMIXBUF_CONVERT(_aName, _aType, _aMin, _aMax, _aSigned, _aShift) \
    415401    /* Clips a specific output value to a single sample value. */ \
    416     AUDMIXBUF_MACRO_FN int64_t audioMixBufClipFrom##_aName(_aType aVal) \
     402    DECLCALLBACK(int64_t) audioMixBufClipFrom##_aName(_aType aVal) \
    417403    { \
    418404        if (_aSigned) \
     
    422408    \
    423409    /* Clips a single sample value to a specific output value. */ \
    424     AUDMIXBUF_MACRO_FN _aType audioMixBufClipTo##_aName(int64_t iVal) \
     410    DECLCALLBACK(_aType) audioMixBufClipTo##_aName(int64_t iVal) \
    425411    { \
    426412        if (iVal >= 0x7fffffff) \
    427413            return _aMax; \
    428         else if (iVal < -INT64_C(0x80000000)) \
     414        if (iVal < -INT64_C(0x80000000)) \
    429415            return _aMin; \
    430416        \
     
    434420    } \
    435421    \
    436     AUDMIXBUF_MACRO_FN uint32_t audioMixBufConvFrom##_aName##Stereo(PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, \
    437                                                                     const PPDMAUDMIXBUF_CONVOPTS pOpts) \
     422    DECLCALLBACK(uint32_t) audioMixBufConvFrom##_aName##Stereo(PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, \
     423                                                               PCPDMAUDMIXBUFCONVOPTS pOpts) \
    438424    { \
    439         _aType *pSrc = (_aType *)pvSrc; \
    440         uint32_t cSamples = (uint32_t)RT_MIN(pOpts->cSamples, cbSrc / sizeof(_aType)); \
     425        _aType const *pSrc = (_aType const *)pvSrc; \
     426        uint32_t cSamples = RT_MIN(pOpts->cSamples, cbSrc / sizeof(_aType)); \
    441427        AUDMIXBUF_MACRO_LOG(("cSamples=%RU32, BpS=%zu, lVol=%RU32, rVol=%RU32\n", \
    442428                             pOpts->cSamples, sizeof(_aType), pOpts->Volume.uLeft, pOpts->Volume.uRight)); \
     
    453439    } \
    454440    \
    455     AUDMIXBUF_MACRO_FN uint32_t audioMixBufConvFrom##_aName##Mono(PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, \
    456                                                                   const PPDMAUDMIXBUF_CONVOPTS pOpts) \
     441    DECLCALLBACK(uint32_t) audioMixBufConvFrom##_aName##Mono(PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, \
     442                                                             PCPDMAUDMIXBUFCONVOPTS pOpts) \
    457443    { \
    458         _aType *pSrc = (_aType *)pvSrc; \
    459         const uint32_t cSamples = (uint32_t)RT_MIN(pOpts->cSamples, cbSrc / sizeof(_aType)); \
     444        _aType const *pSrc = (_aType const *)pvSrc; \
     445        const uint32_t cSamples = RT_MIN(pOpts->cSamples, cbSrc / sizeof(_aType)); \
    460446        AUDMIXBUF_MACRO_LOG(("cSamples=%RU32, BpS=%zu, lVol=%RU32, rVol=%RU32\n", \
    461447                             cSamples, sizeof(_aType), pOpts->Volume.uLeft >> 14, pOpts->Volume.uRight)); \
     
    472458    } \
    473459    \
    474     AUDMIXBUF_MACRO_FN void audioMixBufConvTo##_aName##Stereo(void *pvDst, const PPDMAUDIOSAMPLE paSrc, \
    475                                                               const PPDMAUDMIXBUF_CONVOPTS pOpts) \
     460    DECLCALLBACK(void) audioMixBufConvTo##_aName##Stereo(void *pvDst, PCPDMAUDIOSAMPLE paSrc, PCPDMAUDMIXBUFCONVOPTS pOpts) \
    476461    { \
    477         PPDMAUDIOSAMPLE pSrc = paSrc; \
     462        PCPDMAUDIOSAMPLE pSrc = paSrc; \
    478463        _aType *pDst = (_aType *)pvDst; \
    479464        _aType l, r; \
     
    491476    } \
    492477    \
    493     AUDMIXBUF_MACRO_FN void audioMixBufConvTo##_aName##Mono(void *pvDst, const PPDMAUDIOSAMPLE paSrc, \
    494                                                             const PPDMAUDMIXBUF_CONVOPTS pOpts) \
     478    DECLCALLBACK(void) audioMixBufConvTo##_aName##Mono(void *pvDst, PCPDMAUDIOSAMPLE paSrc, PCPDMAUDMIXBUFCONVOPTS pOpts) \
    495479    { \
    496         PPDMAUDIOSAMPLE pSrc = paSrc; \
     480        PCPDMAUDIOSAMPLE pSrc = paSrc; \
    497481        _aType *pDst = (_aType *)pvDst; \
    498482        uint32_t cSamples = pOpts->cSamples; \
     
    520504
    521505#define AUDMIXBUF_MIXOP(_aName, _aOp) \
    522     AUDMIXBUF_MACRO_FN void audioMixBufOp##_aName(PPDMAUDIOSAMPLE paDst, uint32_t cDstSamples, \
    523                                                   PPDMAUDIOSAMPLE paSrc, uint32_t cSrcSamples, \
    524                                                   PPDMAUDIOSTRMRATE pRate, \
    525                                                   uint32_t *pcDstWritten, uint32_t *pcSrcRead) \
     506    static void audioMixBufOp##_aName(PPDMAUDIOSAMPLE paDst, uint32_t cDstSamples, \
     507                                      PPDMAUDIOSAMPLE paSrc, uint32_t cSrcSamples, \
     508                                      PPDMAUDIOSTRMRATE pRate, \
     509                                      uint32_t *pcDstWritten, uint32_t *pcSrcRead) \
    526510    { \
    527511        AUDMIXBUF_MACRO_LOG(("cSrcSamples=%RU32, cDstSamples=%RU32\n", cSrcSamples, cDstSamples)); \
     
    620604
    621605/** Dummy conversion used when the source is muted. */
    622 AUDMIXBUF_MACRO_FN uint32_t audioMixBufConvFromSilence(PPDMAUDIOSAMPLE paDst, const void *pvSrc,
    623                                                        uint32_t cbSrc, const PPDMAUDMIXBUF_CONVOPTS pOpts)
     606static DECLCALLBACK(uint32_t) audioMixBufConvFromSilence(PPDMAUDIOSAMPLE paDst, const void *pvSrc,
     607                                                         uint32_t cbSrc, PCPDMAUDMIXBUFCONVOPTS pOpts)
    624608{
    625609    /* Internally zero always corresponds to silence. */
     
    637621 * @param   enmFmt                  Audio format to lookup conversion macro for.
    638622 */
    639 static PPDMAUDMIXBUF_FN_CONVFROM audioMixBufConvFromLookup(PDMAUDIOMIXBUFFMT enmFmt)
     623static PFNPDMAUDIOMIXBUFCONVFROM audioMixBufConvFromLookup(PDMAUDIOMIXBUFFMT enmFmt)
    640624{
    641625    if (AUDMIXBUF_FMT_SIGNED(enmFmt))
     
    698682 * @param   enmFmt                  Audio format to lookup conversion macro for.
    699683 */
    700 static PPDMAUDMIXBUF_FN_CONVTO audioMixBufConvToLookup(PDMAUDIOMIXBUFFMT enmFmt)
     684static PFNPDMAUDIOMIXBUFCONVTO audioMixBufConvToLookup(PDMAUDIOMIXBUFFMT enmFmt)
    701685{
    702686    if (AUDMIXBUF_FMT_SIGNED(enmFmt))
     
    792776                                                 pProps->fSigned);
    793777
    794     pMixBuf->pConvFrom = audioMixBufConvFromLookup(pMixBuf->AudioFmt);
    795     pMixBuf->pConvTo   = audioMixBufConvToLookup(pMixBuf->AudioFmt);
     778    pMixBuf->pfnConvFrom = audioMixBufConvFromLookup(pMixBuf->AudioFmt);
     779    pMixBuf->pfnConvTo   = audioMixBufConvToLookup(pMixBuf->AudioFmt);
    796780
    797781    pMixBuf->cShift = pProps->cShift;
     
    13021286    if (cToProcess)
    13031287    {
    1304         PPDMAUDMIXBUF_FN_CONVTO pConv;
     1288        PFNPDMAUDIOMIXBUFCONVTO pfnConv;
    13051289        if (pMixBuf->AudioFmt != enmFmt)
    1306             pConv = audioMixBufConvToLookup(enmFmt);
     1290            pfnConv = audioMixBufConvToLookup(enmFmt);
    13071291        else
    1308             pConv = pMixBuf->pConvTo;
    1309 
    1310         if (pConv)
     1292            pfnConv = pMixBuf->pfnConvTo;
     1293
     1294        if (pfnConv)
    13111295        {
    1312             PDMAUDMIXBUF_CONVOPTS convOpts = { cToProcess, pMixBuf->Volume };
    1313 
    1314             AssertPtr(pConv);
    1315             pConv(pvBuf, pMixBuf->pSamples + offSamples, &convOpts);
     1296            PDMAUDMIXBUFCONVOPTS convOpts = { cToProcess, pMixBuf->Volume };
     1297
     1298            AssertPtr(pfnConv);
     1299            pfnConv(pvBuf, pMixBuf->pSamples + offSamples, &convOpts);
    13161300
    13171301#ifdef DEBUG
     
    13891373    }
    13901374
    1391     PPDMAUDMIXBUF_FN_CONVTO pConv = audioMixBufConvToLookup(enmFmt);
    1392     if (!pConv) /* Audio format not supported. */
     1375    PFNPDMAUDIOMIXBUFCONVTO pfnConv = audioMixBufConvToLookup(enmFmt);
     1376    if (!pfnConv) /* Audio format not supported. */
    13931377        return VERR_NOT_SUPPORTED;
    13941378
     
    14141398    }
    14151399
    1416     PDMAUDMIXBUF_CONVOPTS convOpts;
     1400    PDMAUDMIXBUFCONVOPTS convOpts;
    14171401    convOpts.Volume = pMixBuf->Volume;
    14181402
     
    14241408
    14251409        AUDMIXBUF_LOG(("P1: offRead=%RU32, cToRead=%RU32\n", pMixBuf->offRead, cLenSrc1));
    1426         pConv(pvBuf, pSamplesSrc1, &convOpts);
     1410        pfnConv(pvBuf, pSamplesSrc1, &convOpts);
    14271411    }
    14281412
     
    14371421        AUDMIXBUF_LOG(("P2: cToRead=%RU32, offWrite=%RU32 (%zu bytes)\n", cLenSrc2, cLenSrc1,
    14381422                       AUDIOMIXBUF_S2B(pMixBuf, cLenSrc1)));
    1439         pConv((uint8_t *)pvBuf + AUDIOMIXBUF_S2B(pMixBuf, cLenSrc1), pSamplesSrc2, &convOpts);
     1423        pfnConv((uint8_t *)pvBuf + AUDIOMIXBUF_S2B(pMixBuf, cLenSrc1), pSamplesSrc2, &convOpts);
    14401424    }
    14411425
     
    15931577int AudioMixBufWriteAt(PPDMAUDIOMIXBUF pMixBuf, uint32_t offSamples, const void *pvBuf, uint32_t cbBuf, uint32_t *pcWritten)
    15941578{
    1595     return AudioMixBufWriteAtEx(pMixBuf, pMixBuf->AudioFmt,
    1596                                 offSamples, pvBuf, cbBuf, pcWritten);
    1597 }
    1598 
    1599 /**
    1600  * Writes audio samples at a specific offset. The audio sample format
    1601  * to be written can be different from the audio format the mixing buffer
    1602  * operates on.
     1579    return AudioMixBufWriteAtEx(pMixBuf, pMixBuf->AudioFmt, offSamples, pvBuf, cbBuf, pcWritten);
     1580}
     1581
     1582/**
     1583 * Writes audio samples at a specific offset.
     1584 *
     1585 * The audio sample format to be written can be different from the audio format
     1586 * the mixing buffer operates on.
    16031587 *
    16041588 * @return  IPRT status code.
     
    16191603    /* pcWritten is optional. */
    16201604
     1605    /*
     1606     * Adjust cToWrite so we don't overflow our buffers.
     1607     */
     1608    int rc;
    16211609    uint32_t cToWrite = AUDIOMIXBUF_B2S(pMixBuf, cbBuf);
    1622 
    1623     int rc = VINF_SUCCESS;
    1624 
    1625     if (offSamples + cToWrite > pMixBuf->cSamples)
     1610    if (offSamples <= pMixBuf->cSamples)
     1611    {
     1612        if (offSamples + cToWrite <= pMixBuf->cSamples)
     1613            rc = VINF_SUCCESS;
     1614        else
     1615        {
     1616            rc = VINF_BUFFER_OVERFLOW;
     1617            cToWrite = pMixBuf->cSamples - offSamples;
     1618        }
     1619    }
     1620    else
     1621    {
    16261622        rc = VINF_BUFFER_OVERFLOW;
    1627 
    1628     cToWrite = RT_MIN(cToWrite, pMixBuf->cSamples - offSamples);
    1629 
    1630     PPDMAUDMIXBUF_FN_CONVFROM pConv;
    1631     if (pMixBuf->AudioFmt != enmFmt)
    1632         pConv = audioMixBufConvFromLookup(enmFmt);
    1633     else
    1634     {
    1635         pConv = pMixBuf->Volume.fMuted
    1636               ? &audioMixBufConvFromSilence : pMixBuf->pConvFrom;
    1637     }
    1638 
    1639     if (!pConv)
    1640         rc = VERR_NOT_SUPPORTED;
    1641 
    1642     uint32_t cWritten;
     1623        cToWrite = 0;
     1624    }
    16431625
    16441626#ifdef AUDIOMIXBUF_DEBUG_DUMP_PCM_DATA
    1645     RTFILE fh;
    1646     int rc2 = RTFileOpen(&fh, AUDIOMIXBUF_DEBUG_DUMP_PCM_DATA_PATH "mixbuf_writeat.pcm",
     1627    /*
     1628     * Now that we know how much we'll be converting we can log it.
     1629     */
     1630    RTFILE hFile;
     1631    int rc2 = RTFileOpen(&hFile, AUDIOMIXBUF_DEBUG_DUMP_PCM_DATA_PATH "mixbuf_writeat.pcm",
    16471632                         RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
    16481633    if (RT_SUCCESS(rc2))
    16491634    {
    1650         RTFileWrite(fh, pvBuf, AUDIOMIXBUF_S2B(pMixBuf, cToWrite), NULL);
    1651         RTFileClose(fh);
    1652     }
    1653 #endif
    1654 
    1655     if (   pConv
     1635        RTFileWrite(hFile, pvBuf, AUDIOMIXBUF_S2B(pMixBuf, cToWrite), NULL);
     1636        RTFileClose(hFile);
     1637    }
     1638#endif
     1639
     1640    /*
     1641     * Pick the conversion function and do the conversion.
     1642     */
     1643    PFNPDMAUDIOMIXBUFCONVFROM pfnConv;
     1644    if (pMixBuf->AudioFmt != enmFmt)
     1645        pfnConv = audioMixBufConvFromLookup(enmFmt);
     1646    else
     1647        pfnConv = pMixBuf->Volume.fMuted ? &audioMixBufConvFromSilence : pMixBuf->pfnConvFrom;
     1648
     1649    uint32_t cWritten;
     1650    if (   pfnConv
    16561651        && cToWrite)
    16571652    {
    1658         PDMAUDMIXBUF_CONVOPTS convOpts = { cToWrite, pMixBuf->Volume };
    1659 
    1660         cWritten = pConv(pMixBuf->pSamples + offSamples, pvBuf, AUDIOMIXBUF_S2B(pMixBuf, cToWrite), &convOpts);
     1653        PDMAUDMIXBUFCONVOPTS convOpts = { cToWrite, pMixBuf->Volume };
     1654        cWritten = pfnConv(pMixBuf->pSamples + offSamples, pvBuf, AUDIOMIXBUF_S2B(pMixBuf, cToWrite), &convOpts);
    16611655    }
    16621656    else
     1657    {
    16631658        cWritten = 0;
     1659        if (!pfnConv)
     1660            rc = VERR_NOT_SUPPORTED;
     1661    }
    16641662
    16651663#ifdef DEBUG
     
    16721670                   cWritten, AUDIOMIXBUF_S2B(pMixBuf, cWritten), rc));
    16731671
    1674     if (RT_SUCCESS(rc))
    1675     {
    1676         if (pcWritten)
    1677             *pcWritten = cWritten;
    1678     }
     1672    if (RT_SUCCESS(rc) && pcWritten)
     1673        *pcWritten = cWritten;
    16791674
    16801675    return rc;
     
    16821677
    16831678/**
    1684  * Writes audio samples. The sample format being written must match the
    1685  * format of the mixing buffer.
     1679 * Writes audio samples.
     1680 *
     1681 * The sample format being written must match the format of the mixing buffer.
    16861682 *
    16871683 * @return  IPRT status code, or VINF_BUFFER_OVERFLOW if samples which not have
     
    17411737    }
    17421738
    1743     PPDMAUDMIXBUF_FN_CONVFROM pCnvFrm;
     1739    PFNPDMAUDIOMIXBUFCONVFROM pfnCnvFrm;
    17441740    if (pMixBuf->AudioFmt != enmFmt)
    1745         pCnvFrm = audioMixBufConvFromLookup(enmFmt);
     1741        pfnCnvFrm = audioMixBufConvFromLookup(enmFmt);
    17461742    else
    1747     {
    1748         pCnvFrm = pMixBuf->Volume.fMuted
    1749                 ? &audioMixBufConvFromSilence : pMixBuf->pConvFrom;
    1750     }
    1751 
    1752     if (!pCnvFrm)
     1743        pfnCnvFrm = pMixBuf->Volume.fMuted ? &audioMixBufConvFromSilence : pMixBuf->pfnConvFrom;
     1744
     1745    if (!pfnCnvFrm)
    17531746        return VERR_NOT_SUPPORTED;
    17541747
    1755     int rc = VINF_SUCCESS;
     1748    int rc = VINF_SUCCESS; /** @todo Move this down to where you actually need it and you'll get somewhat nice code! */
    17561749
    17571750    uint32_t cToWrite = AUDIOMIXBUF_B2S(pMixBuf, cbBuf);
     
    17921785    uint32_t cWrittenTotal = 0;
    17931786
    1794     PDMAUDMIXBUF_CONVOPTS convOpts;
     1787    PDMAUDMIXBUFCONVOPTS convOpts;
    17951788    convOpts.Volume = pMixBuf->Volume;
    17961789
     
    17991792    {
    18001793        convOpts.cSamples = cLenDst1;
    1801         cWrittenTotal = pCnvFrm(pSamplesDst1, pvBuf, AUDIOMIXBUF_S2B(pMixBuf, cLenDst1), &convOpts);
     1794        cWrittenTotal = pfnCnvFrm(pSamplesDst1, pvBuf, AUDIOMIXBUF_S2B(pMixBuf, cLenDst1), &convOpts);
    18021795        Assert(cWrittenTotal == cLenDst1);
    18031796
     
    18081801
    18091802    /* Second part present? */
    1810     if (   RT_LIKELY(RT_SUCCESS(rc))
     1803    if (   RT_LIKELY(RT_SUCCESS(rc)) /** @todo r=bird: RT_SUCCESS implies RT_LIKELY for at least 10 years now. besides, it's actually always VINF_SUCCESS at this point. */
    18111804        && cLenDst2)
    18121805    {
     
    18141807
    18151808        convOpts.cSamples = cLenDst2;
    1816         cWrittenTotal += pCnvFrm(pSamplesDst2,
    1817                                  (uint8_t *)pvBuf + AUDIOMIXBUF_S2B(pMixBuf, cLenDst1),
    1818                                  cbBuf - AUDIOMIXBUF_S2B(pMixBuf, cLenDst1),
    1819                                  &convOpts);
    1820         Assert(cWrittenTotal == (cLenDst1 + cLenDst2));
     1809        cWrittenTotal += pfnCnvFrm(pSamplesDst2,
     1810                                   (uint8_t *)pvBuf + AUDIOMIXBUF_S2B(pMixBuf, cLenDst1),
     1811                                   cbBuf - AUDIOMIXBUF_S2B(pMixBuf, cLenDst1),
     1812                                   &convOpts);
     1813        Assert(cWrittenTotal == cLenDst1 + cLenDst2);
    18211814
    18221815#ifdef AUDIOMIXBUF_DEBUG_DUMP_PCM_DATA
  • trunk/src/VBox/Devices/Audio/testcase/Makefile.kmk

    r56085 r61352  
    2525
    2626 tstAudioMixBuffer_TEMPLATE = VBOXR3TSTEXE
    27  tstAudioMixBuffer_DEFS    += TESTCASE
    28  tstAudioMixBuffer_SOURCES  = \
     27 tstAudioMixBuffer_DEFS = TESTCASE
     28 tstAudioMixBuffer_DEFS.debug  = VBOX_WITH_EF_WRAPS
     29 tstAudioMixBuffer_SOURCES = \
    2930        tstAudioMixBuffer.cpp \
    3031        ../AudioMixBuffer.cpp \
    3132        ../DrvAudioCommon.cpp
    32  tstAudioMixBuffer_LIBS     = $(LIB_RUNTIME)
     33 tstAudioMixBuffer_LIBS = $(LIB_RUNTIME)
    3334
    3435 $$(tstAudioMixBuffer_0_OUTDIR)/tstAudioMixBuffer.run: $$(tstAudioMixBuffer_1_STAGE_TARGET)
  • trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp

    r61343 r61352  
    9090    /* Beyond buffer. */
    9191    RTTESTI_CHECK_RC(AudioMixBufWriteAt(&mb, AudioMixBufSize(&mb) + 1, &samples16, sizeof(samples16),
    92                                         &written), VERR_BUFFER_OVERFLOW);
     92                                        &written), VINF_BUFFER_OVERFLOW);
     93    /** @todo (bird): this was checking for VERR_BUFFER_OVERFLOW, which do you want
     94     *        the function to actually return? */
    9395
    9496    /*
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