Index: /trunk/include/VBox/vmm/pdmaudioifs.h
===================================================================
--- /trunk/include/VBox/vmm/pdmaudioifs.h	(revision 58343)
+++ /trunk/include/VBox/vmm/pdmaudioifs.h	(revision 58344)
@@ -175,4 +175,8 @@
     /** Disables the stream. */
     PDMAUDIOSTREAMCMD_DISABLE,
+    /** Pauses the stream. */
+    PDMAUDIOSTREAMCMD_PAUSE,
+    /** Resumes the stream. */
+    PDMAUDIOSTREAMCMD_RESUME,
     /** Hack to blow the type up to 32-bit. */
     PDMAUDIOSTREAMCMD_32BIT_HACK = 0x7fffffff
@@ -300,4 +304,21 @@
 } PDMAUDIOMIXBUF;
 
+/** Stream status flag. To be used with PDMAUDIOSTRMSTS_FLAG_ flags. */
+typedef uint32_t PDMAUDIOSTRMSTS;
+
+/** No flags being set. */
+#define PDMAUDIOSTRMSTS_FLAG_NONE            0
+/** Whether this stream General Enabled or disabled flag. */
+#define PDMAUDIOSTRMSTS_FLAG_ENABLED         RT_BIT_32(0)
+/** Whether this stream has been paused or not. This also implies
+ *  that this is an enabled stream! */
+#define PDMAUDIOSTRMSTS_FLAG_PAUSED          RT_BIT_32(1)
+/** Whether this stream was marked as being disabled
+ *  but there are still associated guest output streams
+ *  which rely on its data. */
+#define PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE RT_BIT_32(2)
+/** Validation mask. */
+#define PDMAUDIOSTRMSTS_VALID_MASK           UINT32_C(0x00000007)
+
 /**
  * Represents an audio input on the host of a certain
@@ -316,6 +337,6 @@
     /** PCM properties. */
     PDMPCMPROPS            Props;
-    /** Whether this input is enabled or not. */
-    bool                   fEnabled;
+    /** Stream status flag. */
+    PDMAUDIOSTRMSTS        fStatus;
     /** This stream's mixing buffer. */
     PDMAUDIOMIXBUF         MixBuf;
@@ -337,10 +358,6 @@
     /** Stream properites. */
     PDMPCMPROPS            Props;
-    /** Enabled or disabled flag. */
-    bool                   fEnabled;
-    /** Whether this stream was marked as being disabled
-     *  but there are still associated guest output streams
-     *  which rely on its data. */
-    bool                   fPendingDisable;
+    /** Stream status flag. */
+    PDMAUDIOSTRMSTS        fStatus;
     /** This stream's mixing buffer. */
     PDMAUDIOMIXBUF         MixBuf;
Index: /trunk/src/VBox/Devices/Audio/DrvAudio.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/DrvAudio.cpp	(revision 58343)
+++ /trunk/src/VBox/Devices/Audio/DrvAudio.cpp	(revision 58344)
@@ -371,6 +371,5 @@
 }
 
-static int drvAudioControlHstIn(PDRVAUDIO pThis, PPDMAUDIOHSTSTRMIN pHstStrmIn, PDMAUDIOSTREAMCMD enmStreamCmd,
-                                uint32_t uFlags)
+static int drvAudioControlHstIn(PDRVAUDIO pThis, PPDMAUDIOHSTSTRMIN pHstStrmIn, PDMAUDIOSTREAMCMD enmStreamCmd)
 {
     AssertPtrReturn(pThis, VERR_INVALID_POINTER);
@@ -383,10 +382,10 @@
         case PDMAUDIOSTREAMCMD_ENABLE:
         {
-            if (!pHstStrmIn->fEnabled)
+            if (!(pHstStrmIn->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED))
             {
                 rc = pThis->pHostDrvAudio->pfnControlIn(pThis->pHostDrvAudio, pHstStrmIn, PDMAUDIOSTREAMCMD_ENABLE);
                 if (RT_SUCCESS(rc))
                 {
-                    pHstStrmIn->fEnabled = true;
+                    pHstStrmIn->fStatus |= PDMAUDIOSTRMSTS_FLAG_ENABLED;
                 }
                 else
@@ -401,10 +400,10 @@
         case PDMAUDIOSTREAMCMD_DISABLE:
         {
-            if (pHstStrmIn->fEnabled)
+            if (pHstStrmIn->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)
             {
                 rc = pThis->pHostDrvAudio->pfnControlIn(pThis->pHostDrvAudio, pHstStrmIn, PDMAUDIOSTREAMCMD_DISABLE);
                 if (RT_SUCCESS(rc))
                 {
-                    pHstStrmIn->fEnabled = false;
+                    pHstStrmIn->fStatus = PDMAUDIOSTRMSTS_FLAG_NONE; /* Clear all. */
                     AudioMixBufClear(&pHstStrmIn->MixBuf);
                 }
@@ -427,6 +426,5 @@
 }
 
-static int drvAudioControlHstOut(PDRVAUDIO pThis, PPDMAUDIOHSTSTRMOUT pHstStrmOut, PDMAUDIOSTREAMCMD enmStreamCmd,
-                                 uint32_t uFlags)
+static int drvAudioControlHstOut(PDRVAUDIO pThis, PPDMAUDIOHSTSTRMOUT pHstStrmOut, PDMAUDIOSTREAMCMD enmStreamCmd)
 {
     AssertPtrReturn(pThis, VERR_INVALID_POINTER);
@@ -439,15 +437,15 @@
         case PDMAUDIOSTREAMCMD_ENABLE:
         {
-            if (!pHstStrmOut->fEnabled)
+            if (!(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED))
             {
                 rc = pThis->pHostDrvAudio->pfnControlOut(pThis->pHostDrvAudio, pHstStrmOut, PDMAUDIOSTREAMCMD_ENABLE);
                 if (RT_SUCCESS(rc))
                 {
-                    Assert(!pHstStrmOut->fPendingDisable);
-                    pHstStrmOut->fEnabled = true;
+                    Assert(!(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE));
+                    pHstStrmOut->fStatus |= PDMAUDIOSTRMSTS_FLAG_ENABLED;
                     LogFunc(("[%s] Enabled stream\n", pHstStrmOut->MixBuf.pszName));
                 }
                 else
-                    LogFlowFunc(("[%s] Backend reported an error when opening output stream, rc=%Rrc\n",
+                    LogFlowFunc(("[%s] Backend reported an error when enabling output stream, rc=%Rrc\n",
                                  pHstStrmOut->MixBuf.pszName, rc));
             }
@@ -460,11 +458,10 @@
         case PDMAUDIOSTREAMCMD_DISABLE:
         {
-            if (pHstStrmOut->fEnabled)
+            if (pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)
             {
                 rc = pThis->pHostDrvAudio->pfnControlOut(pThis->pHostDrvAudio, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE);
                 if (RT_SUCCESS(rc))
                 {
-                    pHstStrmOut->fEnabled        = false;
-                    pHstStrmOut->fPendingDisable = false;
+                    pHstStrmOut->fStatus = PDMAUDIOSTRMSTS_FLAG_NONE; /* Clear all. */
                     AudioMixBufClear(&pHstStrmOut->MixBuf);
 
@@ -472,5 +469,45 @@
                 }
                 else
-                    LogFlowFunc(("[%s] Backend vetoed closing output stream, rc=%Rrc\n", pHstStrmOut->MixBuf.pszName, rc));
+                    LogFlowFunc(("[%s] Backend vetoed disabling output stream, rc=%Rrc\n", pHstStrmOut->MixBuf.pszName, rc));
+            }
+            else
+                rc = VINF_SUCCESS;
+
+            break;
+        }
+
+        case PDMAUDIOSTREAMCMD_PAUSE:
+        {
+            if (!(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_PAUSED))
+            {
+                Assert(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED);
+                rc = pThis->pHostDrvAudio->pfnControlOut(pThis->pHostDrvAudio, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE);
+                if (RT_SUCCESS(rc))
+                {
+                    pHstStrmOut->fStatus |= PDMAUDIOSTRMSTS_FLAG_PAUSED;
+                    LogFunc(("[%s] Pausing stream\n", pHstStrmOut->MixBuf.pszName));
+                }
+                else
+                    LogFlowFunc(("[%s] Backend vetoed pausing output stream, rc=%Rrc\n", pHstStrmOut->MixBuf.pszName, rc));
+            }
+            else
+                rc = VINF_SUCCESS;
+
+            break;
+        }
+
+        case PDMAUDIOSTREAMCMD_RESUME:
+        {
+            if (pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_PAUSED)
+            {
+                Assert(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED);
+                rc = pThis->pHostDrvAudio->pfnControlOut(pThis->pHostDrvAudio, pHstStrmOut, PDMAUDIOSTREAMCMD_ENABLE);
+                if (RT_SUCCESS(rc))
+                {
+                    pHstStrmOut->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PAUSED;
+                    LogFunc(("[%s] Resumed stream\n", pHstStrmOut->MixBuf.pszName));
+                }
+                else
+                    LogFlowFunc(("[%s] Backend vetoed resuming output stream, rc=%Rrc\n", pHstStrmOut->MixBuf.pszName, rc));
             }
             else
@@ -562,5 +599,5 @@
 {
     while ((pHstStrmIn = drvAudioFindNextHstIn(pThis, pHstStrmIn)))
-        if (pHstStrmIn->fEnabled)
+        if (pHstStrmIn->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)
             return pHstStrmIn;
 
@@ -995,5 +1032,5 @@
     AssertPtrReturn(pHstStrmOut, VERR_INVALID_POINTER);
 
-    AssertMsg(pGstStrmOut->pHstStrmOut->fEnabled,
+    AssertMsg(pGstStrmOut->pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED,
               ("Writing to disabled host output stream \"%s\" not possible\n",
               pHstStrmOut->MixBuf.pszName));
@@ -1053,5 +1090,5 @@
     while ((pHostStrmOut = drvAudioFindAnyHstOut(pThis, pHostStrmOut)))
     {
-        if (pHostStrmOut->fEnabled)
+        if (pHostStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)
             return pHostStrmOut;
     }
@@ -1159,12 +1196,12 @@
         /* Has this stream marked as disabled but there still were guest streams relying
          * on it? Check if this stream now can be closed and do so, if possible. */
-        if (   pHstStrmOut->fPendingDisable
+        if (   (pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE)
             && !cSamplesLive)
         {
             /* Stop playing the current (pending) stream. */
-            int rc2 = drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE, 0 /* Flags */);
+            int rc2 = drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE);
             if (RT_SUCCESS(rc2))
             {
-                pHstStrmOut->fPendingDisable = false;
+                pHstStrmOut->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE;
 
                 LogFunc(("[%s] Disabling stream\n", pHstStrmOut->MixBuf.pszName));
@@ -1402,4 +1439,5 @@
 static void drvAudioStateHandler(PPDMDRVINS pDrvIns, PDMAUDIOSTREAMCMD enmCmd)
 {
+    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
     PDRVAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIO);
 
@@ -1411,9 +1449,9 @@
     PPDMAUDIOHSTSTRMOUT pHstStrmOut = NULL;
     while ((pHstStrmOut = drvAudioHstFindAnyEnabledOut(pThis, pHstStrmOut)))
-        drvAudioControlHstOut(pThis, pHstStrmOut, enmCmd, 0 /* Flags */);
+        drvAudioControlHstOut(pThis, pHstStrmOut, enmCmd);
 
     PPDMAUDIOHSTSTRMIN pHstStrmIn = NULL;
     while ((pHstStrmIn = drvAudioFindNextEnabledHstIn(pThis, pHstStrmIn)))
-        drvAudioControlHstIn(pThis, pHstStrmIn, enmCmd, 0 /* Flags */);
+        drvAudioControlHstIn(pThis, pHstStrmIn, enmCmd);
 }
 
@@ -1537,5 +1575,5 @@
     AssertPtrReturn(pHstStrmIn, VERR_INVALID_POINTER);
 
-    AssertMsg(pGstStrmIn->pHstStrmIn->fEnabled,
+    AssertMsg(pGstStrmIn->pHstStrmIn->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED,
               ("Reading from disabled host input stream \"%s\" not possible\n", pGstStrmIn->MixBuf.pszName));
 
@@ -1579,11 +1617,11 @@
             if (fEnable)
             {
-                pHstStrmOut->fPendingDisable = false;
-                if (!pHstStrmOut->fEnabled)
-                    rc = drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_ENABLE, 0 /* Flags */);
+                pHstStrmOut->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE;
+                if (!(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED))
+                    rc = drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_ENABLE);
             }
             else /* Disable */
             {
-                if (pHstStrmOut->fEnabled)
+                if (pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)
                 {
                     uint32_t cGstStrmsActive = 0;
@@ -1607,9 +1645,10 @@
 
                     /* Do we need to defer closing the host stream? */
-                    pHstStrmOut->fPendingDisable = cGstStrmsActive >= 1;
+                    if (cGstStrmsActive >= 1)
+                        pHstStrmOut->fStatus |= PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE;
 
                     /* Can we close the host stream now instead of deferring it? */
-                    if (!pHstStrmOut->fPendingDisable)
-                        rc = drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE, 0 /* Flags */);
+                    if (!(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE))
+                        rc = drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE);
                 }
             }
@@ -1618,6 +1657,6 @@
                 pGstStrmOut->State.fActive = fEnable;
 
-            LogFlowFunc(("%s: fEnable=%RTbool, fPendingDisable=%RTbool, rc=%Rrc\n",
-                         pGstStrmOut->MixBuf.pszName, fEnable, pHstStrmOut->fPendingDisable, rc));
+            LogFlowFunc(("%s: fEnable=%RTbool, fStatus=0x%x, rc=%Rrc\n",
+                         pGstStrmOut->MixBuf.pszName, fEnable, pHstStrmOut->fStatus, rc));
         }
     }
@@ -1646,5 +1685,5 @@
         {
             rc = drvAudioControlHstIn(pThis, pHstStrmIn,
-                                      fEnable ? PDMAUDIOSTREAMCMD_ENABLE : PDMAUDIOSTREAMCMD_DISABLE, 0 /* Flags */);
+                                      fEnable ? PDMAUDIOSTREAMCMD_ENABLE : PDMAUDIOSTREAMCMD_DISABLE);
             if (RT_SUCCESS(rc))
                 pGstStrmIn->State.fActive = fEnable;
@@ -1891,5 +1930,5 @@
     while ((pHstStrmOut = drvAudioFindAnyHstOut(pThis, pHstStrmOut)))
     {
-        drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE, 0 /* Flags */);
+        drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE);
         pThis->pHostDrvAudio->pfnFiniOut(pThis->pHostDrvAudio, pHstStrmOut);
     }
@@ -1899,5 +1938,5 @@
     while ((pHstStrmIn = drvAudioFindNextHstIn(pThis, pHstStrmIn)))
     {
-        drvAudioControlHstIn(pThis, pHstStrmIn, PDMAUDIOSTREAMCMD_DISABLE, 0 /* Flags */);
+        drvAudioControlHstIn(pThis, pHstStrmIn, PDMAUDIOSTREAMCMD_DISABLE);
         pThis->pHostDrvAudio->pfnFiniIn(pThis->pHostDrvAudio, pHstStrmIn);
     }
@@ -1986,5 +2025,5 @@
 static DECLCALLBACK(void) drvAudioSuspend(PPDMDRVINS pDrvIns)
 {
-    drvAudioStateHandler(pDrvIns, PDMAUDIOSTREAMCMD_DISABLE);
+    drvAudioStateHandler(pDrvIns, PDMAUDIOSTREAMCMD_PAUSE);
 }
 
@@ -1996,5 +2035,5 @@
 static DECLCALLBACK(void) drvAudioResume(PPDMDRVINS pDrvIns)
 {
-    drvAudioStateHandler(pDrvIns, PDMAUDIOSTREAMCMD_ENABLE);
+    drvAudioStateHandler(pDrvIns, PDMAUDIOSTREAMCMD_RESUME);
 }
 
