/pidgin/main: 13807c514810: media: don't keep last sample refere...

Jakub Adam <[email protected]>
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: 13807c51481035797ef5ed08f5236389b03ef155
Author:	 Jakub Adam <[email protected]>
Date:	 2016-04-14 21:01 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/13807c514810

Description:

media: don't keep last sample reference on sinks

Holding a reference to a GstBuffer somewhere in a pipeline for possibly
indefinite period may cause trouble when the buffer has been allocated
by a 3rd party library or when it points directly into memory region of
a hardware device.

A specific example is V4L2 source element, which won't allow webcam
image resolution be reconfigured unless all previously allocated buffers
have been freed.

diffstat:

 libpurple/mediamanager.c |   5 ++++-
 pidgin/gtkmedia.c        |  24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletions(-)

diffs (56 lines):

diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c
--- a/libpurple/mediamanager.c
+++ b/libpurple/mediamanager.c
@@ -1127,7 +1127,10 @@ purple_media_manager_get_element(PurpleM
 			 * giving a not-linked error upon destruction
 			 */
 			fakesink = gst_element_factory_make("fakesink", NULL);
-			g_object_set(fakesink, "sync", FALSE, NULL);
+			g_object_set(fakesink,
+				"sync", FALSE,
+				"enable-last-sample", FALSE,
+				NULL);
 			gst_bin_add(GST_BIN(bin), fakesink);
 			gst_element_link(tee, fakesink);
 
diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c
--- a/pidgin/gtkmedia.c
+++ b/pidgin/gtkmedia.c
@@ -1183,6 +1183,23 @@ pidgin_media_new_cb(PurpleMediaManager *
 	return TRUE;
 }
 
+static void
+videosink_disable_last_sample(GstElement *sink)
+{
+	GObjectClass *klass = G_OBJECT_GET_CLASS(sink);
+
+	if (g_object_class_find_property(klass, "enable-last-sample")) {
+		g_object_set(sink, "enable-last-sample", FALSE, NULL);
+	}
+}
+
+static void
+autovideosink_child_added_cb (GstChildProxy *child_proxy, GObject *object,
+		gchar *name, gpointer user_data)
+{
+	videosink_disable_last_sample(GST_ELEMENT(object));
+}
+
 static GstElement *
 create_vv_element(const gchar *plugin, const gchar *device)
 {
@@ -1245,6 +1262,13 @@ create_vv_element(const gchar *plugin, c
 				"set device\n");
 	}
 
+	if (g_strcmp0(plugin, "autovideosink") == 0) {
+		g_signal_connect(source, "child-added",
+			G_CALLBACK(autovideosink_child_added_cb), NULL);
+	} else {
+		videosink_disable_last_sample(source);
+	}
+
 	if (g_strcmp0(plugin, "videotestsrc") == 0)
 		g_object_set(G_OBJECT(element), "is-live", TRUE, NULL);
 

_______________________________________________
Commits mailing list
[email protected]
https://pidgin.im/cgi-bin/mailman/listinfo/commits
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.