/pidgin/main: f80210352fb3: media: ensure nonunique source is re...

Jakub Adam <[email protected]>
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: f80210352fb34fa1d42502e7399f3dceacfcf285
Author:	 Jakub Adam <[email protected]>
Date:	 2014-10-02 23:46 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/f80210352fb3

Description:

media: ensure nonunique source is removed from pipeline when unlinked

diffstat:

 libpurple/mediamanager.c |  14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diffs (31 lines):

diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c
--- a/libpurple/mediamanager.c
+++ b/libpurple/mediamanager.c
@@ -422,6 +422,16 @@ request_pad_unlinked_cb(GstPad *pad, Gst
 
 	gst_iterator_free(iter);
 }
+
+static void
+nonunique_src_unlinked_cb(GstPad *pad, GstPad *peer, gpointer user_data)
+{
+	GstElement *element = GST_ELEMENT_PARENT(pad);
+	gst_element_set_locked_state(element, TRUE);
+	gst_element_set_state(element, GST_STATE_NULL);
+	gst_bin_remove(GST_BIN(GST_ELEMENT_PARENT(element)), element);
+}
+
 #endif
 
 #ifdef USE_GSTREAMER
@@ -561,6 +571,10 @@ purple_media_manager_get_element(PurpleM
 		ret = purple_media_element_info_call_create(info,
 				media, session_id, participant);
 		if (element_type & PURPLE_MEDIA_ELEMENT_SRC) {
+			GstPad *pad = gst_element_get_static_pad(ret, "src");
+			g_signal_connect(pad, "unlinked",
+					G_CALLBACK(nonunique_src_unlinked_cb), NULL);
+			gst_object_unref(pad);
 			gst_object_ref(ret);
 			gst_bin_add(GST_BIN(purple_media_manager_get_pipeline(manager)),
 				ret);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.