Index: wma.c
===================================================================
--- wma.c	(revision 15521)
+++ wma.c	(working copy)
@@ -314,6 +314,7 @@
     uint8_t* audiobuf;
     int audiobufsize;
     int packetlength;
+    int errcount = 0;
 
     /* Generic codec initialisation */
     ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512);
@@ -353,7 +354,7 @@
 
     ci->configure(DSP_SWITCH_FREQUENCY, wfx.rate);
     ci->configure(DSP_SET_STEREO_MODE, wfx.channels == 1 ?
-                  STEREO_MONO : STEREO_INTERLEAVED);
+                  STEREO_MONO : STEREO_NONINTERLEAVED);
     codec_set_replaygain(ci->id3);
 
     /* The main decoding loop */
@@ -382,26 +383,35 @@
             }
             ci->seek_complete();
         }
-
+new_packet:
         res = asf_read_packet(&audiobuf, &audiobufsize, &packetlength, &wfx);
+        /* if asf_read_packet() fails, we'll give up immediately */
         if (res > 0) {
-            wma_decode_superframe_init(&wmadec,
-                                       audiobuf, audiobufsize);
-
+            errcount = 0;
+            wma_decode_superframe_init(&wmadec, audiobuf, audiobufsize);
             for (i=0; i < wmadec.nb_frames; i++)
             {
-                wmares = wma_decode_superframe_frame(&wmadec,
-                                                     decoded,
+                wmares = wma_decode_superframe_frame(&wmadec, decoded,
                                                      audiobuf, audiobufsize);
 
                 ci->yield ();
 
                 if (wmares < 0)
                 {
-                    LOGF("WMA decode error %d\n",wmares);
-                    goto done;
+                    /* We'll try to recover from an error a certain number of
+                     * times. If we succeed, the error counter will be reset.
+                     */
+                    errcount++;
+                    DEBUGF("WMA decode error %d, errcount %d\n",wmares, errcount);
+                    if (errcount > 5) {
+                        goto done;
+                    } else {
+                        ci->advance_buffer(packetlength);
+                        goto new_packet;
+                    }
                 } else if (wmares > 0) {
-                    ci->pcmbuf_insert(decoded, NULL, wmares);
+                    ci->pcmbuf_insert(wmadec.frame_out[0], wmadec.frame_out[1],
+                                      wmares);
                     samplesdone += wmares;
                     elapsedtime = (samplesdone*10)/(wfx.rate/100);
                     ci->set_elapsed(elapsedtime);
Index: libwma/wmadeci.c
===================================================================
--- libwma/wmadeci.c	(revision 15550)
+++ libwma/wmadeci.c	(working copy)
@@ -1405,50 +1405,28 @@
 /* decode a frame of frame_len samples */
 static int wma_decode_frame(WMADecodeContext *s, int32_t *samples)
 {
-    int ret, i, n, ch, incr;
-    int32_t *ptr;
-    fixed32 *iptr;
-   // rb->splash(HZ, "in wma_decode_frame");
+    int ret, ch;
 
+    /* do the overlap */
+    for(ch = 0; ch < s->nb_channels; ch++) {
+        /* prepare for next block */
+        memcpy(&s->frame_out[ch][0], &s->frame_out[ch][s->frame_len],
+               s->frame_len * sizeof(fixed32));
+    }
+
     /* read each block */
     s->block_num = 0;
     s->block_pos = 0;
-
-
-    for(;;)
-    {
+    for(;;) {
         ret = wma_decode_block(s);
-        if (ret < 0)
-        {
-
-            //rb->splash(HZ*4, "wma_decode_block failed with ret %d", ret);
+        if (ret < 0) {
+            DEBUGF("ret is %i\n", ret); // remove braces
             return -1;
         }
         if (ret)
-        {
             break;
-        }
     }
 
-    /* return frame with full 30-bit precision */
-    n = s->frame_len;
-    incr = s->nb_channels;
-    for(ch = 0; ch < s->nb_channels; ++ch)
-    {
-        ptr = samples + ch;
-        iptr = s->frame_out[ch];
-
-        for (i=0;i<n;++i)
-        {
-            *ptr = (*iptr++);
-            ptr += incr;
-        }
-        /* prepare for next block */
-        memmove(&s->frame_out[ch][0], &s->frame_out[ch][s->frame_len],
-                s->frame_len * sizeof(fixed32));
-
-    }
-
     return 0;
 }
 
