Mercurial > SDL_sound_CoreAudio
comparison decoders/mpglib.c @ 268:9b89bb587f8f
Detect and discard ID3 tags.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 07 Mar 2002 08:46:31 +0000 |
parents | cde06af563f7 |
children | 493dd0173f3d |
comparison
equal
deleted
inserted
replaced
267:9810e6794301 | 268:9b89bb587f8f |
---|---|
215 if (rc == -1) | 215 if (rc == -1) |
216 { | 216 { |
217 sample->flags |= SOUND_SAMPLEFLAG_ERROR; | 217 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
218 return(bw); | 218 return(bw); |
219 } /* if */ | 219 } /* if */ |
220 | |
220 else if (rc == 0) | 221 else if (rc == 0) |
221 { | 222 { |
222 sample->flags |= SOUND_SAMPLEFLAG_EOF; | 223 sample->flags |= SOUND_SAMPLEFLAG_EOF; |
223 return(bw); | 224 return(bw); |
224 } /* else if */ | 225 } /* else if */ |
225 | 226 |
227 /* make sure there isn't an ID3 tag. */ | |
228 /* | |
229 * !!! FIXME: This can fail under the following circumstances: | |
230 * First, if there's the sequence "TAG" 128 bytes from the end | |
231 * of a read that isn't the EOF. This is unlikely. | |
232 * Second, if the TAG sequence is split between two reads (ie, | |
233 * the last byte of a read is 'T', and the next read is the | |
234 * final 127 bytes of the stream, being the rest of the ID3 tag). | |
235 * While this is more likely, it's still not very likely at all. | |
236 * Still, something SHOULD be done about this. | |
237 * ID3v2 tags are more complex, too, not to mention LYRICS tags, | |
238 * etc, which aren't handled, either. Hey, this IS meant to be | |
239 * a lightweight decoder. Use SMPEG if you need an all-purpose | |
240 * decoder. mpglib really assumes you control all your assets. | |
241 */ | |
242 if (rc >= 128) | |
243 { | |
244 Uint8 *ptr = &mpg->inbuf[rc - 128]; | |
245 if ((ptr[0] == 'T') && (ptr[1] == 'A') && (ptr[2] == 'G')) | |
246 rc -= 128; /* disregard it. */ | |
247 } /* if */ | |
248 | |
226 rc = decodeMP3(&mpg->mp, mpg->inbuf, rc, | 249 rc = decodeMP3(&mpg->mp, mpg->inbuf, rc, |
227 mpg->outbuf, sizeof (mpg->outbuf), &mpg->outleft); | 250 mpg->outbuf, sizeof (mpg->outbuf), |
251 &mpg->outleft); | |
228 if (rc == MP3_ERR) | 252 if (rc == MP3_ERR) |
229 { | 253 { |
230 sample->flags |= SOUND_SAMPLEFLAG_ERROR; | 254 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
231 return(bw); | 255 return(bw); |
232 } /* if */ | 256 } /* if */ |