Index: /trunk/src/VBox/Devices/Audio/DevSB16.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/DevSB16.cpp	(revision 55009)
+++ /trunk/src/VBox/Devices/Audio/DevSB16.cpp	(revision 55010)
@@ -189,5 +189,5 @@
     int use_hdma;
     int highspeed;
-    int can_write; /** @Todo Value never gets 0? */
+    int can_write; /** @todo Value never gets 0? */
 
     int v2x6;
@@ -323,5 +323,5 @@
 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
 
-static int magic_of_irq (int irq)
+static int magic_of_irq(int irq)
 {
     switch (irq)
@@ -343,5 +343,5 @@
 }
 
-static int irq_of_magic (int magic)
+static int irq_of_magic(int magic)
 {
     switch (magic)
@@ -363,16 +363,16 @@
 }
 
-#if 0
-static void log_dsp (PSB16STATE dsp)
-{
-    ldebug ("%s:%s:%d:%s:dmasize=%d:freq=%d:const=%d:speaker=%d\n",
-            dsp->fmt_stereo ? "Stereo" : "Mono",
-            dsp->fmt_signed ? "Signed" : "Unsigned",
-            dsp->fmt_bits,
-            dsp->dma_auto ? "Auto" : "Single",
-            dsp->block_size,
-            dsp->freq,
-            dsp->time_const,
-            dsp->speaker);
+#ifdef DEBUG
+static inline void log_dsp(PSB16STATE pThis)
+{
+    LogFlowFunc(("%s:%s:%d:%s:dmasize=%d:freq=%d:const=%d:speaker=%d\n",
+                 pThis->fmt_stereo ? "Stereo" : "Mono",
+                 pThis->fmt_signed ? "Signed" : "Unsigned",
+                 pThis->fmt_bits,
+                 pThis->dma_auto ? "Auto" : "Single",
+                 pThis->block_size,
+                 pThis->freq,
+                 pThis->time_const,
+                 pThis->speaker));
 }
 #endif
@@ -1147,5 +1147,5 @@
 }
 
-static void reset (PSB16STATE pThis)
+static void sb16Reset(PSB16STATE pThis)
 {
 #ifndef VBOX
@@ -1181,88 +1181,99 @@
 }
 
-static IO_WRITE_PROTO (dsp_write)
-{
-    PSB16STATE pThis = (SB16STATE*)opaque;
+static IO_WRITE_PROTO(dsp_write)
+{
+    PSB16STATE pThis = (PSB16STATE)opaque;
     int iport = nport - pThis->port;
 
     LogFlowFunc(("write %#x <- %#x\n", nport, val));
-    switch (iport) {
-    case 0x06:
-        switch (val) {
-        case 0x00:
-            if (pThis->v2x6 == 1) {
-                if (0 && pThis->highspeed) {
-                    pThis->highspeed = 0;
+    switch (iport)
+    {
+        case 0x06:
+            switch (val)
+            {
+                case 0x00:
+                {
+                    if (pThis->v2x6 == 1)
+                    {
+                        if (0 && pThis->highspeed)
+                        {
+                            pThis->highspeed = 0;
 #ifndef VBOX
-                    qemu_irq_lower (pThis->pic[pThis->irq]);
-#else
-                    PDMDevHlpISASetIrq(pThis->pDevIns, pThis->irq, 0);
-#endif
-                    sb16Control(pThis, 0);
+                            qemu_irq_lower (pThis->pic[pThis->irq]);
+#else
+                            PDMDevHlpISASetIrq(pThis->pDevIns, pThis->irq, 0);
+#endif
+                            sb16Control(pThis, 0);
+                        }
+                        else
+                            sb16Reset(pThis);
+                    }
+                    pThis->v2x6 = 0;
+                    break;
                 }
-                else {
-                    reset (pThis);
+
+                case 0x01:
+                case 0x03:              /* FreeBSD kludge */
+                    pThis->v2x6 = 1;
+                    break;
+
+                case 0xc6:
+                    pThis->v2x6 = 0;    /* Prince of Persia, csp.sys, diagnose.exe */
+                    break;
+
+                case 0xb8:              /* Panic */
+                    sb16Reset(pThis);
+                    break;
+
+                case 0x39:
+                    dsp_out_data(pThis, 0x38);
+                    sb16Reset(pThis);
+                    pThis->v2x6 = 0x39;
+                    break;
+
+                default:
+                    pThis->v2x6 = val;
+                    break;
+            }
+            break;
+
+        case 0x0c:                      /* Write data or command | write status */
+#if 0
+            if (pThis->highspeed)
+                break;
+#endif
+            if (0 == pThis->needed_bytes)
+            {
+                command(pThis, val);
+#if 0
+                if (0 == pThis->needed_bytes) {
+                    log_dsp (pThis);
+                }
+#endif
+            }
+            else
+            {
+                if (pThis->in_index == sizeof (pThis->in2_data))
+                {
+                    LogFlowFunc(("in data overrun\n"));
+                }
+                else
+                {
+                    pThis->in2_data[pThis->in_index++] = val;
+                    if (pThis->in_index == pThis->needed_bytes)
+                    {
+                        pThis->needed_bytes = 0;
+                        complete (pThis);
+#if 0
+                        log_dsp (pThis);
+#endif
+                    }
                 }
             }
-            pThis->v2x6 = 0;
-            break;
-
-        case 0x01:
-        case 0x03:              /* FreeBSD kludge */
-            pThis->v2x6 = 1;
-            break;
-
-        case 0xc6:
-            pThis->v2x6 = 0;        /* Prince of Persia, csp.sys, diagnose.exe */
-            break;
-
-        case 0xb8:              /* Panic */
-            reset (pThis);
-            break;
-
-        case 0x39:
-            dsp_out_data (pThis, 0x38);
-            reset (pThis);
-            pThis->v2x6 = 0x39;
             break;
 
         default:
-            pThis->v2x6 = val;
-            break;
-        }
-        break;
-
-    case 0x0c:                  /* write data or command | write status */
-/*         if (pThis->highspeed) */
-/*             break; */
-
-        if (0 == pThis->needed_bytes) {
-            command (pThis, val);
-#if 0
-            if (0 == pThis->needed_bytes) {
-                log_dsp (pThis);
-            }
-#endif
-        }
-        else {
-            if (pThis->in_index == sizeof (pThis->in2_data)) {
-                LogFlowFunc(("in data overrun\n"));
-            }
-            else {
-                pThis->in2_data[pThis->in_index++] = val;
-                if (pThis->in_index == pThis->needed_bytes) {
-                    pThis->needed_bytes = 0;
-                    complete (pThis);
-#if 0
-                    log_dsp (pThis);
-#endif
-                }
-            }
-        }
-        break;
-
-    default:
-        LogFlowFunc(("nport=%#x, val=%#x)\n", nport, val));
-        break;
+            LogFlowFunc(("nport=%#x, val=%#x)\n", nport, val));
+            break;
     }
 
@@ -1272,7 +1283,7 @@
 }
 
-static IO_READ_PROTO (dsp_read)
-{
-    PSB16STATE pThis = (SB16STATE*)opaque;
+static IO_READ_PROTO(dsp_read)
+{
+    PSB16STATE pThis = (PSB16STATE)opaque;
     int iport, retval, ack = 0;
 
@@ -1429,5 +1440,5 @@
 static IO_WRITE_PROTO(mixer_write_indexb)
 {
-    PSB16STATE pThis = (SB16STATE*)opaque;
+    PSB16STATE pThis = (PSB16STATE)opaque;
     (void) nport;
     pThis->mixer_nreg = val;
@@ -1593,5 +1604,5 @@
     mixer_write_datab (opaque, nport, (val >> 8) & 0xff);
 #else  /* VBOX */
-    PSB16STATE pThis = (SB16STATE*)opaque;
+    PSB16STATE pThis = (PSB16STATE)opaque;
     int iport = nport - pThis->port;
     switch (cb)
@@ -1622,5 +1633,5 @@
 static IO_READ_PROTO(mixer_read)
 {
-    PSB16STATE pThis = (SB16STATE*)opaque;
+    PSB16STATE pThis = (PSB16STATE)opaque;
 
     (void) nport;
@@ -2097,5 +2108,5 @@
     pThis->csp_regs[9] = 0xf8;
 
-    sb16MixerReset (pThis);
+    sb16MixerReset(pThis);
     pThis->aux_ts = qemu_new_timer (vm_clock, aux_timer, s);
     if (!pThis->aux_ts) {
@@ -2341,4 +2352,8 @@
     pThis->csp_regs[9]             = 0xf8;
 
+#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
+    RTListInit(&pThis->lstDrv);
+#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
+
     sb16MixerReset(pThis);
 
@@ -2394,6 +2409,4 @@
      */
 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
-    RTListInit(&pThis->lstDrv);
-
     uint8_t uLUN;
     for (uLUN = 0; uLUN < UINT8_MAX; uLUN)
