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.
This commit is contained in:
Max Kellermann 2009-01-14 23:21:45 +01:00
parent 69b033757f
commit f353bf77ba

View File

@ -160,25 +160,21 @@ vorbis_copy_comment(struct tag *tag, const char *comment,
return false; return false;
} }
static bool static void
vorbis_parse_comment(struct tag *tag, char *comment, enum tag_type tag_type) vorbis_parse_comment(struct tag *tag, const char *comment)
{ {
const char *needle;
assert(tag != NULL); assert(tag != NULL);
switch (tag_type) { if (vorbis_copy_comment(tag, comment, VORBIS_COMMENT_TRACK_KEY,
case TAG_ITEM_TRACK: TAG_ITEM_TRACK) ||
needle = VORBIS_COMMENT_TRACK_KEY; vorbis_copy_comment(tag, comment, VORBIS_COMMENT_DISC_KEY,
break; TAG_ITEM_DISC))
case TAG_ITEM_DISC: return;
needle = VORBIS_COMMENT_DISC_KEY;
break;
default:
needle = mpdTagItemKeys[tag_type];
}
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 * static struct tag *
@ -186,14 +182,8 @@ vorbis_comments_to_tag(char **comments)
{ {
struct tag *tag = tag_new(); struct tag *tag = tag_new();
while (*comments) { while (*comments)
int j; vorbis_parse_comment(tag, *comments++);
for (j = TAG_NUM_OF_ITEM_TYPES; --j >= 0;) {
if (vorbis_parse_comment(tag, *comments, j))
break;
}
comments++;
}
if (tag_is_empty(tag)) { if (tag_is_empty(tag)) {
tag_free(tag); tag_free(tag);