[totem] thumbnailer: Unref GstBus after usage



commit 86ad8baface5efde31ffcf618bb03df0180d8b3b
Author: Javier JardÃn <jjardon gnome org>
Date:   Tue Sep 25 04:11:33 2012 +0900

    thumbnailer: Unref GstBus after usage
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684736

 src/totem-video-thumbnailer.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/src/totem-video-thumbnailer.c b/src/totem-video-thumbnailer.c
index 362defd..515068e 100644
--- a/src/totem-video-thumbnailer.c
+++ b/src/totem-video-thumbnailer.c
@@ -261,12 +261,14 @@ thumb_app_start (ThumbApp *app)
 {
 	GstBus *bus;
 	GstMessageType events;
+	gboolean terminate = FALSE;
+	gboolean async_received = FALSE;
 
 	gst_element_set_state (app->play, GST_STATE_PAUSED);
 	bus = gst_element_get_bus (app->play);
 	events = GST_MESSAGE_ASYNC_DONE | GST_MESSAGE_ERROR;
 
-	while (TRUE) {
+	while (terminate == FALSE) {
 		GstMessage *message;
 		GstElement *src;
 
@@ -279,13 +281,14 @@ thumb_app_start (ThumbApp *app)
 		switch (GST_MESSAGE_TYPE (message)) {
 		case GST_MESSAGE_ASYNC_DONE:
 			if (src == app->play) {
-				gst_message_unref (message);
-				goto success;
+				async_received = TRUE;
+				terminate = TRUE;
 			}
 			break;
 		case GST_MESSAGE_ERROR:
 			totem_gst_message_print (message, app->play, "totem-video-thumbnailer-error");
-			return FALSE;
+			terminate = TRUE;
+			break;
 
 		default:
 			/* Ignore */
@@ -295,12 +298,14 @@ thumb_app_start (ThumbApp *app)
 		gst_message_unref (message);
 	}
 
-	g_assert_not_reached ();
+	gst_object_unref (bus);
+
+	if (async_received) {
+		/* state change succeeded */
+		GST_DEBUG ("state change to %s succeeded", gst_element_state_get_name (GST_STATE_PAUSED));
+	}
 
-success:
-	/* state change succeeded */
-	GST_DEBUG ("state change to %s succeeded", gst_element_state_get_name (GST_STATE_PAUSED));
-	return TRUE;
+	return async_received;
 }
 
 static void



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