Index: trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/DevIchAc97.cpp	(revision 82323)
+++ trunk/src/VBox/Devices/Audio/DevIchAc97.cpp	(revision 82324)
@@ -505,10 +505,7 @@
     /** The device timer Hz rate. Defaults to AC97_TIMER_HZ_DEFAULT_DEFAULT. */
     uint16_t                uTimerHz;
-    /** The timer for pumping data thru the attached LUN drivers - RCPtr. */
-    PTMTIMERRC              pTimerRC[AC97_MAX_STREAMS];
-    /** The timer for pumping data thru the attached LUN drivers - R3Ptr. */
-    PTMTIMERR3              pTimerR3[AC97_MAX_STREAMS];
-    /** The timer for pumping data thru the attached LUN drivers - R0Ptr. */
-    PTMTIMERR0              pTimerR0[AC97_MAX_STREAMS];
+    uint16_t                au16Padding1[3];
+    /** The timer for pumping data thru the attached LUN drivers. */
+    TMTIMERHANDLE           ahTimers[AC97_MAX_STREAMS];
     /** List of associated LUN drivers (AC97DRIVER). */
     RTLISTANCHORR3          lstDrv;
@@ -581,5 +578,5 @@
 #define DEVAC97_LOCK_BOTH_RETURN(a_pDevIns, a_pThis, a_SD, a_rcBusy) \
     do { \
-        int rcLock = TMTimerLock((a_pThis)->DEVAC97_CTX_SUFF_SD(pTimer, a_SD), (a_rcBusy)); \
+        int rcLock = PDMDevHlpTimerLock((a_pDevIns), RT_SAFE_SUBSCRIPT8((a_pThis)->ahTimers, (a_SD)), (a_rcBusy)); \
         if (rcLock == VINF_SUCCESS) \
         { \
@@ -587,5 +584,5 @@
             if (rcLock == VINF_SUCCESS) \
                 break; \
-            TMTimerUnlock((a_pThis)->DEVAC97_CTX_SUFF_SD(pTimer, a_SD)); \
+            PDMDevHlpTimerUnlock((a_pDevIns), RT_SAFE_SUBSCRIPT8((a_pThis)->ahTimers, (a_SD))); \
         } \
         AssertRC(rcLock); \
@@ -599,5 +596,5 @@
     do { \
         PDMDevHlpCritSectLeave((a_pDevIns), &(a_pThis)->CritSect); \
-        TMTimerUnlock((a_pThis)->DEVAC97_CTX_SUFF_SD(pTimer, a_SD)); \
+        PDMDevHlpTimerUnlock((a_pDevIns), RT_SAFE_SUBSCRIPT8((a_pThis)->ahTimers, (a_SD))); \
     } while (0)
 
@@ -655,5 +652,5 @@
 # endif
 #endif /* IN_RING3 */
-bool                      ichac97TimerSet(PAC97STATE pThis, PAC97STREAM pStream, uint64_t tsExpire, bool fForce);
+static bool               ichac97TimerSet(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint64_t tsExpire, bool fForce);
 
 static void ichac97WarmReset(PAC97STATE pThis)
@@ -1922,9 +1919,10 @@
  *
  * @returns Calculated ticks
+ * @param   pDevIns             The device instance.
  * @param   pThis               AC'97 device state.
  * @param   pStream             AC'97 stream to calculate ticks for.
  * @param   cbBytes             Bytes to calculate ticks for.
  */
-static uint64_t ichac97R3StreamTransferCalcNext(PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbBytes)
+static uint64_t ichac97R3StreamTransferCalcNext(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbBytes)
 {
     if (!cbBytes)
@@ -1932,5 +1930,5 @@
 
     const uint64_t usBytes        = DrvAudioHlpBytesToMicro(cbBytes, &pStream->State.Cfg.Props);
-    const uint64_t cTransferTicks = TMTimerFromMicro((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD), usBytes);
+    const uint64_t cTransferTicks = PDMDevHlpTimerFromMicro(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD), usBytes);
 
     Log3Func(("[SD%RU8] Timer %uHz, cbBytes=%RU32 -> usBytes=%RU64, cTransferTicks=%RU64\n",
@@ -1943,9 +1941,10 @@
  * Updates the next transfer based on a specific amount of bytes.
  *
+ * @param   pDevIns             The device instance.
  * @param   pThis               AC'97 device state.
  * @param   pStream             AC'97 stream to update.
  * @param   cbBytes             Bytes to update next transfer for.
  */
-static void ichac97R3StreamTransferUpdate(PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbBytes)
+static void ichac97R3StreamTransferUpdate(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbBytes)
 {
     if (!cbBytes)
@@ -1957,5 +1956,5 @@
 
     /* Update the transfer ticks. */
-    pStream->State.cTransferTicks = ichac97R3StreamTransferCalcNext(pThis, pStream, pStream->State.cbTransferChunk);
+    pStream->State.cTransferTicks = ichac97R3StreamTransferCalcNext(pDevIns, pThis, pStream, pStream->State.cbTransferChunk);
     Assert(pStream->State.cTransferTicks); /* Paranoia. */
 }
@@ -2599,5 +2598,5 @@
     AssertPtr(pStream);
     Assert(PDMDevHlpCritSectIsOwner(pDevIns, &pThis->CritSect));
-    Assert(TMTimerIsLockOwner((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD)));
+    Assert(PDMDevHlpTimerIsLockOwner(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD)));
 
     ichac97R3StreamUpdate(pThis, pStream, true /* fInTimer */);
@@ -2606,8 +2605,9 @@
     if (pSink && AudioMixerSinkIsActive(pSink))
     {
-        ichac97R3StreamTransferUpdate(pThis, pStream, pStream->Regs.picb << 1); /** @todo r=andy Assumes 16-bit samples. */
-
-        ichac97TimerSet(pThis, pStream,
-                        TMTimerGet((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD)) + pStream->State.cTransferTicks,
+        ichac97R3StreamTransferUpdate(pDevIns, pThis, pStream, pStream->Regs.picb << 1); /** @todo r=andy Assumes 16-bit samples. */
+
+        ichac97TimerSet(pDevIns, pThis, pStream,
+                          PDMDevHlpTimerGet(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD))
+                        + pStream->State.cTransferTicks,
                         false /* fForce */);
     }
@@ -2622,4 +2622,5 @@
  *
  * @returns Whether the new expiration time was set or not.
+ * @param   pDevIns             The device instance.
  * @param   pThis               AC'97 state.
  * @param   pStream             AC'97 stream to set timer for.
@@ -2636,5 +2637,5 @@
  *          Forcing a new expiration time will override the above mechanism.
  */
-bool ichac97TimerSet(PAC97STATE pThis, PAC97STREAM pStream, uint64_t tsExpire, bool fForce)
+static bool ichac97TimerSet(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint64_t tsExpire, bool fForce)
 {
     AssertPtrReturn(pThis, false);
@@ -2645,7 +2646,8 @@
     uint64_t tsExpireMin = tsExpire;
 
-    AssertPtr((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD));
-
-    const uint64_t tsNow = TMTimerGet((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD));
+    TMTIMERHANDLE const hTimer = RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD);
+    /** @todo r=bird: This is rather silly given that all three callers just did
+     *        TimerGet + interval. */
+    const uint64_t tsNow = PDMDevHlpTimerGet(pDevIns, hTimer);
 
     /* Make sure to not go backwards in time, as this will assert in TMTimerSet(). */
@@ -2653,8 +2655,8 @@
         tsExpireMin = tsNow;
 
-    int rc = TMTimerSet((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD), tsExpireMin);
-    AssertRC(rc);
-
-    return RT_SUCCESS(rc);
+    int rc = PDMDevHlpTimerSet(pDevIns, hTimer, tsExpireMin);
+    AssertRCReturn(rc, false);
+
+    return true;
 }
 
@@ -3146,6 +3148,9 @@
 
                             /* Arm the timer for this stream. */
-                            int rc2 = ichac97TimerSet(pThis, pStream,
-                                                      TMTimerGet((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD)) + pStream->State.cTransferTicks,
+                            /** @todo r=bird: This function returns bool, not VBox status! */
+                            int rc2 = ichac97TimerSet(pDevIns, pThis, pStream,
+                                                        PDMDevHlpTimerGet(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers,
+                                                                                                      pStream->u8SD))
+                                                      + pStream->State.cTransferTicks,
                                                       false /* fForce */);
                             AssertRC(rc2);
@@ -3641,6 +3646,8 @@
         {
             /* Re-arm the timer for this stream. */
-            rc2 = ichac97TimerSet(pThis, pStream,
-                                  TMTimerGet((pThis)->DEVAC97_CTX_SUFF_SD(pTimer, pStream->u8SD)) + pStream->State.cTransferTicks,
+            /** @todo r=bird: This function returns bool, not VBox status! */
+            rc2 = ichac97TimerSet(pDevIns, pThis, pStream,
+                                    PDMDevHlpTimerGet(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD))
+                                  + pStream->State.cTransferTicks,
                                   false /* fForce */);
         }
@@ -3949,7 +3956,4 @@
     PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE);
     pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
-
-    for (unsigned i = 0; i < AC97_MAX_STREAMS; i++)
-        pThis->pTimerRC[i] = TMTimerRCPtr(pThis->pTimerR3[i]);
 }
 
@@ -4265,27 +4269,24 @@
     ichac97R3Reset(pDevIns);
 
-    static const char * const s_apszNames[] =
-    {
-        "AC97 PI", "AC97 PO", "AC97 MC"
-    };
+    /*
+     * Create the emulation timers (one per stream).
+     *
+     * We must the critical section for the timers as the device has a
+     * noop section associated with it.
+     *
+     * Note:  Use TMCLOCK_VIRTUAL_SYNC here, as the guest's AC'97 driver
+     *        relies on exact (virtual) DMA timing and uses DMA Position Buffers
+     *        instead of the LPIB registers.
+     */
+    static const char * const s_apszNames[] = { "AC97 PI", "AC97 PO", "AC97 MC" };
     AssertCompile(RT_ELEMENTS(s_apszNames) == AC97_MAX_STREAMS);
-
+    AssertCompile(RT_ELEMENTS(pThis->ahTimers) == AC97_MAX_STREAMS);
     for (unsigned i = 0; i < AC97_MAX_STREAMS; i++)
     {
-        /* Create the emulation timer (per stream).
-         *
-         * Note:  Use TMCLOCK_VIRTUAL_SYNC here, as the guest's AC'97 driver
-         *        relies on exact (virtual) DMA timing and uses DMA Position Buffers
-         *        instead of the LPIB registers.
-         */
-        rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, ichac97R3Timer, &pThis->aStreams[i],
-                                    TMTIMER_FLAGS_NO_CRIT_SECT, s_apszNames[i], &pThis->pTimerR3[i]);
+        rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, ichac97R3Timer, &pThis->aStreams[i],
+                                  TMTIMER_FLAGS_NO_CRIT_SECT, s_apszNames[i], &pThis->ahTimers[i]);
         AssertRCReturn(rc, rc);
-        pThis->pTimerR0[i] = TMTimerR0Ptr(pThis->pTimerR3[i]);
-        pThis->pTimerRC[i] = TMTimerRCPtr(pThis->pTimerR3[i]);
-
-        /* Use our own critcal section for the device timer.
-         * That way we can control more fine-grained when to lock what. */
-        rc = TMR3TimerSetCritSect(pThis->pTimerR3[i], &pThis->CritSect);
+
+        rc = PDMDevHlpTimerSetCritSect(pDevIns, pThis->ahTimers[i], &pThis->CritSect);
         AssertRCReturn(rc, rc);
     }
Index: trunk/src/VBox/Devices/Audio/HDAStream.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/HDAStream.cpp	(revision 82323)
+++ trunk/src/VBox/Devices/Audio/HDAStream.cpp	(revision 82324)
@@ -1110,6 +1110,6 @@
                      *
                      * I know, the following code is horribly slow, but seems to work for now.
-                     ** @todo Optimize channel data extraction! Use some SSE(3) / intrinsics?
                      */
+                    /** @todo Optimize channel data extraction! Use some SSE(3) / intrinsics? */
                     for (unsigned m = 0; m < pStream->State.Mapping.cMappings; m++)
                     {
