changeset 26026:71eee5468b9d

Fix some crashes from printing debug messages on a separate thread.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Mon, 12 Jan 2009 02:42:29 +0000
parents 4859b0b82289
children 5275c7ef9edf
files libpurple/media.c pidgin/gtkmedia.c
diffstat 2 files changed, 12 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Mon Jan 12 02:01:05 2009 +0000
+++ b/libpurple/media.c	Mon Jan 12 02:42:29 2009 +0000
@@ -1459,8 +1459,6 @@
 	const gchar *audio_device = purple_prefs_get_string("/purple/media/audio/device");
 	double input_volume = purple_prefs_get_int("/purple/media/audio/volume/input")/10.0;
 
-	purple_debug_info("media", "purple_media_audio_init_src\n");
-
 	*sendbin = gst_bin_new("purplesendaudiobin");
 	src = gst_element_factory_make("alsasrc", "asrc");
 	volume = gst_element_factory_make("volume", "purpleaudioinputvolume");
@@ -1489,8 +1487,6 @@
 	const gchar *video_device = purple_prefs_get_string(
 			"/purple/media/video/device");
 
-	purple_debug_info("media", "purple_media_video_init_src\n");
-
 	*sendbin = gst_bin_new("purplesendvideobin");
 	src = gst_element_factory_make(video_plugin, "purplevideosource");
 	gst_bin_add(GST_BIN(*sendbin), src);
@@ -1533,8 +1529,6 @@
 	double output_volume = purple_prefs_get_int(
 			"/purple/media/audio/volume/output")/10.0;
 
-	purple_debug_info("media", "purple_media_audio_init_recv\n");
-
 	*recvbin = gst_bin_new("pidginrecvaudiobin");
 	sink = gst_element_factory_make("alsasink", "asink");
 	g_object_set(G_OBJECT(sink), "sync", FALSE, NULL);
@@ -1548,8 +1542,6 @@
 	ghost = gst_ghost_pad_new("ghostsink", pad);
 	gst_element_add_pad(*recvbin, ghost);
 	g_object_set(G_OBJECT(*recvlevel), "message", TRUE, NULL);
-
-	purple_debug_info("media", "purple_media_audio_init_recv end\n");
 }
 
 void
@@ -1558,16 +1550,12 @@
 	GstElement *sink;
 	GstPad *pad, *ghost;
 
-	purple_debug_info("media", "purple_media_video_init_recv\n");
-
 	*recvbin = gst_bin_new("pidginrecvvideobin");
 	sink = gst_element_factory_make("autovideosink", "purplevideosink");
 	gst_bin_add(GST_BIN(*recvbin), sink);
 	pad = gst_element_get_pad(sink, "sink");
 	ghost = gst_ghost_pad_new("ghostsink", pad);
 	gst_element_add_pad(*recvbin, ghost);
-
-	purple_debug_info("media", "purple_media_video_init_recv end\n");
 }
 
 static void
@@ -1647,6 +1635,16 @@
 	purple_media_candidate_free(remote);
 }
 
+static gboolean
+purple_media_connected_cb(PurpleMediaStream *stream)
+{
+	g_signal_emit(stream->session->media,
+			purple_media_signals[STATE_CHANGED],
+			0, PURPLE_MEDIA_STATE_CHANGED_CONNECTED,
+			stream->session->id, stream->participant);
+	return FALSE;
+}
+
 static void
 purple_media_src_pad_added_cb(FsStream *fsstream, GstPad *srcpad,
 			      FsCodec *codec, PurpleMediaStream *stream)
@@ -1660,13 +1658,10 @@
 	gst_bin_add(GST_BIN(purple_media_get_pipeline(stream->session->media)),
 		    stream->sink);
 	sinkpad = gst_element_get_static_pad(stream->sink, "ghostsink");
-	purple_debug_info("media", "connecting new src pad: %s\n", 
-			  gst_pad_link(srcpad, sinkpad) == GST_PAD_LINK_OK ? "success" : "failure");
+	gst_pad_link(srcpad, sinkpad);
 	gst_element_set_state(stream->sink, GST_STATE_PLAYING);
 
-	g_signal_emit(stream->session->media, purple_media_signals[STATE_CHANGED],
-				0, PURPLE_MEDIA_STATE_CHANGED_CONNECTED,
-				stream->session->id, stream->participant);
+	g_timeout_add(0, (GSourceFunc)purple_media_connected_cb, stream);
 }
 
 static gchar *
--- a/pidgin/gtkmedia.c	Mon Jan 12 02:01:05 2009 +0000
+++ b/pidgin/gtkmedia.c	Mon Jan 12 02:42:29 2009 +0000
@@ -337,7 +337,6 @@
 		return TRUE;
 
 	name = gst_object_get_name(GST_MESSAGE_SRC (message));
-	purple_debug_info("gtkmedia", "prepare-xwindow-id object name: %s\n", name);
 
 	/* The XOverlay's name is the sink's name with a suffix */
 	if (!strncmp(name, "purplevideosink", strlen("purplevideosink")))