[tracker/cuesheets: 9/18] tracker-extract-gstreamer: Simplify tagcache behaviour



commit 8f3473d6f9fc4b9826b6a160d1d85331b12f5a99
Author: Sam Thursfield <sam thursfield codethink co uk>
Date:   Tue Aug 23 16:00:02 2011 +0100

    tracker-extract-gstreamer: Simplify tagcache behaviour
    
    Avoid having a NULL tagcache, which allows us to use
    gst_tag_list_insert() to merge new tags.

 src/tracker-extract/tracker-extract-gstreamer.c |   37 ++++------------------
 1 files changed, 7 insertions(+), 30 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index 6bd5287..461ca0a 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -410,7 +410,7 @@ extract_metadata (MetadataExtractor      *extractor,
 	g_return_if_fail (extractor != NULL);
 	g_return_if_fail (metadata != NULL);
 
-	if (extractor->tagcache) {
+	if (!gst_tag_list_is_empty (extractor->tagcache)) {
 		gchar *artist_uri = NULL;
 		gchar *performer_uri = NULL;
 		gchar *composer_uri = NULL;
@@ -975,13 +975,9 @@ discoverer_init_and_run (MetadataExtractor *extractor,
 			/* Unknown type - do nothing */
 		}
 
-		/* Overwrite list of tags */
-		tmp = gst_tag_list_merge (extractor->tagcache,
-		                          gst_discoverer_stream_info_get_tags (stream),
-		                          GST_TAG_MERGE_APPEND);
-		if (extractor->tagcache)
-			gst_tag_list_free (extractor->tagcache);
-		extractor->tagcache = tmp;
+		gst_tag_list_insert (extractor->tagcache,
+		                     gst_discoverer_stream_info_get_tags (stream),
+		                     GST_TAG_MERGE_APPEND);
 	}
 
 	return TRUE;
@@ -996,23 +992,6 @@ discoverer_init_and_run (MetadataExtractor *extractor,
     defined(GSTREAMER_BACKEND_DECODEBIN2)
 
 static void
-add_tags (GstTagList        *new_tags,
-          MetadataExtractor *extractor)
-{
-	GstTagList *result;
-
-	result = gst_tag_list_merge (extractor->tagcache,
-	                             new_tags,
-	                             GST_TAG_MERGE_KEEP);
-
-	if (extractor->tagcache) {
-		gst_tag_list_free (extractor->tagcache);
-	}
-
-	extractor->tagcache = result;
-}
-
-static void
 pipeline_shutdown (MetadataExtractor *extractor)
 {
 	gst_element_set_state (extractor->pipeline, GST_STATE_NULL);
@@ -1110,7 +1089,7 @@ pipeline_poll_for_ready (MetadataExtractor *extractor,
 		}
 		case GST_MESSAGE_TAG: {
 			gst_message_parse_tag (message, &new_tags);
-			add_tags (new_tags, extractor);
+			gst_tag_list_insert (extractor->tagcache, new_tags, GST_TAG_MERGE_KEEP);
 			gst_tag_list_free (new_tags);
 			break;
 		}
@@ -1542,7 +1521,7 @@ tracker_extract_gstreamer (const gchar          *uri,
 
 	extractor = g_slice_new0 (MetadataExtractor);
 	extractor->mime = type;
-	extractor->tagcache = NULL;
+	extractor->tagcache = gst_tag_list_new ();
 	extractor->album_art_data = NULL;
 	extractor->album_art_size = 0;
 	extractor->album_art_mime = NULL;
@@ -1575,9 +1554,7 @@ tracker_extract_gstreamer (const gchar          *uri,
 	g_free (album);
 	g_free (artist);
 
-	if (extractor->tagcache) {
-		gst_tag_list_free (extractor->tagcache);
-	}
+	gst_tag_list_free (extractor->tagcache);
 
 #if defined(GSTREAMER_BACKEND_TAGREADBIN)
 	tagreadbin_shutdown (extractor);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]