Index: /trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/DevIchAc97.cpp	(revision 80608)
+++ /trunk/src/VBox/Devices/Audio/DevIchAc97.cpp	(revision 80609)
@@ -663,6 +663,6 @@
 static int                ichac97R3StreamCreate(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8Strm);
 static void               ichac97R3StreamDestroy(PAC97STATE pThis, PAC97STREAM pStream);
-static int                ichac97R3StreamOpen(PAC97STATE pThis, PAC97STREAM pStream);
-static int                ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream);
+static int                ichac97R3StreamOpen(PAC97STATE pThis, PAC97STREAM pStream, bool fForce);
+static int                ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream, bool fForce);
 static int                ichac97R3StreamClose(PAC97STATE pThis, PAC97STREAM pStream);
 static void               ichac97R3StreamReset(PAC97STATE pThis, PAC97STREAM pStream);
@@ -897,5 +897,5 @@
             RTCircBufReset(pStream->State.pCircBuf);
 
-        rc = ichac97R3StreamOpen(pThis, pStream);
+        rc = ichac97R3StreamOpen(pThis, pStream, false /* fForce */);
 
         if (pStream->Dbg.Runtime.fEnabled)
@@ -1637,4 +1637,8 @@
     AssertMsgReturnVoid(uMixerIdx + 2U <= sizeof(pThis->mixer_data),
                          ("Index %RU8 out of bounds (%zu)\n", uMixerIdx, sizeof(pThis->mixer_data)));
+
+    LogRel2(("AC97: Setting mixer index #%RU8 to %RU16 (%RU8 %RU8)\n",
+             uMixerIdx, uVal, RT_HI_U8(uVal), RT_LO_U8(uVal)));
+
     pThis->mixer_data[uMixerIdx + 0] = RT_LO_U8(uVal);
     pThis->mixer_data[uMixerIdx + 1] = RT_HI_U8(uVal);
@@ -2012,6 +2016,8 @@
  * @param   pThis               AC'97 device state.
  * @param   pStream             AC'97 stream to open.
- */
-static int ichac97R3StreamOpen(PAC97STATE pThis, PAC97STREAM pStream)
+ * @param   fForce              Whether to force re-opening the stream or not.
+ *                              Otherwise re-opening only will happen if the PCM properties have changed.
+ */
+static int ichac97R3StreamOpen(PAC97STATE pThis, PAC97STREAM pStream, bool fForce)
 {
     int rc = VINF_SUCCESS;
@@ -2074,5 +2080,6 @@
         /* Only (re-)create the stream (and driver chain) if we really have to.
          * Otherwise avoid this and just reuse it, as this costs performance. */
-        if (!DrvAudioHlpPCMPropsAreEqual(&Cfg.Props, &pStream->State.Cfg.Props))
+        if (   !DrvAudioHlpPCMPropsAreEqual(&Cfg.Props, &pStream->State.Cfg.Props)
+            || fForce)
         {
             LogRel2(("AC97: (Re-)Opening stream '%s' (%RU32Hz, %RU8 channels, %s%RU8)\n",
@@ -2150,6 +2157,8 @@
  * @param   pThis               AC'97 device state.
  * @param   pStream             AC'97 stream to re-open.
- */
-static int ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream)
+ * @param   fForce              Whether to force re-opening the stream or not.
+ *                              Otherwise re-opening only will happen if the PCM properties have changed.
+ */
+static int ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream, bool fForce)
 {
     LogFlowFunc(("[SD%RU8]\n", pStream->u8SD));
@@ -2157,5 +2166,5 @@
     int rc = ichac97R3StreamClose(pThis, pStream);
     if (RT_SUCCESS(rc))
-        rc = ichac97R3StreamOpen(pThis, pStream);
+        rc = ichac97R3StreamOpen(pThis, pStream, fForce);
 
     return rc;
@@ -3495,26 +3504,41 @@
                 case AC97_Extended_Audio_Ctrl_Stat:
 #ifdef IN_RING3
-                    if (!(u32Val & AC97_EACS_VRA))
+                    /*
+                     * Handle VRA bits.
+                     */
+# ifndef VBOX_WITH_AC97_VRA
+                    if (u32Val & AC97_EACS_VRA)
                     {
-                        ichac97MixerSet(pThis, AC97_PCM_Front_DAC_Rate, 48000 /* Default = 0xBB80 */);
-                        ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX]);
-
-                        ichac97MixerSet(pThis, AC97_PCM_LR_ADC_Rate,    48000 /* Default = 0xBB80 */);
-                        ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX]);
+                        u32Val &= ~AC97_EACS_VRA; /* Only clear VRA bit and keep the rest. */
+                        LogRel2(("AC97: Variable rate audio (VRA) is not supported, setting to 0x%x\n", u32Val));
                     }
-                    else
-                        LogRel2(("AC97: Variable rate audio (VRA) is not supported\n"));
-
-                    if (!(u32Val & AC97_EACS_VRM))
+
+                    ichac97MixerSet(pThis, AC97_PCM_Front_DAC_Rate, 0xbb80); /* Set default (48000 Hz). */
+                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX], true /* fForce */);
+
+                    ichac97MixerSet(pThis, AC97_PCM_LR_ADC_Rate, 0xbb80); /* Set default (48000 Hz). */
+                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX], true /* fForce */);
+# else
+#  error            "Implement EACS VRA support!"
+# endif
+                    /*
+                     * Handle VRM bits.
+                     */
+# ifndef VBOX_WITH_AC97_VRM
+                    if (u32Val & AC97_EACS_VRM)
                     {
-                        ichac97MixerSet(pThis, AC97_MIC_ADC_Rate,       48000 /* Default = 0xBB80 */);
-                        ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX]);
+                        u32Val &= ~AC97_EACS_VRM; /* Only clear VRM bit and keep the rest. */
+                        LogRel2(("AC97: Variable rate microphone audio (VRM) is not supported, setting to 0x%x\n", u32Val));
                     }
-                    else
-                        LogRel2(("AC97: Variable rate microphone audio (VRM) is not supported\n"));
-
-                    LogFunc(("Setting extended audio control to %#x\n", u32Val));
+
+                    ichac97MixerSet(pThis, AC97_MIC_ADC_Rate, 0xbb80); /* Set default (48000 Hz). */
+                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX], true /* fForce */);
+# else
+#  error            "Implement EACS VRM support!"
+# endif
+                    LogRel2(("AC97: Setting extended audio control to %#x\n", u32Val));
+
                     ichac97MixerSet(pThis, AC97_Extended_Audio_Ctrl_Stat, u32Val);
-#else
+#else /* !IN_RING3 */
                     rc = VINF_IOM_R3_IOPORT_WRITE;
 #endif
@@ -3522,5 +3546,5 @@
                 case AC97_PCM_Front_DAC_Rate: /* Output slots 3, 4, 6. */
 #ifdef IN_RING3
-                if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRA)
+                    if (ichac97MixerGet(pThis, AC97_Extended_Audio_Ctrl_Stat) & AC97_EACS_VRA)
                     {
                         ichac97MixerSet(pThis, uPortIdx, u32Val);
@@ -3533,5 +3557,5 @@
                      *       set the VRA rate nevertheless. So re-open the output stream in any case to avoid
                      *       breaking playback. */
-                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX]);
+                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX], true /* fForce */);
 #else
                     rc = VINF_IOM_R3_IOPORT_WRITE;
@@ -3552,5 +3576,5 @@
                      *       set the VRM rate nevertheless. So re-open the mic-in stream in any case to avoid
                      *       breaking recording.*/
-                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX]);
+                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX], true /* fForce */);
 #else
                     rc = VINF_IOM_R3_IOPORT_WRITE;
@@ -3570,5 +3594,5 @@
                      *       set the VRA rate nevertheless. So re-open the line-in stream in any case to avoid
                      *       breaking recording.*/
-                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX]);
+                    ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX], true /* fForce */);
 #else
                     rc = VINF_IOM_R3_IOPORT_WRITE;
