Index: /trunk/src/VBox/Devices/Audio/DevHDA.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/DevHDA.cpp	(revision 82416)
+++ /trunk/src/VBox/Devices/Audio/DevHDA.cpp	(revision 82417)
@@ -507,5 +507,5 @@
     SSMFIELD_ENTRY(HDASTREAMPERIOD, u64StartWalClk),
     SSMFIELD_ENTRY(HDASTREAMPERIOD, u64ElapsedWalClk),
-    SSMFIELD_ENTRY(HDASTREAMPERIOD, framesTransferred),
+    SSMFIELD_ENTRY(HDASTREAMPERIOD, cFramesTransferred),
     SSMFIELD_ENTRY(HDASTREAMPERIOD, cIntPending),
     SSMFIELD_ENTRY_TERM()
@@ -2786,5 +2786,5 @@
         {
 #  ifdef DEBUG
-            PHDASTREAMDBGINFO pStreamDbg = &pStream->Dbg;
+            PHDASTREAMDEBUG pStreamDbg = &pStream->Dbg;
 
             const uint64_t tsNowNs     = RTTimeNanoTS();
Index: /trunk/src/VBox/Devices/Audio/DevHDA.h
===================================================================
--- /trunk/src/VBox/Devices/Audio/DevHDA.h	(revision 82416)
+++ /trunk/src/VBox/Devices/Audio/DevHDA.h	(revision 82417)
@@ -101,5 +101,5 @@
 
 /**
- * ICH Intel HD Audio Controller state.
+ * Shared ICH Intel HD audio controller state.
  */
 typedef struct HDASTATE
@@ -226,5 +226,7 @@
      *  This is set to HDASTATE_ALIGNMENT_CHECK_MAGIC. */
     uint64_t                uAlignmentCheckMagic;
-} HDASTATE, *PHDASTATE;
+} HDASTATE;
+/** Pointer to a shared HDA device state.  */
+typedef HDASTATE *PHDASTATE;
 
 /** Value for HDASTATE:uAlignmentCheckMagic. */
Index: /trunk/src/VBox/Devices/Audio/DevHDACommon.h
===================================================================
--- /trunk/src/VBox/Devices/Audio/DevHDACommon.h	(revision 82416)
+++ /trunk/src/VBox/Devices/Audio/DevHDACommon.h	(revision 82417)
@@ -535,9 +535,9 @@
 
 
-/** The HDA controller. */
+/** Pointer to a shared HDA state. */
 typedef struct HDASTATE *PHDASTATE;
-/** The HDA stream. */
+/** Pointer to a HDA stream state. */
 typedef struct HDASTREAM *PHDASTREAM;
-
+/** Pointer to a mixer sink. */
 typedef struct HDAMIXERSINK *PHDAMIXERSINK;
 
Index: /trunk/src/VBox/Devices/Audio/HDACodec.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/HDACodec.cpp	(revision 82416)
+++ /trunk/src/VBox/Devices/Audio/HDACodec.cpp	(revision 82417)
@@ -2712,4 +2712,5 @@
  * HDA codec verb map.
  * @todo Any reason not to use binary search here?
+ *      bird: because you'd need to sort the entries first...
  */
 static const CODECVERB g_aCodecVerbs[] =
Index: /trunk/src/VBox/Devices/Audio/HDAStream.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/HDAStream.cpp	(revision 82416)
+++ /trunk/src/VBox/Devices/Audio/HDAStream.cpp	(revision 82417)
@@ -924,6 +924,5 @@
 
     PHDASTREAMPERIOD pPeriod = &pStream->State.Period;
-    if (!hdaR3StreamPeriodLock(pPeriod))
-        return VERR_ACCESS_DENIED;
+    hdaR3StreamPeriodLock(pPeriod))
 
     bool fProceed = true;
Index: /trunk/src/VBox/Devices/Audio/HDAStream.h
===================================================================
--- /trunk/src/VBox/Devices/Audio/HDAStream.h	(revision 82416)
+++ /trunk/src/VBox/Devices/Audio/HDAStream.h	(revision 82417)
@@ -1,5 +1,5 @@
 /* $Id$ */
 /** @file
- * HDAStream.h - Stream functions for HD Audio.
+ * HDAStream.h - Streams for HD Audio.
  */
 
@@ -23,31 +23,30 @@
 
 #include "DevHDACommon.h"
-
 #include "HDAStreamMap.h"
 #include "HDAStreamPeriod.h"
 
 
-typedef struct HDAMIXERSINK *PHDAMIXERSINK;
-
 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO
 /**
- * Structure keeping the HDA stream's state for asynchronous I/O.
+ * HDA stream's state for asynchronous I/O.
  */
 typedef struct HDASTREAMSTATEAIO
 {
     /** Thread handle for the actual I/O thread. */
-    RTTHREAD              Thread;
+    RTTHREAD                Thread;
     /** Event for letting the thread know there is some data to process. */
-    RTSEMEVENT            Event;
+    RTSEMEVENT              Event;
     /** Critical section for synchronizing access. */
-    RTCRITSECT            CritSect;
+    RTCRITSECT              CritSect;
     /** Started indicator. */
-    volatile bool         fStarted;
+    volatile bool           fStarted;
     /** Shutdown indicator. */
-    volatile bool         fShutdown;
+    volatile bool           fShutdown;
     /** Whether the thread should do any data processing or not. */
-    volatile bool         fEnabled;
-    uint32_t              Padding1;
-} HDASTREAMSTATEAIO, *PHDASTREAMSTATEAIO;
+    volatile bool           fEnabled;
+    bool                    afPadding[1+4];
+} HDASTREAMSTATEAIO;
+/** Pointer to a HDA stream's asynchronous I/O state. */
+typedef HDASTREAMSTATEAIO *PHDASTREAMSTATEAIO;
 #endif
 
@@ -55,5 +54,5 @@
  * Structure containing HDA stream debug stuff, configurable at runtime.
  */
-typedef struct HDASTREAMDBGINFORT
+typedef struct HDASTREAMDEBUGRT
 {
     /** Whether debugging is enabled or not. */
@@ -70,10 +69,10 @@
     /** File for dumping mapped (that is, extracted) DMA reads / writes. */
     R3PTRTYPE(PPDMAUDIOFILE) pFileDMAMapped;
-} HDASTREAMDBGINFORT, *PHDASTREAMDBGINFORT;
+} HDASTREAMDEBUGRT;
 
 /**
  * Structure containing HDA stream debug information.
  */
-typedef struct HDASTREAMDBGINFO
+typedef struct HDASTREAMDEBUG
 {
 #ifdef DEBUG
@@ -106,6 +105,7 @@
 #endif
     /** Runtime debug info. */
-    HDASTREAMDBGINFORT      Runtime;
-} HDASTREAMDBGINFO ,*PHDASTREAMDBGINFO;
+    HDASTREAMDEBUGRT        Runtime;
+} HDASTREAMDEBUG;
+typedef HDASTREAMDEBUG *PHDASTREAMDEBUG;
 
 /**
@@ -185,4 +185,5 @@
 } HDASTREAMSTATE;
 AssertCompileSizeAlignment(HDASTREAMSTATE, 8);
+/** Pointer to the internal state of an HDA stream. */
 typedef HDASTREAMSTATE *PHDASTREAMSTATE;
 
@@ -204,19 +205,19 @@
 {
     /** Stream descriptor number (SDn). */
-    uint8_t                  u8SD;
+    uint8_t                     u8SD;
     /** Current channel index.
      *  For a stereo stream, this is u8Channel + 1. */
-    uint8_t                  u8Channel;
-    uint8_t                  Padding0[6];
+    uint8_t                     u8Channel;
+    uint8_t                     abPadding0[6];
     /** DMA base address (SDnBDPU - SDnBDPL).
      *  Will be updated in hdaR3StreamInit(). */
-    uint64_t                 u64BDLBase;
+    uint64_t                    u64BDLBase;
     /** Cyclic Buffer Length (SDnCBL).
      *  Represents the size of the ring buffer.
      *  Will be updated in hdaR3StreamInit(). */
-    uint32_t                 u32CBL;
+    uint32_t                    u32CBL;
     /** Format (SDnFMT).
      *  Will be updated in hdaR3StreamInit(). */
-    uint16_t                 u16FMT;
+    uint16_t                    u16FMT;
     /** FIFO Size (FIFOS).
      *  Maximum number of bytes that may have been DMA'd into
@@ -224,23 +225,23 @@
      *
      *  Will be updated in hdaR3StreamInit(). */
-    uint16_t                 u16FIFOS;
+    uint16_t                    u16FIFOS;
     /** FIFO Watermark. */
-    uint16_t                 u16FIFOW;
+    uint16_t                    u16FIFOW;
     /** Last Valid Index (SDnLVI).
      *  Will be updated in hdaR3StreamInit(). */
-    uint16_t                 u16LVI;
-    uint16_t                 Padding1[2];
+    uint16_t                    u16LVI;
+    uint16_t                    au16Padding1[2];
     /** Pointer to the HDA state this stream is attached to. */
-    R3PTRTYPE(PHDASTATE)     pHDAState;
+    R3PTRTYPE(PHDASTATE)        pHDAState;
     /** Pointer to HDA sink this stream is attached to. */
-    R3PTRTYPE(PHDAMIXERSINK) pMixSink;
+    R3PTRTYPE(PHDAMIXERSINK)    pMixSink;
     /** The timer for pumping data thru the attached LUN drivers. */
-    TMTIMERHANDLE            hTimer;
+    TMTIMERHANDLE               hTimer;
     /** The stream'S critical section to serialize access. */
-    RTCRITSECT               CritSect;
+    RTCRITSECT                  CritSect;
     /** Internal state of this stream. */
-    HDASTREAMSTATE           State;
+    HDASTREAMSTATE              State;
     /** Debug information. */
-    HDASTREAMDBGINFO         Dbg;
+    HDASTREAMDEBUG              Dbg;
 } HDASTREAM;
 /** Pointer to an HDA stream (SDI / SDO).  */
@@ -282,13 +283,6 @@
 bool              hdaR3StreamRegisterDMAHandlers(PHDASTREAM pStream);
 void              hdaR3StreamUnregisterDMAHandlers(PHDASTREAM pStream);
-# endif /* HDA_USE_DMA_ACCESS_HANDLER */
+# endif
 /** @} */
-
-/** @name Timer functions.
- * @{
- */
-DECLCALLBACK(void) hdaR3StreamTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser);
-/** @} */
-
 
 /** @name Async I/O stream functions.
Index: /trunk/src/VBox/Devices/Audio/HDAStreamPeriod.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/HDAStreamPeriod.cpp	(revision 82416)
+++ /trunk/src/VBox/Devices/Audio/HDAStreamPeriod.cpp	(revision 82417)
@@ -106,19 +106,19 @@
         cTotalPeriods = 2; /* At least two periods *must* be present (LVI >= 1). */
 
-    uint32_t framesToTransfer = (u32CBL / 4 /** @todo Define frame size? */) / cTotalPeriods;
+    uint32_t cFramesToTransfer = (u32CBL / 4 /** @todo Define frame size? */) / cTotalPeriods;
 
     pPeriod->u8SD              = u8SD;
     pPeriod->u64StartWalClk    = 0;
     pPeriod->u32Hz             = pStreamCfg->Props.uHz;
-    pPeriod->u64DurationWalClk = hdaR3StreamPeriodFramesToWalClk(pPeriod, framesToTransfer);
+    pPeriod->u64DurationWalClk = hdaR3StreamPeriodFramesToWalClk(pPeriod, cFramesToTransfer);
     pPeriod->u64ElapsedWalClk  = 0;
     pPeriod->i64DelayWalClk    = 0;
-    pPeriod->framesToTransfer  = framesToTransfer;
-    pPeriod->framesTransferred = 0;
+    pPeriod->cFramesToTransfer  = cFramesToTransfer;
+    pPeriod->cFramesTransferred = 0;
     pPeriod->cIntPending       = 0;
 
     Log3Func(("[SD%RU8] %RU64 long, Hz=%RU32, CBL=%RU32, LVI=%RU16 -> %u periods, %RU32 frames each\n",
               pPeriod->u8SD, pPeriod->u64DurationWalClk, pPeriod->u32Hz, u32CBL, u16LVI,
-              cTotalPeriods, pPeriod->framesToTransfer));
+              cTotalPeriods, pPeriod->cFramesToTransfer));
 
     return VINF_SUCCESS;
@@ -141,5 +141,5 @@
     pPeriod->u64StartWalClk    = 0;
     pPeriod->u64ElapsedWalClk  = 0;
-    pPeriod->framesTransferred = 0;
+    pPeriod->cFramesTransferred = 0;
     pPeriod->cIntPending       = 0;
 # ifdef LOG_ENABLED
@@ -162,5 +162,5 @@
     pPeriod->u64StartWalClk    = u64WalClk;
     pPeriod->u64ElapsedWalClk  = 0;
-    pPeriod->framesTransferred = 0;
+    pPeriod->cFramesTransferred = 0;
     pPeriod->cIntPending       = 0;
 # ifdef LOG_ENABLED
@@ -224,10 +224,12 @@
  * Locks a stream period for serializing access.
  *
- * @return  true if locking was successful, false if not.
+ * @returns IPRT status code (safe to ignore, asserted).
  * @param   pPeriod             Stream period to lock.
  */
-bool hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod)
-{
-    return RT_SUCCESS(RTCritSectEnter(&pPeriod->CritSect));
+int hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod)
+{
+    int rc = RTCritSectEnter(&pPeriod->CritSect);
+    AssertRC(rc);
+    return rc;
 }
 
@@ -295,6 +297,6 @@
 uint32_t hdaR3StreamPeriodGetRemainingFrames(PHDASTREAMPERIOD pPeriod)
 {
-    Assert(pPeriod->framesToTransfer >= pPeriod->framesTransferred);
-    return pPeriod->framesToTransfer - pPeriod->framesTransferred;
+    Assert(pPeriod->cFramesToTransfer >= pPeriod->cFramesTransferred);
+    return pPeriod->cFramesToTransfer - pPeriod->cFramesTransferred;
 }
 
@@ -385,12 +387,12 @@
 void hdaR3StreamPeriodInc(PHDASTREAMPERIOD pPeriod, uint32_t framesInc)
 {
-    pPeriod->framesTransferred += framesInc;
-    Assert(pPeriod->framesTransferred <= pPeriod->framesToTransfer);
-
-    pPeriod->u64ElapsedWalClk   = hdaR3StreamPeriodFramesToWalClk(pPeriod, pPeriod->framesTransferred);
+    pPeriod->cFramesTransferred += framesInc;
+    Assert(pPeriod->cFramesTransferred <= pPeriod->cFramesToTransfer);
+
+    pPeriod->u64ElapsedWalClk   = hdaR3StreamPeriodFramesToWalClk(pPeriod, pPeriod->cFramesTransferred);
     Assert(pPeriod->u64ElapsedWalClk <= pPeriod->u64DurationWalClk);
 
     Log3Func(("[SD%RU8] cbTransferred=%RU32, u64ElapsedWalClk=%RU64\n",
-              pPeriod->u8SD, pPeriod->framesTransferred, pPeriod->u64ElapsedWalClk));
+              pPeriod->u8SD, pPeriod->cFramesTransferred, pPeriod->u64ElapsedWalClk));
 }
 
@@ -409,9 +411,9 @@
                                 hdaR3StreamPeriodHasElapsed(pPeriod)
                              /* All frames transferred? */
-                             && pPeriod->framesTransferred >= pPeriod->framesToTransfer;
+                             && pPeriod->cFramesTransferred >= pPeriod->cFramesToTransfer;
 # ifdef VBOX_STRICT
     if (fIsComplete)
     {
-        Assert(pPeriod->framesTransferred == pPeriod->framesToTransfer);
+        Assert(pPeriod->cFramesTransferred == pPeriod->cFramesToTransfer);
         Assert(pPeriod->u64ElapsedWalClk  == pPeriod->u64DurationWalClk);
     }
Index: /trunk/src/VBox/Devices/Audio/HDAStreamPeriod.h
===================================================================
--- /trunk/src/VBox/Devices/Audio/HDAStreamPeriod.h	(revision 82416)
+++ /trunk/src/VBox/Devices/Audio/HDAStreamPeriod.h	(revision 82417)
@@ -28,6 +28,4 @@
 #include <VBox/log.h> /* LOG_ENABLED */
 
-struct HDASTREAM;
-typedef struct HDASTREAM *PHDASTREAM;
 
 #ifdef LOG_ENABLED
@@ -35,9 +33,9 @@
  * Debug stuff for a HDA stream's period.
  */
-typedef struct HDASTREAMPERIODDDEBUG
+typedef struct HDASTREAMPERIODDEBUG
 {
     /** Host start time (in ns) of the period. */
     uint64_t                tsStartNs;
-} HDASTREAMPERIODDDEBUG;
+} HDASTREAMPERIODDEBUG;
 #endif
 
@@ -56,5 +54,7 @@
 typedef struct HDASTREAMPERIOD
 {
-    /** Critical section for serializing access. */
+    /** Critical section for serializing access.
+     * @todo r=bird: This is not needed.  The stream lock is held the two places
+     *       this critsect is entered. */
     RTCRITSECT              CritSect;
     /** Associated HDA stream descriptor (SD) number. */
@@ -76,10 +76,10 @@
     int64_t                 i64DelayWalClk;
     /** Number of audio frames to transfer for this period. */
-    uint32_t                framesToTransfer;
+    uint32_t                cFramesToTransfer;
     /** Number of audio frames already transfered. */
-    uint32_t                framesTransferred;
+    uint32_t                cFramesTransferred;
 #ifdef LOG_ENABLED
     /** Debugging state. */
-    HDASTREAMPERIODDDEBUG   Dbg;
+    HDASTREAMPERIODDEBUG    Dbg;
 #endif
 } HDASTREAMPERIOD;
@@ -97,5 +97,5 @@
 void     hdaR3StreamPeriodPause(PHDASTREAMPERIOD pPeriod);
 void     hdaR3StreamPeriodResume(PHDASTREAMPERIOD pPeriod);
-bool     hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod);
+int      hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod);
 void     hdaR3StreamPeriodUnlock(PHDASTREAMPERIOD pPeriod);
 uint64_t hdaR3StreamPeriodFramesToWalClk(PHDASTREAMPERIOD pPeriod, uint32_t uFrames);
