From 01706dd46c977acd0bce1fa7e8cc665c621b158c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 4 Nov 2008 17:04:54 +0100 Subject: mp4: use tag_is_empty() instead of passing the tag_is_found flag The API of mp4_load_tag() was strange: it always returned a tag object, no matter if a tag was found in the file; the existence of a tag was indicated with the tag_found integer reference. This flag is superfluous, since we can simply check whether the tag is empty or not. --- src/decoder/mp4_plugin.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/decoder/mp4_plugin.c b/src/decoder/mp4_plugin.c index 934ffc59b..7f17055a1 100644 --- a/src/decoder/mp4_plugin.c +++ b/src/decoder/mp4_plugin.c @@ -302,7 +302,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) } static struct tag * -mp4_load_tag(const char *file, int *tag_found) +mp4_load_tag(const char *file) { struct tag *ret = NULL; struct input_stream input_stream; @@ -317,8 +317,6 @@ mp4_load_tag(const char *file, int *tag_found) int32_t scale; int i; - *tag_found = 0; - if (!input_stream_open(&input_stream, file)) { DEBUG("mp4_load_tag: Failed to open file: %s\n", file); return NULL; @@ -356,25 +354,18 @@ mp4_load_tag(const char *file, int *tag_found) if (0 == strcasecmp("artist", item)) { tag_add_item(ret, TAG_ITEM_ARTIST, value); - *tag_found = 1; } else if (0 == strcasecmp("title", item)) { tag_add_item(ret, TAG_ITEM_TITLE, value); - *tag_found = 1; } else if (0 == strcasecmp("album", item)) { tag_add_item(ret, TAG_ITEM_ALBUM, value); - *tag_found = 1; } else if (0 == strcasecmp("track", item)) { tag_add_item(ret, TAG_ITEM_TRACK, value); - *tag_found = 1; } else if (0 == strcasecmp("disc", item)) { /* Is that the correct id? */ tag_add_item(ret, TAG_ITEM_DISC, value); - *tag_found = 1; } else if (0 == strcasecmp("genre", item)) { tag_add_item(ret, TAG_ITEM_GENRE, value); - *tag_found = 1; } else if (0 == strcasecmp("date", item)) { tag_add_item(ret, TAG_ITEM_DATE, value); - *tag_found = 1; } free(item); @@ -391,12 +382,11 @@ static struct tag * mp4_tag_dup(const char *file) { struct tag *ret = NULL; - int tag_found = 0; - ret = mp4_load_tag(file, &tag_found); + ret = mp4_load_tag(file); if (!ret) return NULL; - if (!tag_found) { + if (tag_is_empty(ret)) { struct tag *temp = tag_id3_load(file); if (temp) { temp->time = ret->time; -- cgit v1.2.3