Index: /trunk/include/VBox/vmm/pdmaudioifs.h
===================================================================
--- /trunk/include/VBox/vmm/pdmaudioifs.h	(revision 61351)
+++ /trunk/include/VBox/vmm/pdmaudioifs.h	(revision 61352)
@@ -92,5 +92,9 @@
     int64_t i64LSample;
     int64_t i64RSample;
-} PDMAUDIOSAMPLE, *PPDMAUDIOSAMPLE;
+} PDMAUDIOSAMPLE;
+/** Pointer to a single (stereo) audio sample.   */
+typedef PDMAUDIOSAMPLE *PPDMAUDIOSAMPLE;
+/** Pointer to a const single (stereo) audio sample.   */
+typedef PDMAUDIOSAMPLE const *PCPDMAUDIOSAMPLE;
 
 typedef enum PDMAUDIOENDIANNESS
@@ -344,5 +348,5 @@
  * the audioMixBufConvFromXXX / audioMixBufConvToXXX macros.
  */
-typedef struct PDMAUDMIXBUF_CONVOPTS
+typedef struct PDMAUDMIXBUFCONVOPTS
 {
     /** Number of audio samples to convert. */
@@ -352,5 +356,9 @@
      *  all conversion functions. */
     PDMAUDIOVOLUME Volume;
-} PDMAUDMIXBUF_CONVOPTS, *PPDMAUDMIXBUF_CONVOPTS;
+} PDMAUDMIXBUFCONVOPTS;
+/** Pointer to conversion parameters for the audio mixer.   */
+typedef PDMAUDMIXBUFCONVOPTS *PPDMAUDMIXBUFCONVOPTS;
+/** Pointer to const conversion parameters for the audio mixer.   */
+typedef PDMAUDMIXBUFCONVOPTS const *PCPDMAUDMIXBUFCONVOPTS;
 
 /**
@@ -361,13 +369,28 @@
 typedef PDMAUDIOMIXBUFFMT *PPDMAUDIOMIXBUFFMT;
 
-/** Function pointer definition for a conversion-from routine
- *  used by the PDM audio mixing buffer. */
-typedef uint32_t (PDMAUDMIXBUF_FN_CONVFROM) (PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, const PPDMAUDMIXBUF_CONVOPTS pOpts);
-typedef PDMAUDMIXBUF_FN_CONVFROM *PPDMAUDMIXBUF_FN_CONVFROM;
-
-/** Function definition for a conversion-to routine
- *  used by the PDM audio mixing buffer. */
-typedef void (PDMAUDMIXBUF_FN_CONVTO) (void *pvDst, const PPDMAUDIOSAMPLE paSrc, const PPDMAUDMIXBUF_CONVOPTS pOpts);
-typedef PDMAUDMIXBUF_FN_CONVTO *PPDMAUDMIXBUF_FN_CONVTO;
+/**
+ * Convertion-from function used by the PDM audio buffer mixer.
+ *
+ * @returns Number of samples returned.
+ * @param   paDst           Where to return the converted samples.
+ * @param   pvSrc           The source samples bytes.
+ * @param   cbSrc           Number of bytes to convert.
+ * @param   pOpts           Conversion options.
+ */
+typedef DECLCALLBACK(uint32_t) FNPDMAUDIOMIXBUFCONVFROM(PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc,
+                                                        PCPDMAUDMIXBUFCONVOPTS pOpts);
+/** Pointer to a convertion-from function used by the PDM audio buffer mixer. */
+typedef FNPDMAUDIOMIXBUFCONVFROM *PFNPDMAUDIOMIXBUFCONVFROM;
+
+/**
+ * Convertion-to function used by the PDM audio buffer mixer.
+ *
+ * @param   pvDst           Output buffer.
+ * @param   paSrc           The input samples.
+ * @param   pOpts           Conversion options.
+ */
+typedef DECLCALLBACK(void) FNPDMAUDIOMIXBUFCONVTO(void *pvDst, PCPDMAUDIOSAMPLE paSrc, PCPDMAUDMIXBUFCONVOPTS pOpts);
+/** Pointer to a convertion-to function used by the PDM audio buffer mixer. */
+typedef FNPDMAUDIOMIXBUFCONVTO *PFNPDMAUDIOMIXBUFCONVTO;
 
 typedef struct PDMAUDIOMIXBUF *PPDMAUDIOMIXBUF;
@@ -408,7 +431,7 @@
     PDMAUDIOMIXBUFFMT         AudioFmt;
     /** Standard conversion-to function for set AudioFmt. */
-    PPDMAUDMIXBUF_FN_CONVTO   pConvTo;
+    PFNPDMAUDIOMIXBUFCONVTO   pfnConvTo;
     /** Standard conversion-from function for set AudioFmt. */
-    PPDMAUDMIXBUF_FN_CONVFROM pConvFrom;
+    PFNPDMAUDIOMIXBUFCONVFROM pfnConvFrom;
     /**
      * Ratio of the associated parent stream's frequency by this stream's
Index: /trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp	(revision 61351)
+++ /trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp	(revision 61352)
@@ -132,15 +132,4 @@
 AssertCompile(AUDIOMIXBUF_VOL_0DB == 0x40000000);   /* For now -- when only attenuation is used. */
 
-/*
- * When running the audio testcases we want to verfiy
- * the macro-generated routines separately, so unmark them as being
- * inlined + static.
- */
-#ifdef VBOX_AUDIO_TESTCASE
-# define AUDMIXBUF_MACRO_FN
-#else
-# define AUDMIXBUF_MACRO_FN static inline
-#endif
-
 #ifdef DEBUG
 static uint64_t s_cSamplesMixedTotal = 0;
@@ -385,14 +374,11 @@
 
     size_t cbSamples = cSamples * sizeof(PDMAUDIOSAMPLE);
-    if (!cbSamples)
-        return VERR_INVALID_PARAMETER;
-
     pMixBuf->pSamples = (PPDMAUDIOSAMPLE)RTMemAllocZ(cbSamples);
-    if (!pMixBuf->pSamples)
-        return VERR_NO_MEMORY;
-
-    pMixBuf->cSamples = cSamples;
-
-    return VINF_SUCCESS;
+    if (pMixBuf->pSamples)
+    {
+        pMixBuf->cSamples = cSamples;
+        return VINF_SUCCESS;
+    }
+    return VERR_NO_MEMORY;
 }
 
@@ -414,5 +400,5 @@
 #define AUDMIXBUF_CONVERT(_aName, _aType, _aMin, _aMax, _aSigned, _aShift) \
     /* Clips a specific output value to a single sample value. */ \
-    AUDMIXBUF_MACRO_FN int64_t audioMixBufClipFrom##_aName(_aType aVal) \
+    DECLCALLBACK(int64_t) audioMixBufClipFrom##_aName(_aType aVal) \
     { \
         if (_aSigned) \
@@ -422,9 +408,9 @@
     \
     /* Clips a single sample value to a specific output value. */ \
-    AUDMIXBUF_MACRO_FN _aType audioMixBufClipTo##_aName(int64_t iVal) \
+    DECLCALLBACK(_aType) audioMixBufClipTo##_aName(int64_t iVal) \
     { \
         if (iVal >= 0x7fffffff) \
             return _aMax; \
-        else if (iVal < -INT64_C(0x80000000)) \
+        if (iVal < -INT64_C(0x80000000)) \
             return _aMin; \
         \
@@ -434,9 +420,9 @@
     } \
     \
-    AUDMIXBUF_MACRO_FN uint32_t audioMixBufConvFrom##_aName##Stereo(PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, \
-                                                                    const PPDMAUDMIXBUF_CONVOPTS pOpts) \
+    DECLCALLBACK(uint32_t) audioMixBufConvFrom##_aName##Stereo(PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, \
+                                                               PCPDMAUDMIXBUFCONVOPTS pOpts) \
     { \
-        _aType *pSrc = (_aType *)pvSrc; \
-        uint32_t cSamples = (uint32_t)RT_MIN(pOpts->cSamples, cbSrc / sizeof(_aType)); \
+        _aType const *pSrc = (_aType const *)pvSrc; \
+        uint32_t cSamples = RT_MIN(pOpts->cSamples, cbSrc / sizeof(_aType)); \
         AUDMIXBUF_MACRO_LOG(("cSamples=%RU32, BpS=%zu, lVol=%RU32, rVol=%RU32\n", \
                              pOpts->cSamples, sizeof(_aType), pOpts->Volume.uLeft, pOpts->Volume.uRight)); \
@@ -453,9 +439,9 @@
     } \
     \
-    AUDMIXBUF_MACRO_FN uint32_t audioMixBufConvFrom##_aName##Mono(PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, \
-                                                                  const PPDMAUDMIXBUF_CONVOPTS pOpts) \
+    DECLCALLBACK(uint32_t) audioMixBufConvFrom##_aName##Mono(PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, \
+                                                             PCPDMAUDMIXBUFCONVOPTS pOpts) \
     { \
-        _aType *pSrc = (_aType *)pvSrc; \
-        const uint32_t cSamples = (uint32_t)RT_MIN(pOpts->cSamples, cbSrc / sizeof(_aType)); \
+        _aType const *pSrc = (_aType const *)pvSrc; \
+        const uint32_t cSamples = RT_MIN(pOpts->cSamples, cbSrc / sizeof(_aType)); \
         AUDMIXBUF_MACRO_LOG(("cSamples=%RU32, BpS=%zu, lVol=%RU32, rVol=%RU32\n", \
                              cSamples, sizeof(_aType), pOpts->Volume.uLeft >> 14, pOpts->Volume.uRight)); \
@@ -472,8 +458,7 @@
     } \
     \
-    AUDMIXBUF_MACRO_FN void audioMixBufConvTo##_aName##Stereo(void *pvDst, const PPDMAUDIOSAMPLE paSrc, \
-                                                              const PPDMAUDMIXBUF_CONVOPTS pOpts) \
+    DECLCALLBACK(void) audioMixBufConvTo##_aName##Stereo(void *pvDst, PCPDMAUDIOSAMPLE paSrc, PCPDMAUDMIXBUFCONVOPTS pOpts) \
     { \
-        PPDMAUDIOSAMPLE pSrc = paSrc; \
+        PCPDMAUDIOSAMPLE pSrc = paSrc; \
         _aType *pDst = (_aType *)pvDst; \
         _aType l, r; \
@@ -491,8 +476,7 @@
     } \
     \
-    AUDMIXBUF_MACRO_FN void audioMixBufConvTo##_aName##Mono(void *pvDst, const PPDMAUDIOSAMPLE paSrc, \
-                                                            const PPDMAUDMIXBUF_CONVOPTS pOpts) \
+    DECLCALLBACK(void) audioMixBufConvTo##_aName##Mono(void *pvDst, PCPDMAUDIOSAMPLE paSrc, PCPDMAUDMIXBUFCONVOPTS pOpts) \
     { \
-        PPDMAUDIOSAMPLE pSrc = paSrc; \
+        PCPDMAUDIOSAMPLE pSrc = paSrc; \
         _aType *pDst = (_aType *)pvDst; \
         uint32_t cSamples = pOpts->cSamples; \
@@ -520,8 +504,8 @@
 
 #define AUDMIXBUF_MIXOP(_aName, _aOp) \
-    AUDMIXBUF_MACRO_FN void audioMixBufOp##_aName(PPDMAUDIOSAMPLE paDst, uint32_t cDstSamples, \
-                                                  PPDMAUDIOSAMPLE paSrc, uint32_t cSrcSamples, \
-                                                  PPDMAUDIOSTRMRATE pRate, \
-                                                  uint32_t *pcDstWritten, uint32_t *pcSrcRead) \
+    static void audioMixBufOp##_aName(PPDMAUDIOSAMPLE paDst, uint32_t cDstSamples, \
+                                      PPDMAUDIOSAMPLE paSrc, uint32_t cSrcSamples, \
+                                      PPDMAUDIOSTRMRATE pRate, \
+                                      uint32_t *pcDstWritten, uint32_t *pcSrcRead) \
     { \
         AUDMIXBUF_MACRO_LOG(("cSrcSamples=%RU32, cDstSamples=%RU32\n", cSrcSamples, cDstSamples)); \
@@ -620,6 +604,6 @@
 
 /** Dummy conversion used when the source is muted. */
-AUDMIXBUF_MACRO_FN uint32_t audioMixBufConvFromSilence(PPDMAUDIOSAMPLE paDst, const void *pvSrc,
-                                                       uint32_t cbSrc, const PPDMAUDMIXBUF_CONVOPTS pOpts)
+static DECLCALLBACK(uint32_t) audioMixBufConvFromSilence(PPDMAUDIOSAMPLE paDst, const void *pvSrc,
+                                                         uint32_t cbSrc, PCPDMAUDMIXBUFCONVOPTS pOpts)
 {
     /* Internally zero always corresponds to silence. */
@@ -637,5 +621,5 @@
  * @param   enmFmt                  Audio format to lookup conversion macro for.
  */
-static PPDMAUDMIXBUF_FN_CONVFROM audioMixBufConvFromLookup(PDMAUDIOMIXBUFFMT enmFmt)
+static PFNPDMAUDIOMIXBUFCONVFROM audioMixBufConvFromLookup(PDMAUDIOMIXBUFFMT enmFmt)
 {
     if (AUDMIXBUF_FMT_SIGNED(enmFmt))
@@ -698,5 +682,5 @@
  * @param   enmFmt                  Audio format to lookup conversion macro for.
  */
-static PPDMAUDMIXBUF_FN_CONVTO audioMixBufConvToLookup(PDMAUDIOMIXBUFFMT enmFmt)
+static PFNPDMAUDIOMIXBUFCONVTO audioMixBufConvToLookup(PDMAUDIOMIXBUFFMT enmFmt)
 {
     if (AUDMIXBUF_FMT_SIGNED(enmFmt))
@@ -792,6 +776,6 @@
                                                  pProps->fSigned);
 
-    pMixBuf->pConvFrom = audioMixBufConvFromLookup(pMixBuf->AudioFmt);
-    pMixBuf->pConvTo   = audioMixBufConvToLookup(pMixBuf->AudioFmt);
+    pMixBuf->pfnConvFrom = audioMixBufConvFromLookup(pMixBuf->AudioFmt);
+    pMixBuf->pfnConvTo   = audioMixBufConvToLookup(pMixBuf->AudioFmt);
 
     pMixBuf->cShift = pProps->cShift;
@@ -1302,16 +1286,16 @@
     if (cToProcess)
     {
-        PPDMAUDMIXBUF_FN_CONVTO pConv;
+        PFNPDMAUDIOMIXBUFCONVTO pfnConv;
         if (pMixBuf->AudioFmt != enmFmt)
-            pConv = audioMixBufConvToLookup(enmFmt);
+            pfnConv = audioMixBufConvToLookup(enmFmt);
         else
-            pConv = pMixBuf->pConvTo;
-
-        if (pConv)
+            pfnConv = pMixBuf->pfnConvTo;
+
+        if (pfnConv)
         {
-            PDMAUDMIXBUF_CONVOPTS convOpts = { cToProcess, pMixBuf->Volume };
-
-            AssertPtr(pConv);
-            pConv(pvBuf, pMixBuf->pSamples + offSamples, &convOpts);
+            PDMAUDMIXBUFCONVOPTS convOpts = { cToProcess, pMixBuf->Volume };
+
+            AssertPtr(pfnConv);
+            pfnConv(pvBuf, pMixBuf->pSamples + offSamples, &convOpts);
 
 #ifdef DEBUG
@@ -1389,6 +1373,6 @@
     }
 
-    PPDMAUDMIXBUF_FN_CONVTO pConv = audioMixBufConvToLookup(enmFmt);
-    if (!pConv) /* Audio format not supported. */
+    PFNPDMAUDIOMIXBUFCONVTO pfnConv = audioMixBufConvToLookup(enmFmt);
+    if (!pfnConv) /* Audio format not supported. */
         return VERR_NOT_SUPPORTED;
 
@@ -1414,5 +1398,5 @@
     }
 
-    PDMAUDMIXBUF_CONVOPTS convOpts;
+    PDMAUDMIXBUFCONVOPTS convOpts;
     convOpts.Volume = pMixBuf->Volume;
 
@@ -1424,5 +1408,5 @@
 
         AUDMIXBUF_LOG(("P1: offRead=%RU32, cToRead=%RU32\n", pMixBuf->offRead, cLenSrc1));
-        pConv(pvBuf, pSamplesSrc1, &convOpts);
+        pfnConv(pvBuf, pSamplesSrc1, &convOpts);
     }
 
@@ -1437,5 +1421,5 @@
         AUDMIXBUF_LOG(("P2: cToRead=%RU32, offWrite=%RU32 (%zu bytes)\n", cLenSrc2, cLenSrc1,
                        AUDIOMIXBUF_S2B(pMixBuf, cLenSrc1)));
-        pConv((uint8_t *)pvBuf + AUDIOMIXBUF_S2B(pMixBuf, cLenSrc1), pSamplesSrc2, &convOpts);
+        pfnConv((uint8_t *)pvBuf + AUDIOMIXBUF_S2B(pMixBuf, cLenSrc1), pSamplesSrc2, &convOpts);
     }
 
@@ -1593,12 +1577,12 @@
 int AudioMixBufWriteAt(PPDMAUDIOMIXBUF pMixBuf, uint32_t offSamples, const void *pvBuf, uint32_t cbBuf, uint32_t *pcWritten)
 {
-    return AudioMixBufWriteAtEx(pMixBuf, pMixBuf->AudioFmt,
-                                offSamples, pvBuf, cbBuf, pcWritten);
-}
-
-/**
- * Writes audio samples at a specific offset. The audio sample format
- * to be written can be different from the audio format the mixing buffer
- * operates on.
+    return AudioMixBufWriteAtEx(pMixBuf, pMixBuf->AudioFmt, offSamples, pvBuf, cbBuf, pcWritten);
+}
+
+/**
+ * Writes audio samples at a specific offset.
+ *
+ * The audio sample format to be written can be different from the audio format
+ * the mixing buffer operates on.
  *
  * @return  IPRT status code.
@@ -1619,47 +1603,61 @@
     /* pcWritten is optional. */
 
+    /*
+     * Adjust cToWrite so we don't overflow our buffers.
+     */
+    int rc;
     uint32_t cToWrite = AUDIOMIXBUF_B2S(pMixBuf, cbBuf);
-
-    int rc = VINF_SUCCESS;
-
-    if (offSamples + cToWrite > pMixBuf->cSamples)
+    if (offSamples <= pMixBuf->cSamples)
+    {
+        if (offSamples + cToWrite <= pMixBuf->cSamples)
+            rc = VINF_SUCCESS;
+        else
+        {
+            rc = VINF_BUFFER_OVERFLOW;
+            cToWrite = pMixBuf->cSamples - offSamples;
+        }
+    }
+    else
+    {
         rc = VINF_BUFFER_OVERFLOW;
-
-    cToWrite = RT_MIN(cToWrite, pMixBuf->cSamples - offSamples);
-
-    PPDMAUDMIXBUF_FN_CONVFROM pConv;
-    if (pMixBuf->AudioFmt != enmFmt)
-        pConv = audioMixBufConvFromLookup(enmFmt);
-    else
-    {
-        pConv = pMixBuf->Volume.fMuted
-              ? &audioMixBufConvFromSilence : pMixBuf->pConvFrom;
-    }
-
-    if (!pConv)
-        rc = VERR_NOT_SUPPORTED;
-
-    uint32_t cWritten;
+        cToWrite = 0;
+    }
 
 #ifdef AUDIOMIXBUF_DEBUG_DUMP_PCM_DATA
-    RTFILE fh;
-    int rc2 = RTFileOpen(&fh, AUDIOMIXBUF_DEBUG_DUMP_PCM_DATA_PATH "mixbuf_writeat.pcm",
+    /*
+     * Now that we know how much we'll be converting we can log it.
+     */
+    RTFILE hFile;
+    int rc2 = RTFileOpen(&hFile, AUDIOMIXBUF_DEBUG_DUMP_PCM_DATA_PATH "mixbuf_writeat.pcm",
                          RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
     if (RT_SUCCESS(rc2))
     {
-        RTFileWrite(fh, pvBuf, AUDIOMIXBUF_S2B(pMixBuf, cToWrite), NULL);
-        RTFileClose(fh);
-    }
-#endif
-
-    if (   pConv
+        RTFileWrite(hFile, pvBuf, AUDIOMIXBUF_S2B(pMixBuf, cToWrite), NULL);
+        RTFileClose(hFile);
+    }
+#endif
+
+    /*
+     * Pick the conversion function and do the conversion.
+     */
+    PFNPDMAUDIOMIXBUFCONVFROM pfnConv;
+    if (pMixBuf->AudioFmt != enmFmt)
+        pfnConv = audioMixBufConvFromLookup(enmFmt);
+    else
+        pfnConv = pMixBuf->Volume.fMuted ? &audioMixBufConvFromSilence : pMixBuf->pfnConvFrom;
+
+    uint32_t cWritten;
+    if (   pfnConv
         && cToWrite)
     {
-        PDMAUDMIXBUF_CONVOPTS convOpts = { cToWrite, pMixBuf->Volume };
-
-        cWritten = pConv(pMixBuf->pSamples + offSamples, pvBuf, AUDIOMIXBUF_S2B(pMixBuf, cToWrite), &convOpts);
+        PDMAUDMIXBUFCONVOPTS convOpts = { cToWrite, pMixBuf->Volume };
+        cWritten = pfnConv(pMixBuf->pSamples + offSamples, pvBuf, AUDIOMIXBUF_S2B(pMixBuf, cToWrite), &convOpts);
     }
     else
+    {
         cWritten = 0;
+        if (!pfnConv)
+            rc = VERR_NOT_SUPPORTED;
+    }
 
 #ifdef DEBUG
@@ -1672,9 +1670,6 @@
                    cWritten, AUDIOMIXBUF_S2B(pMixBuf, cWritten), rc));
 
-    if (RT_SUCCESS(rc))
-    {
-        if (pcWritten)
-            *pcWritten = cWritten;
-    }
+    if (RT_SUCCESS(rc) && pcWritten)
+        *pcWritten = cWritten;
 
     return rc;
@@ -1682,6 +1677,7 @@
 
 /**
- * Writes audio samples. The sample format being written must match the
- * format of the mixing buffer.
+ * Writes audio samples.
+ *
+ * The sample format being written must match the format of the mixing buffer.
  *
  * @return  IPRT status code, or VINF_BUFFER_OVERFLOW if samples which not have
@@ -1741,17 +1737,14 @@
     }
 
-    PPDMAUDMIXBUF_FN_CONVFROM pCnvFrm;
+    PFNPDMAUDIOMIXBUFCONVFROM pfnCnvFrm;
     if (pMixBuf->AudioFmt != enmFmt)
-        pCnvFrm = audioMixBufConvFromLookup(enmFmt);
+        pfnCnvFrm = audioMixBufConvFromLookup(enmFmt);
     else
-    {
-        pCnvFrm = pMixBuf->Volume.fMuted
-                ? &audioMixBufConvFromSilence : pMixBuf->pConvFrom;
-    }
-
-    if (!pCnvFrm)
+        pfnCnvFrm = pMixBuf->Volume.fMuted ? &audioMixBufConvFromSilence : pMixBuf->pfnConvFrom;
+
+    if (!pfnCnvFrm)
         return VERR_NOT_SUPPORTED;
 
-    int rc = VINF_SUCCESS;
+    int rc = VINF_SUCCESS; /** @todo Move this down to where you actually need it and you'll get somewhat nice code! */
 
     uint32_t cToWrite = AUDIOMIXBUF_B2S(pMixBuf, cbBuf);
@@ -1792,5 +1785,5 @@
     uint32_t cWrittenTotal = 0;
 
-    PDMAUDMIXBUF_CONVOPTS convOpts;
+    PDMAUDMIXBUFCONVOPTS convOpts;
     convOpts.Volume = pMixBuf->Volume;
 
@@ -1799,5 +1792,5 @@
     {
         convOpts.cSamples = cLenDst1;
-        cWrittenTotal = pCnvFrm(pSamplesDst1, pvBuf, AUDIOMIXBUF_S2B(pMixBuf, cLenDst1), &convOpts);
+        cWrittenTotal = pfnCnvFrm(pSamplesDst1, pvBuf, AUDIOMIXBUF_S2B(pMixBuf, cLenDst1), &convOpts);
         Assert(cWrittenTotal == cLenDst1);
 
@@ -1808,5 +1801,5 @@
 
     /* Second part present? */
-    if (   RT_LIKELY(RT_SUCCESS(rc))
+    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. */
         && cLenDst2)
     {
@@ -1814,9 +1807,9 @@
 
         convOpts.cSamples = cLenDst2;
-        cWrittenTotal += pCnvFrm(pSamplesDst2,
-                                 (uint8_t *)pvBuf + AUDIOMIXBUF_S2B(pMixBuf, cLenDst1),
-                                 cbBuf - AUDIOMIXBUF_S2B(pMixBuf, cLenDst1),
-                                 &convOpts);
-        Assert(cWrittenTotal == (cLenDst1 + cLenDst2));
+        cWrittenTotal += pfnCnvFrm(pSamplesDst2,
+                                   (uint8_t *)pvBuf + AUDIOMIXBUF_S2B(pMixBuf, cLenDst1),
+                                   cbBuf - AUDIOMIXBUF_S2B(pMixBuf, cLenDst1),
+                                   &convOpts);
+        Assert(cWrittenTotal == cLenDst1 + cLenDst2);
 
 #ifdef AUDIOMIXBUF_DEBUG_DUMP_PCM_DATA
Index: /trunk/src/VBox/Devices/Audio/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Devices/Audio/testcase/Makefile.kmk	(revision 61351)
+++ /trunk/src/VBox/Devices/Audio/testcase/Makefile.kmk	(revision 61352)
@@ -25,10 +25,11 @@
 
  tstAudioMixBuffer_TEMPLATE = VBOXR3TSTEXE
- tstAudioMixBuffer_DEFS    += TESTCASE
- tstAudioMixBuffer_SOURCES  = \
+ tstAudioMixBuffer_DEFS = TESTCASE
+ tstAudioMixBuffer_DEFS.debug  = VBOX_WITH_EF_WRAPS
+ tstAudioMixBuffer_SOURCES = \
 	tstAudioMixBuffer.cpp \
 	../AudioMixBuffer.cpp \
 	../DrvAudioCommon.cpp
- tstAudioMixBuffer_LIBS     = $(LIB_RUNTIME)
+ tstAudioMixBuffer_LIBS = $(LIB_RUNTIME)
 
  $$(tstAudioMixBuffer_0_OUTDIR)/tstAudioMixBuffer.run: $$(tstAudioMixBuffer_1_STAGE_TARGET)
Index: /trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp	(revision 61351)
+++ /trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp	(revision 61352)
@@ -90,5 +90,7 @@
     /* Beyond buffer. */
     RTTESTI_CHECK_RC(AudioMixBufWriteAt(&mb, AudioMixBufSize(&mb) + 1, &samples16, sizeof(samples16),
-                                        &written), VERR_BUFFER_OVERFLOW);
+                                        &written), VINF_BUFFER_OVERFLOW);
+    /** @todo (bird): this was checking for VERR_BUFFER_OVERFLOW, which do you want
+     *        the function to actually return? */
 
     /*
