aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/mad_decoder_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-05-30 18:26:33 +0200
committerMax Kellermann <max@duempel.org>2010-05-30 18:26:33 +0200
commit9dda53e1d20ed70b31d8651ad9036f52b1d17360 (patch)
treeb3c353e59783039341af006a602b12c51c01d439 /src/decoder/mad_decoder_plugin.c
parente8310211e216a1de0b4e856496633966d106b831 (diff)
parent57e95ea6f425e03d3d1586e02dae6a0974b00f28 (diff)
downloadmpd-9dda53e1d20ed70b31d8651ad9036f52b1d17360.tar.gz
mpd-9dda53e1d20ed70b31d8651ad9036f52b1d17360.tar.xz
mpd-9dda53e1d20ed70b31d8651ad9036f52b1d17360.zip
Merge release 0.15.10 from branch 'v0.15.x'
Conflicts: NEWS configure.ac src/input/mms_input_plugin.c
Diffstat (limited to 'src/decoder/mad_decoder_plugin.c')
-rw-r--r--src/decoder/mad_decoder_plugin.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/decoder/mad_decoder_plugin.c b/src/decoder/mad_decoder_plugin.c
index 573afc975..32e35f113 100644
--- a/src/decoder/mad_decoder_plugin.c
+++ b/src/decoder/mad_decoder_plugin.c
@@ -468,7 +468,27 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
/* This code is enabled when libid3tag is disabled. Instead
of parsing the ID3 frame, it just skips it. */
- mad_stream_skip(&data->stream, tagsize);
+ size_t count = data->stream.bufend - data->stream.this_frame;
+
+ if (tagsize <= count) {
+ mad_stream_skip(&data->stream, tagsize);
+ } else {
+ mad_stream_skip(&data->stream, count);
+
+ while (count < tagsize) {
+ size_t len = tagsize - count;
+ char ignored[1024];
+ if (len > sizeof(ignored))
+ len = sizeof(ignored);
+
+ len = decoder_read(data->decoder, data->input_stream,
+ ignored, len);
+ if (len == 0)
+ break;
+ else
+ count += len;
+ }
+ }
#endif
}
@@ -476,16 +496,16 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
/**
* This function emulates libid3tag when it is disabled. Instead of
* doing a real analyzation of the frame, it just checks whether the
- * frame begins with the string "ID3". If so, it returns the full
- * length.
+ * frame begins with the string "ID3". If so, it returns the length
+ * of the ID3 frame.
*/
static signed long
id3_tag_query(const void *p0, size_t length)
{
const char *p = p0;
- return length > 3 && memcmp(p, "ID3", 3) == 0
- ? length
+ return length >= 10 && memcmp(p, "ID3", 3) == 0
+ ? (p[8] << 7) + p[9] + 10
: 0;
}
#endif /* !HAVE_ID3TAG */