]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mp3dec_filter.c
mp3dec: Allocate correct output buffer size also for mono files.
[paraslash.git] / mp3dec_filter.c
index c2c15a3aeacd1e2b9b6d613efacd99345f30eb61..7731a379cfe6028559829cdcff9c29e4f541b983 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2010 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2011 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -181,14 +181,13 @@ next_frame:
        }
        mad_synth_frame(&pmd->synth, &pmd->frame);
        pmd->flags |= MP3DEC_FLAG_DECODE_STARTED;
-
-       outbuffer = para_malloc(pmd->synth.pcm.length * 4);
+       outbuffer = para_malloc(pmd->synth.pcm.length * 2 * pmd->channels);
        loaded = 0;
        for (i = 0; i < pmd->synth.pcm.length; i++) {
                int sample = MAD_TO_SHORT(pmd->synth.pcm.samples[0][i]);
                write_int16_host_endian(outbuffer + loaded, sample);
                loaded += 2;
-               if (MAD_NCHANNELS(&pmd->frame.header) == 2) { /* stereo */
+               if (pmd->channels == 2) { /* stereo */
                        sample = MAD_TO_SHORT(pmd->synth.pcm.samples[1][i]);
                        write_int16_host_endian(outbuffer + loaded, sample);
                        loaded += 2;