From f353bf77ba17cf75489f10d60e0593c740e669fb Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 14 Jan 2009 23:21:45 +0100 Subject: [PATCH] oggvorbis: moved tag look into vorbis_parse_comment() vorbis_parse_comment() should be a function which converts one comment to a tag item. It should do everything required to do the conversion, including looping over all possible tag types. --- src/decoder/oggvorbis_plugin.c | 36 ++++++++++++---------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/decoder/oggvorbis_plugin.c b/src/decoder/oggvorbis_plugin.c index c1fb799f0..a74722cdf 100644 --- a/src/decoder/oggvorbis_plugin.c +++ b/src/decoder/oggvorbis_plugin.c @@ -160,25 +160,21 @@ vorbis_copy_comment(struct tag *tag, const char *comment, return false; } -static bool -vorbis_parse_comment(struct tag *tag, char *comment, enum tag_type tag_type) +static void +vorbis_parse_comment(struct tag *tag, const char *comment) { - const char *needle; - assert(tag != NULL); - switch (tag_type) { - case TAG_ITEM_TRACK: - needle = VORBIS_COMMENT_TRACK_KEY; - break; - case TAG_ITEM_DISC: - needle = VORBIS_COMMENT_DISC_KEY; - break; - default: - needle = mpdTagItemKeys[tag_type]; - } + if (vorbis_copy_comment(tag, comment, VORBIS_COMMENT_TRACK_KEY, + TAG_ITEM_TRACK) || + vorbis_copy_comment(tag, comment, VORBIS_COMMENT_DISC_KEY, + TAG_ITEM_DISC)) + return; - return vorbis_copy_comment(tag, comment, needle, tag_type); + for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) + if (vorbis_copy_comment(tag, comment, + mpdTagItemKeys[i], i)) + return; } static struct tag * @@ -186,14 +182,8 @@ vorbis_comments_to_tag(char **comments) { struct tag *tag = tag_new(); - while (*comments) { - int j; - for (j = TAG_NUM_OF_ITEM_TYPES; --j >= 0;) { - if (vorbis_parse_comment(tag, *comments, j)) - break; - } - comments++; - } + while (*comments) + vorbis_parse_comment(tag, *comments++); if (tag_is_empty(tag)) { tag_free(tag);