cpw.maiku.media_refactor: d22bab6d: Decouple the media_bus_call from the bac...

maiku at pidgin.im maiku at pidgin.im
Fri Oct 23 22:10:34 EDT 2009


-----------------------------------------------------------------
Revision: d22bab6d4644c8b9401b185131d65f40f93d210a
Ancestor: 2cc368b5cbb31c025b90fcb71a18944d9c01b55e
Author: maiku at pidgin.im
Date: 2009-10-23T18:20:54
Branch: im.pidgin.cpw.maiku.media_refactor
URL: http://d.pidgin.im/viewmtn/revision/info/d22bab6d4644c8b9401b185131d65f40f93d210a

Modified files:
        libpurple/media/media.c

ChangeLog: 

Decouple the media_bus_call from the backend. It will still be needed even
after integration with the backend is finished.

-------------- next part --------------
============================================================
--- libpurple/media/media.c	0619cc306d3204e691b631ca062faa4c3ade82ca
+++ libpurple/media/media.c	24c161b4e1ef93d1906540049069f77666a8b1d6
@@ -113,6 +113,7 @@ struct _PurpleMediaPrivate
 	PurpleMediaBackend *backend;
 	FsConference *conference;
 	gchar *conference_type;
+	gulong gst_bus_handler_id;
 	gboolean initiator;
 	gpointer prpl_data;
 
@@ -378,15 +379,16 @@ purple_media_dispose(GObject *media)
 			g_object_unref(participants->data);
 	}
 
-	if (priv->manager) {
+	if (priv->gst_bus_handler_id != 0) {
 		GstElement *pipeline = purple_media_manager_get_pipeline(
 				priv->manager);
 		GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
-		g_signal_handlers_disconnect_matched(G_OBJECT(bus),
-				G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
-				0, 0, 0, media_bus_call, media);
+		g_signal_handler_disconnect(bus, priv->gst_bus_handler_id);
 		gst_object_unref(bus);
+		priv->gst_bus_handler_id = 0;
+	}
 
+	if (priv->manager) {
 		g_object_unref(priv->manager);
 		priv->manager = NULL;
 	}
@@ -1607,6 +1609,16 @@ purple_media_add_stream(PurpleMedia *med
 
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
 
+	if (media->priv->gst_bus_handler_id == 0) {
+		GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(
+				purple_media_manager_get_pipeline(
+				purple_media_manager_get())));
+		media->priv->gst_bus_handler_id =
+				g_signal_connect(G_OBJECT(bus), "message",
+				G_CALLBACK(media_bus_call), media);
+		gst_object_unref(bus);
+	}
+
 	if (!purple_media_backend_add_stream(media->priv->backend,
 			sess_id, who, type, initiator, transmitter,
 			num_params, params)) {
@@ -1616,19 +1628,12 @@ purple_media_add_stream(PurpleMedia *med
 
 	/* XXX: Temporary call while integrating with backend */
 	if (media->priv->conference == NULL) {
-		GstBus *bus;
 		media->priv->conference =
 				purple_media_backend_fs2_get_conference(
 				PURPLE_MEDIA_BACKEND_FS2(
 				media->priv->backend));
 		media->priv->confbin = GST_ELEMENT_PARENT(
 				media->priv->conference);
-		bus = gst_pipeline_get_bus(GST_PIPELINE(
-				purple_media_manager_get_pipeline(
-				purple_media_manager_get())));
-		g_signal_connect(G_OBJECT(bus), "message",
-				G_CALLBACK(media_bus_call), media);
-		gst_object_unref(bus);
 	}
 
 	session = purple_media_get_session(media, sess_id);


More information about the Commits mailing list