Better error diagnostics for the mp3 decoder.
authorAndre Noll <maan@systemlinux.org>
Sat, 22 Nov 2008 20:37:34 +0000 (21:37 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 22 Nov 2008 20:37:34 +0000 (21:37 +0100)
mp3dec.c

index 763ca37..615a064 100644 (file)
--- a/mp3dec.c
+++ b/mp3dec.c
@@ -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);