diff options
author | J. Alexander Treuman <jat@spatialrift.net> | 2006-05-15 13:48:47 +0000 |
---|---|---|
committer | J. Alexander Treuman <jat@spatialrift.net> | 2006-05-15 13:48:47 +0000 |
commit | c9b3498a2df280d112cf575b38af767540f033b3 (patch) | |
tree | 110238126b466c87ced16f92bc502015d559a859 /src/inputPlugins/mp3_plugin.c | |
parent | 581507209d7898ee85e5228bc76404037b4999e8 (diff) | |
download | mpd-c9b3498a2df280d112cf575b38af767540f033b3.tar.gz mpd-c9b3498a2df280d112cf575b38af767540f033b3.tar.xz mpd-c9b3498a2df280d112cf575b38af767540f033b3.zip |
Work around a stupid bug in libmad so VBR MP3s with CRC protection have the correct length.
git-svn-id: https://svn.musicpd.org/mpd/trunk@4184 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/inputPlugins/mp3_plugin.c')
-rw-r--r-- | src/inputPlugins/mp3_plugin.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 8a73ed85d..6fe9f3849 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -154,7 +154,7 @@ void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream) { memset(&(data->dither), 0, sizeof(struct audio_dither)); mad_stream_init(&data->stream); - data->stream.options |= MAD_OPTION_IGNORECRC; + mad_stream_options(&data->stream, MAD_OPTION_IGNORECRC); mad_frame_init(&data->frame); mad_synth_init(&data->synth); mad_timer_reset(&data->timer); @@ -397,7 +397,8 @@ int decodeNextFrame(mp3DecodeData * data) { } /* xing stuff stolen from alsaplayer */ -# define XING_MAGIC (('X' << 24) | ('i' << 16) | ('n' << 8) | 'g') +#define XI_MAGIC (('X' << 8) | 'i') +#define NG_MAGIC (('n' << 8) | 'g') struct xing { long flags; /* valid fields (see below) */ @@ -416,10 +417,22 @@ enum { int parse_xing(struct xing *xing, struct mad_bitptr ptr, unsigned int bitlen) { - if (bitlen < 64 || mad_bit_read(&ptr, 32) != XING_MAGIC) goto fail; + unsigned long bits; + if (bitlen < 16) goto fail; + bits = mad_bit_read(&ptr, 16); + bitlen -= 16; + + if (bits == XI_MAGIC) { + if (bitlen < 16) goto fail; + if (mad_bit_read(&ptr, 16) != NG_MAGIC) goto fail; + bitlen -= 16; + } + else if (bits != NG_MAGIC) goto fail; + + if (bitlen < 32) goto fail; xing->flags = mad_bit_read(&ptr, 32); - bitlen -= 64; + bitlen -= 32; if (xing->flags & XING_FRAMES) { if (bitlen < 32) goto fail; |