Index: trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/DevIchAc97.cpp	(revision 89723)
+++ trunk/src/VBox/Devices/Audio/DevIchAc97.cpp	(revision 89724)
@@ -682,7 +682,6 @@
 static uint16_t             ichac97MixerGet(PAC97STATE pThis, uint32_t uMixerIdx);
 #ifdef IN_RING3
-static void                 ichac97R3StreamLock(PAC97STREAMR3 pStreamCC);
-static void                 ichac97R3StreamUnlock(PAC97STREAMR3 pStreamCC);
-
+DECLINLINE(void)            ichac97R3StreamLock(PAC97STREAMR3 pStreamCC);
+DECLINLINE(void)            ichac97R3StreamUnlock(PAC97STREAMR3 pStreamCC);
 static void                 ichac97R3DbgPrintBdl(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream,
                                                  PCDBGFINFOHLP pHlp, const char *pszPrefix);
@@ -1794,4 +1793,6 @@
  * Adds a driver stream to a specific mixer sink.
  *
+ * Called by ichac97R3MixerAddDrvStreams() and ichac97R3MixerAddDrv().
+ *
  * @returns VBox status code.
  * @param   pDevIns     The device instance.
@@ -1842,6 +1843,9 @@
 }
 
+
 /**
  * Adds all current driver streams to a specific mixer sink.
+ *
+ * Called by ichac97R3StreamOpen().
  *
  * @returns VBox status code.
@@ -1881,79 +1885,9 @@
 }
 
-/**
- * Adds a specific AC'97 driver to the driver chain.
- *
- * Only called from ichac97R3Attach().
- *
- * @returns VBox status code.
- * @param   pDevIns     The device instance.
- * @param   pThisCC     The ring-3 AC'97 device state.
- * @param   pDrv        The AC'97 driver to add.
- */
-static int ichac97R3MixerAddDrv(PPDMDEVINS pDevIns, PAC97STATER3 pThisCC, PAC97DRIVER pDrv)
-{
-    int rc = VINF_SUCCESS;
-
-    if (AudioHlpStreamCfgIsValid(&pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX].State.Cfg))
-        rc = ichac97R3MixerAddDrvStream(pDevIns, pThisCC->pSinkLineIn,
-                                        &pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX].State.Cfg, pDrv);
-
-    if (AudioHlpStreamCfgIsValid(&pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX].State.Cfg))
-    {
-        int rc2 = ichac97R3MixerAddDrvStream(pDevIns, pThisCC->pSinkOut,
-                                             &pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX].State.Cfg, pDrv);
-        if (RT_SUCCESS(rc))
-            rc = rc2;
-    }
-
-    if (AudioHlpStreamCfgIsValid(&pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX].State.Cfg))
-    {
-        int rc2 = ichac97R3MixerAddDrvStream(pDevIns, pThisCC->pSinkMicIn,
-                                             &pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX].State.Cfg, pDrv);
-        if (RT_SUCCESS(rc))
-            rc = rc2;
-    }
-
-    return rc;
-}
-
-/**
- * Removes a specific AC'97 driver from the driver chain and destroys its
- * associated streams.
- *
- * Only called from ichac97R3Detach().
- *
- * @param   pDevIns     The device instance.
- * @param   pThisCC     The ring-3 AC'97 device state.
- * @param   pDrv        AC'97 driver to remove.
- */
-static void ichac97R3MixerRemoveDrv(PPDMDEVINS pDevIns, PAC97STATER3 pThisCC, PAC97DRIVER pDrv)
-{
-    if (pDrv->MicIn.pMixStrm)
-    {
-        AudioMixerSinkRemoveStream(pThisCC->pSinkMicIn,  pDrv->MicIn.pMixStrm);
-        AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm, pDevIns, true /*fImmediate*/);
-        pDrv->MicIn.pMixStrm = NULL;
-    }
-
-    if (pDrv->LineIn.pMixStrm)
-    {
-        AudioMixerSinkRemoveStream(pThisCC->pSinkLineIn, pDrv->LineIn.pMixStrm);
-        AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm, pDevIns, true /*fImmediate*/);
-        pDrv->LineIn.pMixStrm = NULL;
-    }
-
-    if (pDrv->Out.pMixStrm)
-    {
-        AudioMixerSinkRemoveStream(pThisCC->pSinkOut,    pDrv->Out.pMixStrm);
-        AudioMixerStreamDestroy(pDrv->Out.pMixStrm, pDevIns, true /*fImmediate*/);
-        pDrv->Out.pMixStrm = NULL;
-    }
-
-    RTListNodeRemove(&pDrv->Node);
-}
 
 /**
  * Removes a driver stream from a specific mixer sink.
+ *
+ * Worker for ichac97R3MixerRemoveDrvStreams.
  *
  * @param   pDevIns     The device instance.
@@ -1981,4 +1915,6 @@
 /**
  * Removes all driver streams from a specific mixer sink.
+ *
+ * Called by ichac97R3StreamOpen() and ichac97R3StreamsDestroy().
  *
  * @param   pDevIns     The device instance.
@@ -4021,4 +3957,42 @@
 
 /**
+ * Adds a specific AC'97 driver to the driver chain.
+ *
+ * Only called from ichac97R3Attach().
+ *
+ * @returns VBox status code.
+ * @param   pDevIns     The device instance.
+ * @param   pThisCC     The ring-3 AC'97 device state.
+ * @param   pDrv        The AC'97 driver to add.
+ */
+static int ichac97R3MixerAddDrv(PPDMDEVINS pDevIns, PAC97STATER3 pThisCC, PAC97DRIVER pDrv)
+{
+    int rc = VINF_SUCCESS;
+
+    if (AudioHlpStreamCfgIsValid(&pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX].State.Cfg))
+        rc = ichac97R3MixerAddDrvStream(pDevIns, pThisCC->pSinkLineIn,
+                                        &pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX].State.Cfg, pDrv);
+
+    if (AudioHlpStreamCfgIsValid(&pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX].State.Cfg))
+    {
+        int rc2 = ichac97R3MixerAddDrvStream(pDevIns, pThisCC->pSinkOut,
+                                             &pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX].State.Cfg, pDrv);
+        if (RT_SUCCESS(rc))
+            rc = rc2;
+    }
+
+    if (AudioHlpStreamCfgIsValid(&pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX].State.Cfg))
+    {
+        int rc2 = ichac97R3MixerAddDrvStream(pDevIns, pThisCC->pSinkMicIn,
+                                             &pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX].State.Cfg, pDrv);
+        if (RT_SUCCESS(rc))
+            rc = rc2;
+    }
+
+    return rc;
+}
+
+
+/**
  * Worker for ichac97R3Construct() and ichac97R3Attach().
  *
@@ -4105,4 +4079,41 @@
 
     return rc;
+}
+
+
+/**
+ * Removes a specific AC'97 driver from the driver chain and destroys its
+ * associated streams.
+ *
+ * Only called from ichac97R3Detach().
+ *
+ * @param   pDevIns     The device instance.
+ * @param   pThisCC     The ring-3 AC'97 device state.
+ * @param   pDrv        AC'97 driver to remove.
+ */
+static void ichac97R3MixerRemoveDrv(PPDMDEVINS pDevIns, PAC97STATER3 pThisCC, PAC97DRIVER pDrv)
+{
+    if (pDrv->MicIn.pMixStrm)
+    {
+        AudioMixerSinkRemoveStream(pThisCC->pSinkMicIn,  pDrv->MicIn.pMixStrm);
+        AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm, pDevIns, true /*fImmediate*/);
+        pDrv->MicIn.pMixStrm = NULL;
+    }
+
+    if (pDrv->LineIn.pMixStrm)
+    {
+        AudioMixerSinkRemoveStream(pThisCC->pSinkLineIn, pDrv->LineIn.pMixStrm);
+        AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm, pDevIns, true /*fImmediate*/);
+        pDrv->LineIn.pMixStrm = NULL;
+    }
+
+    if (pDrv->Out.pMixStrm)
+    {
+        AudioMixerSinkRemoveStream(pThisCC->pSinkOut,    pDrv->Out.pMixStrm);
+        AudioMixerStreamDestroy(pDrv->Out.pMixStrm, pDevIns, true /*fImmediate*/);
+        pDrv->Out.pMixStrm = NULL;
+    }
+
+    RTListNodeRemove(&pDrv->Node);
 }
 
