diff options
author | Max Kellermann <max@duempel.org> | 2012-02-11 10:51:43 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-02-11 12:37:24 +0100 |
commit | 1892d29be0567486792464b0457e8afb335d9e08 (patch) | |
tree | 7f5c9e6258081010c8751c72374ea8f683aec703 /src/decoder/vorbis_comments.c | |
parent | 9e5a49b8cb6d655bdab52232f390a4faa9253f99 (diff) | |
download | mpd-1892d29be0567486792464b0457e8afb335d9e08.tar.gz mpd-1892d29be0567486792464b0457e8afb335d9e08.tar.xz mpd-1892d29be0567486792464b0457e8afb335d9e08.zip |
decoder/{vorbis,flac}: use the tag_table library
Diffstat (limited to 'src/decoder/vorbis_comments.c')
-rw-r--r-- | src/decoder/vorbis_comments.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/decoder/vorbis_comments.c b/src/decoder/vorbis_comments.c index 98b5166e5..9145507dc 100644 --- a/src/decoder/vorbis_comments.c +++ b/src/decoder/vorbis_comments.c @@ -20,6 +20,7 @@ #include "config.h" #include "vorbis_comments.h" #include "tag.h" +#include "tag_table.h" #include "replay_gain_info.h" #include <glib.h> @@ -73,9 +74,6 @@ vorbis_comments_to_replay_gain(struct replay_gain_info *rgi, char **comments) return found; } -static const char *VORBIS_COMMENT_TRACK_KEY = "tracknumber"; -static const char *VORBIS_COMMENT_DISC_KEY = "discnumber"; - /** * Check if the comment's name equals the passed name, and if so, copy * the comment value into the tag. @@ -95,18 +93,21 @@ vorbis_copy_comment(struct tag *tag, const char *comment, return false; } +static const struct tag_table vorbis_tags[] = { + { "tracknumber", TAG_TRACK }, + { "discnumber", TAG_DISC }, + { "album artist", TAG_ALBUM_ARTIST }, + { NULL, TAG_NUM_OF_ITEM_TYPES } +}; + static void vorbis_parse_comment(struct tag *tag, const char *comment) { assert(tag != NULL); - if (vorbis_copy_comment(tag, comment, VORBIS_COMMENT_TRACK_KEY, - TAG_TRACK) || - vorbis_copy_comment(tag, comment, VORBIS_COMMENT_DISC_KEY, - TAG_DISC) || - vorbis_copy_comment(tag, comment, "album artist", - TAG_ALBUM_ARTIST)) - return; + for (const struct tag_table *i = vorbis_tags; i->name != NULL; ++i) + if (vorbis_copy_comment(tag, comment, i->name, i->type)) + return; for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) if (vorbis_copy_comment(tag, comment, |