GNOME Bugzilla – Bug 399825
Tags don't work properly for shout2send plugin
Last modified: 2007-01-26 12:22:42 UTC
When the shout2send plugin receives tags, it was previously appending the new tags to a taglist, as such the tags were not getting updated properly. Additionally, while parsing the tags, the artist and title were getting prepended and appended to a string which composed the "song name" for that stream. As a result, the artist / title were getting repeated over and over. Both of these issues have been fixed in the patches provided. PATCH: --- gstshout2.c 2006-05-10 04:29:53.000000000 -0600 +++ gstshout2.c.new 2007-01-23 08:58:49.000000000 -0700 @@ -256,14 +256,21 @@ gst_shout2send_init (GstShout2send * sho shout2send->audio_format = SHOUT_FORMAT_VORBIS; shout2send->connected = FALSE; shout2send->songmetadata = NULL; + shout2send->songartist = NULL; + shout2send->songtitle = NULL; + } static void set_shout_metadata (const GstTagList * list, const gchar * tag, gpointer user_data) { - char **shout_metadata = (char **) user_data; - gchar *value, *temp; + GstShout2send *shout2send = (GstShout2send *)user_data; + char **shout_metadata = &(shout2send->songmetadata); + char **song_artist = &(shout2send->songartist); + char **song_title = &(shout2send->songtitle); + + gchar *value; GST_DEBUG ("tag: %s being added", tag); if (strcmp (tag, GST_TAG_ARTIST) == 0) { @@ -272,15 +279,11 @@ set_shout_metadata (const GstTagList * l GST_DEBUG ("Error reading \"%s\" tag value", tag); return; } - /* shout_metadata should be NULL if title is after artist in list */ - if (*shout_metadata == NULL) { - *shout_metadata = g_strdup (value); - } else { - temp = g_strdup_printf ("%s - %s", value, *shout_metadata); - g_free (*shout_metadata); - *shout_metadata = temp; - } + if(*song_artist != NULL) + g_free(*song_artist); + + *song_artist = g_strdup(value); } } else if (strcmp (tag, GST_TAG_TITLE) == 0) { if (gst_tag_get_type (tag) == G_TYPE_STRING) { @@ -288,16 +291,32 @@ set_shout_metadata (const GstTagList * l GST_DEBUG ("Error reading \"%s\" tag value", tag); return; } - /* shout_metadata should be NULL if title is before artist in list */ - if (*shout_metadata == NULL) { - *shout_metadata = g_strdup (value); - } else { - temp = g_strdup_printf ("%s - %s", *shout_metadata, value); - g_free (*shout_metadata); - *shout_metadata = temp; - } + + if(*song_title != NULL) + g_free(*song_title); + + *song_title = g_strdup(value); } } + + if(*shout_metadata != NULL) + g_free(*shout_metadata); + + + if(*song_title && *song_artist) + { + *shout_metadata = g_strdup_printf("%s - %s", *song_artist, *song_title); + } else if(*song_title && *song_artist == NULL) + { + *shout_metadata = g_strdup_printf("Unknown - %s", *song_title); + } else if(*song_title == NULL && *song_artist) + { + *shout_metadata = g_strdup_printf("%s - Unknown", *song_artist); + } else + { + *shout_metadata = g_strdup_printf("Unknown - Unknown"); + } + GST_LOG ("shout metadata is now: %s", *shout_metadata); } @@ -355,8 +374,8 @@ gst_shout2send_event (GstBaseSink * sink list, gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send))); /* lets get the artist and song tags */ - gst_tag_list_foreach ((GstTagList *) shout2send->tags, - set_shout_metadata, &shout2send->songmetadata); + gst_tag_list_foreach ((GstTagList *) list, + set_shout_metadata, shout2send); if (shout2send->songmetadata && shout2send->connected) { shout_metadata_t *pmetadata; --- gstshout2.h 2006-04-18 11:17:55.000000000 -0600 +++ gstshout2.h.new 2007-01-23 08:56:28.000000000 -0700 @@ -54,7 +54,8 @@ struct _GstShout2send { gchar *url; gboolean connected; gchar *songmetadata; - + gchar *songartist; + gchar *songtitle; guint16 audio_format; GstTagList* tags;
Created attachment 80994 [details] [review] Fix for shout2send tags