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

Jakub Adam jakub.adam at ktknet.cz
Wed Apr 27 10:24:18 EDT 2016


Changeset: f827e56eea34a7d37922fcefb1eaa34a3410fac7
Author:	 Jakub Adam <jakub.adam at ktknet.cz>
Date:	 2016-04-27 09:19 +0200
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/f827e56eea34

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.

Backport of Pidgin 3 commit 13807c514810.

diffstat:

 libpurple/mediamanager.c  |   5 ++++-
 pidgin/gtkmedia.c         |  23 +++++++++++++++++++++++
 pidgin/plugins/vvconfig.c |  28 ++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 1 deletions(-)

diffs (100 lines):

diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c
--- a/libpurple/mediamanager.c
+++ b/libpurple/mediamanager.c
@@ -1171,7 +1171,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
@@ -1208,6 +1208,26 @@ 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,
+#if GST_CHECK_VERSION(1,0,0)
+		gchar *name,
+#endif
+		gpointer user_data)
+{
+	videosink_disable_last_sample(GST_ELEMENT(object));
+}
+
 static GstElement *
 create_default_video_src(PurpleMedia *media,
 		const gchar *session_id, const gchar *participant)
@@ -1260,6 +1280,9 @@ create_default_video_sink(PurpleMedia *m
 	if (sink == NULL)
 		purple_debug_error("gtkmedia", "Unable to find a suitable "
 				"element for the default video sink.\n");
+	if (sink != NULL)
+		g_signal_connect(sink, "child-added",
+				G_CALLBACK(autovideosink_child_added_cb), NULL);
 	return sink;
 }
 
diff --git a/pidgin/plugins/vvconfig.c b/pidgin/plugins/vvconfig.c
--- a/pidgin/plugins/vvconfig.c
+++ b/pidgin/plugins/vvconfig.c
@@ -371,6 +371,26 @@ create_video_src(PurpleMedia *media,
 	return ret;
 }
 
+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,
+#if GST_CHECK_VERSION(1,0,0)
+		gchar *name,
+#endif
+		gpointer user_data)
+{
+	videosink_disable_last_sample(GST_ELEMENT(object));
+}
+
 static GstElement *
 create_video_sink(PurpleMedia *media,
 		const gchar *session_id, const gchar *participant)
@@ -388,6 +408,14 @@ create_video_sink(PurpleMedia *media,
 	ret = gst_element_factory_make(plugin, NULL);
 	if (device[0] != '\0')
 		g_object_set(G_OBJECT(ret), "device", device, NULL);
+
+	if (g_strcmp0(plugin, "autovideosink") == 0) {
+		g_signal_connect(ret, "child-added",
+			G_CALLBACK(autovideosink_child_added_cb), NULL);
+	} else {
+		videosink_disable_last_sample(ret);
+	}
+
 	return ret;
 }
 



More information about the Commits mailing list