# HG changeset patch # User Ryan C. Gordon # Date 1015490791 0 # Node ID 9b89bb587f8f772a0a84f32422edb30b9b5c0a61 # Parent 9810e679430185ab2206a883dc063ec7dbf54c65 Detect and discard ID3 tags. diff -r 9810e6794301 -r 9b89bb587f8f decoders/mpglib.c --- a/decoders/mpglib.c Thu Mar 07 08:46:05 2002 +0000 +++ b/decoders/mpglib.c Thu Mar 07 08:46:31 2002 +0000 @@ -217,14 +217,38 @@ sample->flags |= SOUND_SAMPLEFLAG_ERROR; return(bw); } /* if */ + else if (rc == 0) { sample->flags |= SOUND_SAMPLEFLAG_EOF; return(bw); } /* else if */ + /* make sure there isn't an ID3 tag. */ + /* + * !!! FIXME: This can fail under the following circumstances: + * First, if there's the sequence "TAG" 128 bytes from the end + * of a read that isn't the EOF. This is unlikely. + * Second, if the TAG sequence is split between two reads (ie, + * the last byte of a read is 'T', and the next read is the + * final 127 bytes of the stream, being the rest of the ID3 tag). + * While this is more likely, it's still not very likely at all. + * Still, something SHOULD be done about this. + * ID3v2 tags are more complex, too, not to mention LYRICS tags, + * etc, which aren't handled, either. Hey, this IS meant to be + * a lightweight decoder. Use SMPEG if you need an all-purpose + * decoder. mpglib really assumes you control all your assets. + */ + if (rc >= 128) + { + Uint8 *ptr = &mpg->inbuf[rc - 128]; + if ((ptr[0] == 'T') && (ptr[1] == 'A') && (ptr[2] == 'G')) + rc -= 128; /* disregard it. */ + } /* if */ + rc = decodeMP3(&mpg->mp, mpg->inbuf, rc, - mpg->outbuf, sizeof (mpg->outbuf), &mpg->outleft); + mpg->outbuf, sizeof (mpg->outbuf), + &mpg->outleft); if (rc == MP3_ERR) { sample->flags |= SOUND_SAMPLEFLAG_ERROR;