From b0f9a1454af5af826255e988d1ca8fe78df2c136 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 30 Sep 2009 15:22:47 +0200 Subject: decoder/faad: skip assertion failure on large ID3 tags When the ID3 tag in an AAC file is larger than the current buffer, the function decoder_buffer_consume() aborts. By using the new function decoder_buffer_skip() instead, we can safely skip the ID3 tag. --- src/decoder/faad_plugin.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/decoder') diff --git a/src/decoder/faad_plugin.c b/src/decoder/faad_plugin.c index d0537dd5b..7b2806a4c 100644 --- a/src/decoder/faad_plugin.c +++ b/src/decoder/faad_plugin.c @@ -162,6 +162,7 @@ faad_song_duration(struct decoder_buffer *buffer, struct input_stream *is) size_t tagsize; const unsigned char *data; size_t length; + bool success; fileread = is->size >= 0 ? is->size : 0; @@ -179,8 +180,11 @@ faad_song_duration(struct decoder_buffer *buffer, struct input_stream *is) tagsize += 10; - decoder_buffer_consume(buffer, tagsize); - decoder_buffer_fill(buffer); + success = decoder_buffer_skip(buffer, tagsize) && + decoder_buffer_fill(buffer); + if (!success) + return -1; + data = decoder_buffer_read(buffer, &length); if (data == NULL) return -1; -- cgit v1.2.3 From 65693d057bd57a8df3f491650485087365170564 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 30 Sep 2009 15:41:43 +0200 Subject: decoder/ffmpeg: use the "artist" tag if "author" is not present Usually, we read our "artist" tag from ffmpeg's "author" tag. In some cases however (e.g. APE), this tag is named "artist". This patch implements a fallback: if no "author" is found, MPD tries to use "artist". --- src/decoder/ffmpeg_plugin.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/decoder') diff --git a/src/decoder/ffmpeg_plugin.c b/src/decoder/ffmpeg_plugin.c index abccdf977..27b0c2507 100644 --- a/src/decoder/ffmpeg_plugin.c +++ b/src/decoder/ffmpeg_plugin.c @@ -338,13 +338,14 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) } #if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(31<<8)+0) -static void +static bool ffmpeg_copy_metadata(struct tag *tag, AVMetadata *m, enum tag_type type, const char *name) { AVMetadataTag *mt = av_metadata_get(m, name, NULL, 0); if (mt != NULL) tag_add_item(tag, type, mt->value); + return mt != NULL; } #endif @@ -359,7 +360,9 @@ static bool ffmpeg_tag_internal(struct ffmpeg_context *ctx) #if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(31<<8)+0) ffmpeg_copy_metadata(tag, f->metadata, TAG_ITEM_TITLE, "title"); - ffmpeg_copy_metadata(tag, f->metadata, TAG_ITEM_ARTIST, "author"); + if (!ffmpeg_copy_metadata(tag, f->metadata, TAG_ITEM_ARTIST, "author")) + ffmpeg_copy_metadata(tag, f->metadata, + TAG_ITEM_ARTIST, "artist"); ffmpeg_copy_metadata(tag, f->metadata, TAG_ITEM_ALBUM, "album"); ffmpeg_copy_metadata(tag, f->metadata, TAG_ITEM_COMMENT, "comment"); ffmpeg_copy_metadata(tag, f->metadata, TAG_ITEM_GENRE, "genre"); -- cgit v1.2.3