]> git.tue.mpg.de Git - paraslash.git/commitdiff
wma: Decode as much as possible.
authorAndre Noll <maan@systemlinux.org>
Thu, 12 Nov 2009 21:08:09 +0000 (22:08 +0100)
committerAndre Noll <maan@systemlinux.org>
Wed, 18 Nov 2009 18:34:31 +0000 (19:34 +0100)
Currently, we only decode at most one superframe during each
scheduler run. This patch makes the wma decoder as much as what
fits into the output buffer.

wmadec_filter.c

index 802cb8256fa30f66698f765c4cdab004cd3abb8f..9cb964fca0648af10f142732892262aa45db3f80 100644 (file)
@@ -1187,11 +1187,9 @@ fail:
 static ssize_t wmadec_convert(char *inbuffer, size_t len,
                struct filter_node *fn)
 {
-       int ret, out_size = fn->bufsize - fn->loaded;
+       int ret, converted = 0;
        struct private_wmadec_data *pwd = fn->private_data;
 
-       if (out_size < 128 * 1024)
-               return 0;
        if (len <= WMA_FRAME_SKIP)
                return 0;
        if (!pwd) {
@@ -1203,16 +1201,22 @@ static ssize_t wmadec_convert(char *inbuffer, size_t len,
                fn->fc->samplerate = pwd->ahi.sample_rate;
                return pwd->ahi.header_len;
        }
-       /* skip 31 bytes */
-       if (len <= WMA_FRAME_SKIP + pwd->ahi.block_align)
-               return 0;
-       ret = wma_decode_superframe(pwd, fn->buf + fn->loaded,
-               &out_size, (uint8_t *)inbuffer + WMA_FRAME_SKIP,
-               len - WMA_FRAME_SKIP);
-       if (ret < 0)
-               return ret;
-       fn->loaded += out_size;
-       return ret + WMA_FRAME_SKIP;
+       for (;;) {
+               int out_size;
+               if (converted + WMA_FRAME_SKIP + pwd->ahi.block_align > len)
+                       break;
+               out_size = fn->bufsize - fn->loaded;
+               if (out_size < 128 * 1024)
+                       break;
+               ret = wma_decode_superframe(pwd, fn->buf + fn->loaded,
+                       &out_size, (uint8_t *)inbuffer + converted + WMA_FRAME_SKIP,
+                       len - WMA_FRAME_SKIP);
+               if (ret < 0)
+                       return ret;
+               fn->loaded += out_size;
+               converted += ret + WMA_FRAME_SKIP;
+       }
+       return converted;
 }
 
 static void wmadec_close(struct filter_node *fn)