aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-14 23:21:45 +0100
committerMax Kellermann <max@duempel.org>2009-01-14 23:21:45 +0100
commitf353bf77ba17cf75489f10d60e0593c740e669fb (patch)
tree6b6e6148ef0189195fc2cd1623c8bdb7e9d3c542
parent69b033757f422d6472315f7892c303f92da495b6 (diff)
downloadmpd-f353bf77ba17cf75489f10d60e0593c740e669fb.tar.gz
mpd-f353bf77ba17cf75489f10d60e0593c740e669fb.tar.xz
mpd-f353bf77ba17cf75489f10d60e0593c740e669fb.zip
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.
-rw-r--r--src/decoder/oggvorbis_plugin.c36
1 files 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);