Merge branch 'master' into next
[paraslash.git] / mp3dec.c
index 16599411820313eae492a604fb58d09b1221b752..599d8a90928d6fdeb9c2d2cd418df707c3620fb3 100644 (file)
--- a/mp3dec.c
+++ b/mp3dec.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2007 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2008 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -43,15 +43,25 @@ static ssize_t mp3dec(char *inbuffer, size_t len, struct filter_node *fn)
        pmd->stream.error = 0;
 next_frame:
        ret = mad_header_decode(&pmd->frame.header, &pmd->stream);
-       if (ret < 0)
+       if (ret < 0) {
+               if (pmd->stream.error != MAD_ERROR_BUFLEN &&
+                       pmd->stream.error != MAD_ERROR_LOSTSYNC)
+                       PARA_DEBUG_LOG("header decode: %s\n",
+                               mad_stream_errorstr(&pmd->stream));
                goto out;
+       }
        fn->fc->samplerate = pmd->frame.header.samplerate;
        fn->fc->channels = MAD_NCHANNELS(&pmd->frame.header);
        ret = mad_frame_decode(&pmd->frame, &pmd->stream);
        if (ret) {
-               if (MAD_RECOVERABLE(pmd->stream.error) || pmd->stream.error == MAD_ERROR_BUFLEN)
+               if (MAD_RECOVERABLE(pmd->stream.error) ||
+                       pmd->stream.error == MAD_ERROR_BUFLEN) {
+                       PARA_DEBUG_LOG("frame decode: %s\n",
+                               mad_stream_errorstr(&pmd->stream));
                        goto out;
-               PARA_ERROR_LOG("fatal: ret = %d, loaded = %zd\n", ret, fn->loaded);
+               }
+               PARA_ERROR_LOG("frame decode: %s\n",
+                       mad_stream_errorstr(&pmd->stream));
                return -E_MAD_FRAME_DECODE;
        }
        mad_synth_frame(&pmd->synth, &pmd->frame);
@@ -98,9 +108,9 @@ static void mp3dec_close(struct filter_node *fn)
 
 static void mp3dec_open(struct filter_node *fn)
 {
-       fn->private_data = para_calloc(sizeof(struct private_mp3dec_data));
-       struct private_mp3dec_data *pmd = fn->private_data;
+       struct private_mp3dec_data *pmd = para_calloc(sizeof(*pmd));
 
+       fn->private_data = pmd;
        mad_stream_init(&pmd->stream);
        mad_frame_init(&pmd->frame);
        mad_synth_init(&pmd->synth);
@@ -116,7 +126,7 @@ static void mp3dec_open(struct filter_node *fn)
  *
  * \sa filter::init.
  */
-void mp3dec_init(struct filter *f)
+void mp3dec_filter_init(struct filter *f)
 {
        f->open = mp3dec_open;
        f->convert = mp3dec;