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".
This commit is contained in:
Max Kellermann 2009-09-30 15:41:43 +02:00
parent b0f9a1454a
commit 65693d057b
2 changed files with 6 additions and 2 deletions

1
NEWS
View File

@ -2,6 +2,7 @@ ver 0.15.4 (2009/??/??)
* decoders:
- vorbis: revert "faster tag scanning with ov_test_callback()"
- faad: skip assertion failure on large ID3 tags
- ffmpeg: use the "artist" tag if "author" is not present
* output:
- osx: fix the OS X 10.6 build

View File

@ -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");