Index: trunk/src/VBox/Devices/Audio/DrvAudio.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/DrvAudio.cpp	(revision 58372)
+++ trunk/src/VBox/Devices/Audio/DrvAudio.cpp	(revision 58378)
@@ -310,61 +310,73 @@
 }
 
-void drvAudioClearBuf(PPDMPCMPROPS pPCMInfo, void *pvBuf, size_t cbBuf)
-{
-    AssertPtrReturnVoid(pPCMInfo);
+/**
+ * Clears a sample buffer by the given amount of audio samples.
+ *
+ * @return  IPRT status code.
+ * @param   pPCMProps               PCM properties to use for the buffer to clear.
+ * @param   pvBuf                   Buffer to clear.
+ * @param   cbBuf                   Size (in bytes) of the buffer.
+ * @param   cSamples                Number of audio samples to clear in the buffer.
+ */
+void DrvAudioClearBuf(PPDMPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t cSamples)
+{
+    AssertPtrReturnVoid(pPCMProps);
     AssertPtrReturnVoid(pvBuf);
 
-    if (!cbBuf)
+    if (!cbBuf || !cSamples)
         return;
 
-    Log2Func(("pPCMInfo=%p, pvBuf=%p, cbBuf=%zu, fSigned=%RTbool, cBits=%RU8, cShift=%RU8\n",
-              pPCMInfo, pvBuf, cbBuf, pPCMInfo->fSigned, pPCMInfo->cBits, pPCMInfo->cShift));
-
-    if (pPCMInfo->fSigned)
-    {
-        memset(pvBuf, 0, cbBuf << pPCMInfo->cShift);
+    Log2Func(("pPCMInfo=%p, pvBuf=%p, cSamples=%RU32, fSigned=%RTbool, cBits=%RU8, cShift=%RU8\n",
+              pPCMProps, pvBuf, cSamples, pPCMProps->fSigned, pPCMProps->cBits, pPCMProps->cShift));
+
+    if (pPCMProps->fSigned)
+    {
+        memset(pvBuf, 0, cSamples << pPCMProps->cShift);
     }
     else
     {
-        switch (pPCMInfo->cBits)
-        {
-
-        case 8:
-            memset(pvBuf, 0x80, cbBuf << pPCMInfo->cShift);
-            break;
-
-        case 16:
-        {
-            uint16_t *p = (uint16_t *)pvBuf;
-            int shift = pPCMInfo->cChannels - 1;
-            short s = INT16_MAX;
-
-            if (pPCMInfo->fSwapEndian)
-                s = RT_BSWAP_U16(s);
-
-            for (unsigned i = 0; i < cbBuf << shift; i++)
-                p[i] = s;
-
-            break;
-        }
-
-        case 32:
-        {
-            uint32_t *p = (uint32_t *)pvBuf;
-            int shift = pPCMInfo->cChannels - 1;
-            int32_t s = INT32_MAX;
-
-            if (pPCMInfo->fSwapEndian)
-                s = RT_BSWAP_U32(s);
-
-            for (unsigned i = 0; i < cbBuf << shift; i++)
-                p[i] = s;
-
-            break;
-        }
-
-        default:
-            AssertMsgFailed(("Invalid bits: %RU8\n", pPCMInfo->cBits));
-            break;
+        switch (pPCMProps->cBits)
+        {
+            case 8:
+            {
+                memset(pvBuf, 0x80, cSamples << pPCMProps->cShift);
+                break;
+            }
+
+            case 16:
+            {
+                uint16_t *p = (uint16_t *)pvBuf;
+                int shift = pPCMProps->cChannels - 1;
+                short s = INT16_MAX;
+
+                if (pPCMProps->fSwapEndian)
+                    s = RT_BSWAP_U16(s);
+
+                for (unsigned i = 0; i < cSamples << shift; i++)
+                    p[i] = s;
+
+                break;
+            }
+
+            case 32:
+            {
+                uint32_t *p = (uint32_t *)pvBuf;
+                int shift = pPCMProps->cChannels - 1;
+                int32_t s = INT32_MAX;
+
+                if (pPCMProps->fSwapEndian)
+                    s = RT_BSWAP_U32(s);
+
+                for (unsigned i = 0; i < cSamples << shift; i++)
+                    p[i] = s;
+
+                break;
+            }
+
+            default:
+            {
+                AssertMsgFailed(("Invalid bits: %RU8\n", pPCMProps->cBits));
+                break;
+            }
         }
     }
@@ -639,5 +651,5 @@
     AssertPtrReturn(pCfg,         VERR_INVALID_POINTER);
 
-    int rc = drvAudioStreamCfgToProps(pCfg, &pGstStrmOut->Props);
+    int rc = DrvAudioStreamCfgToProps(pCfg, &pGstStrmOut->Props);
     if (RT_SUCCESS(rc))
     {
@@ -891,5 +903,5 @@
     AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
 
-    int rc = drvAudioStreamCfgToProps(pCfg, &pGstStrmIn->Props);
+    int rc = DrvAudioStreamCfgToProps(pCfg, &pGstStrmIn->Props);
     if (RT_SUCCESS(rc))
     {
@@ -1192,5 +1204,5 @@
     while ((pHstStrmOut = drvAudioHstFindAnyEnabledOut(pThis, pHstStrmOut)))
     {
-        cSamplesLive = drvAudioHstOutSamplesLive(pHstStrmOut);
+        cSamplesLive = AudioMixBufAvail(&pHstStrmOut->MixBuf);
 
         /* Has this stream marked as disabled but there still were guest streams relying
Index: trunk/src/VBox/Devices/Audio/DrvAudio.h
===================================================================
--- trunk/src/VBox/Devices/Audio/DrvAudio.h	(revision 58372)
+++ trunk/src/VBox/Devices/Audio/DrvAudio.h	(revision 58378)
@@ -110,5 +110,4 @@
 
 bool drvAudioPCMPropsAreEqual(PPDMPCMPROPS info, PPDMAUDIOSTREAMCFG pCfg);
-int drvAudioStreamCfgToProps(PPDMAUDIOSTREAMCFG pCfg, PPDMPCMPROPS pProps);
 void drvAudioStreamCfgPrint(PPDMAUDIOSTREAMCFG pCfg);
 
@@ -144,9 +143,6 @@
 
 /* Common functions between DrvAudio and backends (host audio drivers). */
-int  drvAudioAttachCapture(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMOUT pHstStrmOut);
-void drvAudioClearBuf(PPDMPCMPROPS pPCMInfo, void *pvBuf, size_t cbBuf);
-void drvAudioDetachCapture(PPDMAUDIOHSTSTRMOUT pHstStrmOut);
-uint32_t drvAudioHstOutSamplesLive(PPDMAUDIOHSTSTRMOUT pHstStrmOut);
-
+void DrvAudioClearBuf(PPDMPCMPROPS pPCMInfo, void *pvBuf, size_t cbBuf, uint32_t cSamples);
+int DrvAudioStreamCfgToProps(PPDMAUDIOSTREAMCFG pCfg, PPDMPCMPROPS pProps);
 
 typedef struct fixed_settings
Index: trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp	(revision 58372)
+++ trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp	(revision 58378)
@@ -309,6 +309,16 @@
 }
 
-int drvAudioStreamCfgToProps(PPDMAUDIOSTREAMCFG pCfg, PPDMPCMPROPS pProps)
-{
+/**
+ * Converts an audio stream configuration to matching PCM properties.
+ *
+ * @return  IPRT status code.
+ * @param   pCfg                    Audio stream configuration to convert.
+ * @param   pProps                  PCM properties to save result to.
+ */
+int DrvAudioStreamCfgToProps(PPDMAUDIOSTREAMCFG pCfg, PPDMPCMPROPS pProps)
+{
+    AssertPtrReturn(pCfg,   VERR_INVALID_POINTER);
+    AssertPtrReturn(pProps, VERR_INVALID_POINTER);
+
     int rc = VINF_SUCCESS;
 
@@ -407,20 +417,2 @@
     }
 }
-
-/**
- * Finds the number of live samples for a specific output stream.
- *
- * @return  uint32_t                Minimum number of live host output samples processed
- *                                  by all connected guest output streams.
- * @param   pHstStrmOut             Host output stream to search in.
- */
-uint32_t drvAudioHstOutSamplesLive(PPDMAUDIOHSTSTRMOUT pHstStrmOut)
-{
-    AssertPtrReturn(pHstStrmOut, 0);
-
-    uint32_t cSamplesLive = AudioMixBufAvail(&pHstStrmOut->MixBuf);
-
-    LogFlowFunc(("%s: cStreamsLive=%RU32, cSamplesLive=%RU32\n", pHstStrmOut->MixBuf.pszName, cSamplesLive));
-    return cSamplesLive;
-}
-
Index: trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp	(revision 58372)
+++ trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp	(revision 58378)
@@ -946,5 +946,5 @@
                                                  (uint32_t)cAvail), /* cAvail is always >= 0 */
                                  AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf,
-                                                 drvAudioHstOutSamplesLive(pHstStrmOut)));
+                                                 AudioMixBufAvail(&pHstStrmOut->MixBuf)));
         LogFlowFunc(("cbToRead=%zu, cbAvail=%zu\n",
                      cbToRead, AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, cAvail)));
@@ -1118,5 +1118,5 @@
         streamCfg.enmEndianness = enmEnd;
 
-        rc = drvAudioStreamCfgToProps(&streamCfg, &pHstStrmOut->Props);
+        rc = DrvAudioStreamCfgToProps(&streamCfg, &pHstStrmOut->Props);
         if (RT_FAILURE(rc))
             break;
@@ -1189,5 +1189,5 @@
         streamCfg.enmEndianness = enmEnd;
 
-        rc = drvAudioStreamCfgToProps(&streamCfg, &pHstStrmIn->Props);
+        rc = DrvAudioStreamCfgToProps(&streamCfg, &pHstStrmIn->Props);
         if (RT_FAILURE(rc))
             break;
Index: trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp	(revision 58372)
+++ trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp	(revision 58378)
@@ -1481,5 +1481,5 @@
     /* Not much else to do here. */
 
-    uint32_t cLive = drvAudioHstOutSamplesLive(pHstStrmOut);
+    uint32_t cLive = AudioMixBufAvail(&pHstStrmOut->MixBuf);;
     if (!cLive) /* Not samples to play? Bail out. */
     {
@@ -1508,5 +1508,5 @@
             RTCircBufReleaseWriteBlock(pStreamOut->pBuf, cbCopy);
             break;
-        }        
+        }
 
         Assert(cbCopy <= cbToRead);
@@ -1879,5 +1879,5 @@
 
     /* Initialize the hardware info section with the audio settings */
-    int rc = drvAudioStreamCfgToProps(pCfg, &pStreamIn->streamIn.Props);
+    int rc = DrvAudioStreamCfgToProps(pCfg, &pStreamIn->streamIn.Props);
     if (RT_SUCCESS(rc))
     {
@@ -1938,5 +1938,5 @@
 
     /* Initialize the hardware info section with the audio settings */
-    drvAudioStreamCfgToProps(pCfg, &pStreamOut->streamOut.Props);
+    DrvAudioStreamCfgToProps(pCfg, &pStreamOut->streamOut.Props);
 
 #if 0
Index: trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp	(revision 58372)
+++ trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp	(revision 58378)
@@ -514,19 +514,21 @@
     AssertPtrReturnVoid(pDSoundStrmOut);
 
+    PPDMAUDIOHSTSTRMOUT pStrmOut = &pDSoundStrmOut->strmOut;
+
     LPVOID pv1, pv2;
     DWORD cb1, cb2;
     HRESULT hr = directSoundPlayLock(pDSoundStrmOut->pDSB, &pDSoundStrmOut->strmOut.Props,
-                                     0, pDSoundStrmOut->csPlaybackBufferSize << pDSoundStrmOut->strmOut.Props.cShift,
+                                     0 /* dwOffset */, AUDIOMIXBUF_S2B(&pStrmOut->MixBuf, pDSoundStrmOut->csPlaybackBufferSize),
                                      &pv1, &pv2, &cb1, &cb2, DSBLOCK_ENTIREBUFFER);
     if (SUCCEEDED(hr))
     {
-        int len1 = cb1 >> pDSoundStrmOut->strmOut.Props.cShift;
-        int len2 = cb2 >> pDSoundStrmOut->strmOut.Props.cShift;
+        DWORD len1 = AUDIOMIXBUF_B2S(&pStrmOut->MixBuf, cb1);
+        DWORD len2 = AUDIOMIXBUF_B2S(&pStrmOut->MixBuf, cb2);
 
         if (pv1 && len1)
-            drvAudioClearBuf(&pDSoundStrmOut->strmOut.Props, pv1, len1);
+            DrvAudioClearBuf(&pDSoundStrmOut->strmOut.Props, pv1, cb1, len1);
 
         if (pv2 && len2)
-            drvAudioClearBuf(&pDSoundStrmOut->strmOut.Props, pv2, len2);
+            DrvAudioClearBuf(&pDSoundStrmOut->strmOut.Props, pv2, cb2, len2);
 
         directSoundPlayUnlock(pDSoundStrmOut->pDSB, pv1, pv2, cb1, cb2);
@@ -534,8 +536,8 @@
 }
 
-static HRESULT directSoundPlayGetStatus(LPDIRECTSOUNDBUFFER8 pDSB, DWORD *pStatus)
+static HRESULT directSoundPlayGetStatus(LPDIRECTSOUNDBUFFER8 pDSB, DWORD *pdwStatus)
 {
     AssertPtrReturn(pDSB, E_POINTER);
-    /* pStatus is optional. */
+    /* pdwStatus is optional. */
 
     DWORD dwStatus = 0;
@@ -553,6 +555,6 @@
     if (SUCCEEDED(hr))
     {
-        if (pStatus)
-            *pStatus = dwStatus;
+        if (pdwStatus)
+            *pdwStatus = dwStatus;
     }
     else
@@ -1024,5 +1026,5 @@
     pDSoundStrmOut->streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;
 
-    int rc = drvAudioStreamCfgToProps(&pDSoundStrmOut->streamCfg, &pDSoundStrmOut->strmOut.Props);
+    int rc = DrvAudioStreamCfgToProps(&pDSoundStrmOut->streamCfg, &pDSoundStrmOut->strmOut.Props);
     if (RT_SUCCESS(rc))
     {
@@ -1120,5 +1122,5 @@
 
         int cShift = pHstStrmOut->Props.cShift;
-        DWORD cbBuffer = pDSoundStrmOut->csPlaybackBufferSize << cShift;
+        DWORD cbBuffer = AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, pDSoundStrmOut->csPlaybackBufferSize);
 
         /* Get the current play position which is used for calculating the free space in the buffer. */
@@ -1142,14 +1144,15 @@
 
         DWORD cbFree = cbBuffer - dsoundRingDistance(pDSoundStrmOut->cbPlayWritePos, cbPlayPos, cbBuffer);
-
-        /* Check for full buffer, do not allow the cbPlayWritePos to catch cbPlayPos during playback,
+        /*
+         * Check for full buffer, do not allow the cbPlayWritePos to catch cbPlayPos during playback,
          * i.e. always leave a free space for 1 audio sample.
          */
-        if (cbFree <= (1U << cShift))
-            break;
-        cbFree -= (1U << cShift);
-
-        uint32_t csLive = drvAudioHstOutSamplesLive(pHstStrmOut);
-        uint32_t cbLive = csLive << cShift;
+        const DWORD cbSample = AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, 1);
+        if (cbFree <= cbSample)
+            break;
+        cbFree     -= cbSample;
+
+        uint32_t csLive = AudioMixBufAvail(&pHstStrmOut->MixBuf);
+        uint32_t cbLive = AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, csLive);
 
         /* Do not write more than available space in the DirectSound playback buffer. */
@@ -1171,6 +1174,6 @@
             break;
 
-        DWORD len1 = cb1 >> cShift;
-        DWORD len2 = cb2 >> cShift;
+        DWORD len1 = AUDIOMIXBUF_B2S(&pHstStrmOut->MixBuf, cb1);
+        DWORD len2 = AUDIOMIXBUF_B2S(&pHstStrmOut->MixBuf, cb2);
 
         uint32_t cRead = 0;
@@ -1194,5 +1197,6 @@
         directSoundPlayUnlock(pDSB, pv1, pv2, cb1, cb2);
 
-        pDSoundStrmOut->cbPlayWritePos = (pDSoundStrmOut->cbPlayWritePos + (cReadTotal << cShift)) % cbBuffer;
+        pDSoundStrmOut->cbPlayWritePos =
+            (pDSoundStrmOut->cbPlayWritePos + AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, cReadTotal)) % cbBuffer;
 
         DSLOGF(("DSound: %RU32 (%RU32 samples) out of %RU32%s, buffer write pos %ld, rc=%Rrc\n",
@@ -1262,5 +1266,5 @@
 
     /** @todo caller should already init Props? */
-    int rc = drvAudioStreamCfgToProps(&pDSoundStrmIn->streamCfg, &pHstStrmIn->Props);
+    int rc = DrvAudioStreamCfgToProps(&pDSoundStrmIn->streamCfg, &pHstStrmIn->Props);
     if (RT_SUCCESS(rc))
     {
@@ -1405,6 +1409,6 @@
     DWORD cb1, cb2;
     hr = directSoundCaptureLock(pDSCB, &pHstStrmIn->Props,
-                                pDSoundStrmIn->csCaptureReadPos << pHstStrmIn->Props.cShift,
-                                csCaptured << pHstStrmIn->Props.cShift,
+                                AUDIOMIXBUF_S2B(&pHstStrmIn->MixBuf, pDSoundStrmIn->csCaptureReadPos), /* dwOffset */
+                                AUDIOMIXBUF_S2B(&pHstStrmIn->MixBuf, csCaptured),                      /* dwBytes */
                                 &pv1, &pv2, &cb1, &cb2,
                                 0 /* dwFlags */);
@@ -1416,6 +1420,6 @@
     }
 
-    DWORD len1 = cb1 >> pHstStrmIn->Props.cShift;
-    DWORD len2 = cb2 >> pHstStrmIn->Props.cShift;
+    DWORD len1 = AUDIOMIXBUF_B2S(&pHstStrmIn->MixBuf, cb1);
+    DWORD len2 = AUDIOMIXBUF_B2S(&pHstStrmIn->MixBuf, cb2);
 
     uint32_t csWrittenTotal = 0;
Index: trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp	(revision 58372)
+++ trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp	(revision 58378)
@@ -112,5 +112,5 @@
 
     /* Just adopt the wanted stream configuration. */
-    int rc = drvAudioStreamCfgToProps(pCfg, &pHstStrmIn->Props);
+    int rc = DrvAudioStreamCfgToProps(pCfg, &pHstStrmIn->Props);
     if (RT_SUCCESS(rc))
     {
@@ -129,5 +129,5 @@
 
     /* Just adopt the wanted stream configuration. */
-    int rc = drvAudioStreamCfgToProps(pCfg, &pHstStrmOut->Props);
+    int rc = DrvAudioStreamCfgToProps(pCfg, &pHstStrmOut->Props);
     if (RT_SUCCESS(rc))
     {
@@ -164,5 +164,5 @@
 
     /* Consume as many samples as would be played at the current frequency since last call. */
-    uint32_t csLive          = drvAudioHstOutSamplesLive(pHstStrmOut);
+    uint32_t csLive          = AudioMixBufAvail(&pHstStrmOut->MixBuf);;
     uint64_t u64TicksNow     = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns);
     uint64_t u64TicksElapsed = u64TicksNow  - pNullStrmOut->u64TicksLast;
@@ -185,5 +185,6 @@
 
     uint32_t csRead = 0;
-    AudioMixBufReadCirc(&pHstStrmOut->MixBuf, pNullStrmOut->pu8PlayBuffer, cSamplesPlayed << pHstStrmOut->Props.cShift, &csRead);
+    AudioMixBufReadCirc(&pHstStrmOut->MixBuf, pNullStrmOut->pu8PlayBuffer,
+                        AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, cSamplesPlayed), &csRead);
     AudioMixBufFinish(&pHstStrmOut->MixBuf, csRead);
 
Index: trunk/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp	(revision 58372)
+++ trunk/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp	(revision 58378)
@@ -66,6 +66,8 @@
     int                cFragments;
     int                cbFragmentSize;
-    void              *pvBuf;
-    size_t             cbBuf;
+    /** Own PCM buffer. */
+    void              *pvPCMBuf;
+    /** Size (in bytes) of own PCM buffer. */
+    size_t             cbPCMBuf;
     int                old_optr;
 } OSSAUDIOSTREAMIN, *POSSAUDIOSTREAMIN;
@@ -79,7 +81,12 @@
     int                 cbFragmentSize;
 #ifndef RT_OS_L4
+    /** Whether we use a memory mapped file instead of our
+     *  own allocated PCM buffer below. */
     bool                fMemMapped;
 #endif
+    /** Own PCM buffer in case memory mapping is unavailable. */
     void               *pvPCMBuf;
+    /** Size (in bytes) of own PCM buffer. */
+    size_t              cbPCMBuf;
     int                 old_optr;
 } OSSAUDIOSTREAMOUT, *POSSAUDIOSTREAMOUT;
@@ -353,6 +360,6 @@
         case PDMAUDIOSTREAMCMD_ENABLE:
         {
-            drvAudioClearBuf(&pHstStrmOut->Props,
-                             pThisStrmOut->pvPCMBuf, AudioMixBufSize(&pHstStrmOut->MixBuf));
+            DrvAudioClearBuf(&pHstStrmOut->Props,
+                             pThisStrmOut->pvPCMBuf, pThisStrmOut->cbPCMBuf, AudioMixBufSize(&pHstStrmOut->MixBuf));
 
             mask = PCM_ENABLE_OUTPUT;
@@ -406,5 +413,5 @@
 
     int rc = VINF_SUCCESS;
-    size_t cbToRead = RT_MIN(pThisStrmIn->cbBuf,
+    size_t cbToRead = RT_MIN(pThisStrmIn->cbPCMBuf,
                              AudioMixBufFreeBytes(&pHstStrmIn->MixBuf));
 
@@ -418,7 +425,7 @@
     while (cbToRead)
     {
-        cbTemp = RT_MIN(cbToRead, pThisStrmIn->cbBuf);
+        cbTemp = RT_MIN(cbToRead, pThisStrmIn->cbPCMBuf);
         AssertBreakStmt(cbTemp, rc = VERR_NO_DATA);
-        cbRead = read(pThisStrmIn->hFile, (uint8_t *)pThisStrmIn->pvBuf + offWrite, cbTemp);
+        cbRead = read(pThisStrmIn->hFile, (uint8_t *)pThisStrmIn->pvPCMBuf + offWrite, cbTemp);
 
         LogFlowFunc(("cbRead=%zi, cbTemp=%RU32, cbToRead=%zu\n",
@@ -455,5 +462,5 @@
             uint32_t cWritten;
             rc = AudioMixBufWriteCirc(&pHstStrmIn->MixBuf,
-                                      pThisStrmIn->pvBuf, cbRead,
+                                      pThisStrmIn->pvPCMBuf, cbRead,
                                       &cWritten);
             if (RT_FAILURE(rc))
@@ -501,9 +508,13 @@
     LogFlowFuncEnter();
 
-    if (pThisStrmIn->pvBuf)
-    {
-        RTMemFree(pThisStrmIn->pvBuf);
-        pThisStrmIn->pvBuf = NULL;
+    if (pThisStrmIn->pvPCMBuf)
+    {
+        Assert(pThisStrmIn->cbPCMBuf);
+
+        RTMemFree(pThisStrmIn->pvPCMBuf);
+        pThisStrmIn->pvPCMBuf = NULL;
     }
+
+    pThisStrmIn->cbPCMBuf = 0;
 
     return VINF_SUCCESS;
@@ -524,7 +535,11 @@
         if (pThisStrmOut->pvPCMBuf)
         {
+            Assert(pThisStrmOut->cbPCMBuf);
+
             RTMemFree(pThisStrmOut->pvPCMBuf);
             pThisStrmOut->pvPCMBuf = NULL;
         }
+
+        pThisStrmOut->cbPCMBuf = 0;
     }
 #endif
@@ -587,5 +602,5 @@
             streamCfg.enmEndianness = obtStream.enmENDIANNESS;
 
-            rc = drvAudioStreamCfgToProps(&streamCfg, &pHstStrmIn->Props);
+            rc = DrvAudioStreamCfgToProps(&streamCfg, &pHstStrmIn->Props);
             if (RT_SUCCESS(rc))
             {
@@ -599,14 +614,14 @@
         if (RT_SUCCESS(rc))
         {
-            size_t cbBuf = cSamples * (1 << pHstStrmIn->Props.cShift);
-            pThisStrmIn->pvBuf = RTMemAlloc(cbBuf);
-            if (!pThisStrmIn->pvBuf)
-            {
-                LogRel(("OSS: Failed allocating ADC buffer with %RU32 samples, each %d bytes\n",
-                        cSamples, 1 << pHstStrmIn->Props.cShift));
+            size_t cbSample = (1 << pHstStrmIn->Props.cShift);
+            size_t cbBuf    = cSamples * cbSample;
+            pThisStrmIn->pvPCMBuf = RTMemAlloc(cbBuf);
+            if (!pThisStrmIn->pvPCMBuf)
+            {
+                LogRel(("OSS: Failed allocating ADC buffer with %RU32 samples (%zu bytes per sample)\n", cSamples, cbSample));
                 rc = VERR_NO_MEMORY;
             }
 
-            pThisStrmIn->cbBuf = cbBuf;
+            pThisStrmIn->cbPCMBuf = cbBuf;
 
             if (pcSamples)
@@ -664,5 +679,5 @@
             streamCfg.enmEndianness = obtStream.enmENDIANNESS;
 
-            rc = drvAudioStreamCfgToProps(&streamCfg, &pHstStrmOut->Props);
+            rc = DrvAudioStreamCfgToProps(&streamCfg, &pHstStrmOut->Props);
             if (RT_SUCCESS(rc))
                 cSamples = (obtStream.cFragments * obtStream.cbFragmentSize)
@@ -714,7 +729,5 @@
                                          cSamples << pHstStrmOut->Props.cShift);
                         if (rc2)
-                            LogRel(("OSS: Failed to unmap DAC output file: %s\n",
-                                    strerror(errno)));
-
+                            LogRel(("OSS: Failed to unmap DAC output file: %s\n", strerror(errno)));
                         break;
                     }
@@ -728,13 +741,18 @@
             {
 #endif
+                size_t cbSample = (1 << pHstStrmOut->Props.cShift);
+                size_t cbPCMBuf = cSamples * cbSample;
+
                 LogFlowFunc(("cSamples=%RU32\n", cSamples));
-                pThisStrmOut->pvPCMBuf = RTMemAlloc(cSamples * (1 << pHstStrmOut->Props.cShift));
+
+                pThisStrmOut->pvPCMBuf = RTMemAlloc(cbPCMBuf);
                 if (!pThisStrmOut->pvPCMBuf)
                 {
-                    LogRel(("OSS: Failed allocating DAC buffer with %RU32 samples, each %d bytes\n",
-                            cSamples, 1 << pHstStrmOut->Props.cShift));
+                    LogRel(("OSS: Failed allocating DAC buffer with %RU32 samples (%zu bytes per sample)\n", cSamples, cbSample));
                     rc = VERR_NO_MEMORY;
                     break;
                 }
+
+                pThisStrmOut->cbPCMBuf = cbPCMBuf;
 #ifndef RT_OS_L4
             }
@@ -776,5 +794,5 @@
         size_t cbBuf = AudioMixBufSizeBytes(&pHstStrmOut->MixBuf);
 
-        uint32_t cLive = drvAudioHstOutSamplesLive(pHstStrmOut);
+        uint32_t cLive = AudioMixBufAvail(&pHstStrmOut->MixBuf);
         uint32_t cToRead;
 
@@ -858,5 +876,5 @@
             if (cbWritten == -1)
             {
-                LogRel(("OSS: Failed writing output data %s\n", strerror(errno)));
+                LogRel(("OSS: Failed writing output data: %s\n", strerror(errno)));
                 rc = RTErrConvertFromErrno(errno);
                 break;
Index: trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp	(revision 58372)
+++ trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp	(revision 58378)
@@ -599,5 +599,5 @@
     streamCfg.cChannels = pThisStrmOut->SampleSpec.channels;
 
-    rc = drvAudioStreamCfgToProps(&streamCfg, &pHstStrmOut->Props);
+    rc = DrvAudioStreamCfgToProps(&streamCfg, &pHstStrmOut->Props);
     if (RT_SUCCESS(rc))
     {
@@ -682,5 +682,5 @@
     streamCfg.cChannels = pThisStrmIn->SampleSpec.channels;
 
-    rc = drvAudioStreamCfgToProps(&streamCfg, &pHstStrmIn->Props);
+    rc = DrvAudioStreamCfgToProps(&streamCfg, &pHstStrmIn->Props);
     if (RT_SUCCESS(rc))
     {
@@ -833,5 +833,5 @@
     uint32_t cbReadTotal = 0;
 
-    uint32_t cLive = drvAudioHstOutSamplesLive(pHstStrmOut);
+    uint32_t cLive = AudioMixBufAvail(&pHstStrmOut->MixBuf);
     if (!cLive)
     {
Index: trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp	(revision 58372)
+++ trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp	(revision 58378)
@@ -50,5 +50,5 @@
     PDMPCMPROPS props;
 
-    int rc = drvAudioStreamCfgToProps(&config, &props);
+    int rc = DrvAudioStreamCfgToProps(&config, &props);
     AssertRC(rc);
 
@@ -149,5 +149,5 @@
     PDMPCMPROPS props;
 
-    int rc = drvAudioStreamCfgToProps(&cfg_p, &props);
+    int rc = DrvAudioStreamCfgToProps(&cfg_p, &props);
     AssertRC(rc);
 
@@ -163,5 +163,5 @@
     };
 
-    rc = drvAudioStreamCfgToProps(&cfg_c1, &props);
+    rc = DrvAudioStreamCfgToProps(&cfg_c1, &props);
     AssertRC(rc);
 
@@ -178,5 +178,5 @@
     };
 
-    rc = drvAudioStreamCfgToProps(&cfg_c2, &props);
+    rc = DrvAudioStreamCfgToProps(&cfg_c2, &props);
     AssertRC(rc);
 
@@ -260,5 +260,5 @@
     };
 
-    int rc = drvAudioStreamCfgToProps(&cfg_p, &props);
+    int rc = DrvAudioStreamCfgToProps(&cfg_p, &props);
     AssertRC(rc);
 
@@ -281,5 +281,5 @@
     };
 
-    rc = drvAudioStreamCfgToProps(&cfg_c, &props);
+    rc = DrvAudioStreamCfgToProps(&cfg_c, &props);
     AssertRC(rc);
 
@@ -364,5 +364,5 @@
     };
 
-    int rc = drvAudioStreamCfgToProps(&cfg_p, &props);
+    int rc = DrvAudioStreamCfgToProps(&cfg_p, &props);
     AssertRC(rc);
 
@@ -378,5 +378,5 @@
     };
 
-    rc = drvAudioStreamCfgToProps(&cfg_c, &props);
+    rc = DrvAudioStreamCfgToProps(&cfg_c, &props);
     AssertRC(rc);
 
@@ -462,5 +462,5 @@
     };
 
-    int rc = drvAudioStreamCfgToProps(&cfg, &props);
+    int rc = DrvAudioStreamCfgToProps(&cfg, &props);
     AssertRC(rc);
 
