changeset 24977:99c3489e06b0

Wait for local video frame to be realized before starting local video. This fixes half of the BadWindow errors that have plagued vv.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sun, 14 Dec 2008 23:43:52 +0000
parents 01df0829f054
children 68f4edb42f39
files libpurple/media.c pidgin/gtkmedia.c
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Sat Dec 13 09:11:08 2008 +0000
+++ b/libpurple/media.c	Sun Dec 14 23:43:52 2008 +0000
@@ -738,6 +738,7 @@
 		gst_bus_add_signal_watch(GST_BUS(bus));
 		g_signal_connect(G_OBJECT(bus), "message",
 				G_CALLBACK(media_bus_call), media);
+		gst_bus_set_sync_handler(bus, gst_bus_sync_signal_handler, NULL);
 		gst_object_unref(bus);
 
 		gst_bin_add(GST_BIN(media->priv->pipeline), GST_ELEMENT(media->priv->conference));
--- a/pidgin/gtkmedia.c	Sat Dec 13 09:11:08 2008 +0000
+++ b/pidgin/gtkmedia.c	Sun Dec 14 23:43:52 2008 +0000
@@ -300,6 +300,12 @@
 }
 
 static void
+realize_cb(GtkWidget *widget, GstElement *element)
+{
+	gst_element_set_state(element, GST_STATE_PLAYING);
+}
+
+static void
 pidgin_media_ready_cb(PurpleMedia *media, PidginMedia *gtkmedia)
 {
 	GstElement *pipeline = purple_media_get_pipeline(media);
@@ -327,7 +333,6 @@
 			if (!videosendbin && (type & PURPLE_MEDIA_SEND_VIDEO)) {
 				purple_media_video_init_src(&videosendbin);
 				purple_media_set_src(media, sessions->data, videosendbin);
-				gst_element_set_state(videosendbin, GST_STATE_PLAYING);
 			}
 			if (!videorecvbool && (type & PURPLE_MEDIA_RECV_VIDEO)) {
 				videorecvbool = TRUE;
@@ -373,8 +378,12 @@
 		gtk_box_pack_start(GTK_BOX(send_widget), aspect, TRUE, TRUE, 0);
 
 		local_video = gtk_drawing_area_new();
+		g_signal_connect(G_OBJECT(local_video), "realize",
+				G_CALLBACK(realize_cb), videosendbin);
+
 		gtk_container_add(GTK_CONTAINER(aspect), local_video);
 		gtk_widget_set_size_request (GTK_WIDGET(local_video), 100, -1);
+
 		gtk_widget_show(local_video);
 		gtk_widget_show(aspect);
 
@@ -405,8 +414,8 @@
 	bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
 
 	if (videorecvbool || videosendbin)
-		gst_bus_set_sync_handler(bus,
-				(GstBusSyncHandler)create_window, gtkmedia);
+		g_signal_connect(bus, "sync-message::element",
+				G_CALLBACK(create_window), gtkmedia);
 
 	if (audiorecvbool || audiosendbin)
 		g_signal_connect(G_OBJECT(bus), "message::element",