From 62d8456eb715a3cb849ca0f14d2182fe5229ddf4 Mon Sep 17 00:00:00 2001 From: Tim-Philipp Müller Date: Wed, 14 Nov 2007 21:39:47 +0000 Subject: gst/id3demux/: We don't want the same string multiple times in a tag list for the same tag ever, for any tag, not jus... Original commit message from CVS: * gst/id3demux/id3tags.c: * gst/id3demux/id3tags.h: * gst/id3demux/id3v2frames.c: (id3v2_tag_to_taglist): We don't want the same string multiple times in a tag list for the same tag ever, for any tag, not just for GST_TAG_GENRE, so make sure this doesn't happen and remove special-case code for GST_TAG_GENRE. --- gst/id3demux/id3v2frames.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'gst/id3demux/id3v2frames.c') diff --git a/gst/id3demux/id3v2frames.c b/gst/id3demux/id3v2frames.c index efbef079..c8acb886 100644 --- a/gst/id3demux/id3v2frames.c +++ b/gst/id3demux/id3v2frames.c @@ -794,14 +794,23 @@ id3v2_tag_to_taglist (ID3TagsWorking * work, const gchar * tag_name, break; } case G_TYPE_STRING:{ - if (!strcmp (tag_name, GST_TAG_GENRE)) { - if (work->prev_genre && !strcmp (tag_str, work->prev_genre)) - break; /* Same as the last genre */ - g_free (work->prev_genre); - work->prev_genre = g_strdup (tag_str); + const GValue *val; + guint i, num; + + /* make sure we add each unique string only once per tag, we don't want + * to have the same genre in the genre list multiple times, for example, + * or the same DiscID in there twice just because it's contained in the + * tag multiple times under different TXXX user tags */ + num = gst_tag_list_get_tag_size (tag_list, tag_name); + for (i = 0; i < num; ++i) { + val = gst_tag_list_get_value_index (tag_list, tag_name, i); + if (val != NULL && strcmp (g_value_get_string (val), tag_str) == 0) + break; + } + if (i == num) { + gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, + tag_name, tag_str, NULL); } - gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, - tag_name, tag_str, NULL); break; } -- cgit