fix handling of corrupt mp3 files
authorAndre <maan@meins.(none)>
Sat, 4 Nov 2006 13:59:40 +0000 (14:59 +0100)
committerAndre <maan@meins.(none)>
Sat, 4 Nov 2006 13:59:40 +0000 (14:59 +0100)
When a recoverable error occured we always returned FRAME_HEADER_SIZE
in mp3dec, which is clearly wrong if the error did not happen in the
first frame.

Fix is not to distinguish between recoverable and unrecoverable
errors which even simplifies the code a bit.

mp3dec.c

index fc2b9d8..1818d4c 100644 (file)
--- a/mp3dec.c
+++ b/mp3dec.c
@@ -49,7 +49,6 @@ struct private_mp3dec_data {
 };
 
 /* TODO: Convert all input if possible */
-#define FRAME_HEADER_SIZE 4
 static ssize_t mp3dec(char *inbuffer, size_t len, struct filter_node *fn)
 {
        int i, ret;
@@ -62,11 +61,8 @@ 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 (!MAD_RECOVERABLE(pmd->stream.error))
-                       goto out;
-               return FRAME_HEADER_SIZE;
-       }
+       if (ret < 0)
+               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);