totem r5011 - in trunk: . src/backend



Author: tpm
Date: Wed Jan  9 12:23:49 2008
New Revision: 5011
URL: http://svn.gnome.org/viewvc/totem?rev=5011&view=rev

Log:
	* src/backend/bacon-video-widget-gst-0.10.c: (gui_thread),
	  (bacon_video_widget_finalize),
	  (bvw_update_brightness_and_contrast_from_gconf),
	  (bvw_update_colorbalance_from_gconf_delayed),
	  (bvw_update_interface_implementations), (bacon_video_widget_new):
	  Make sure we don't do GConf stuff from the streaming thread, since
	  gconf might apparently iterate the default main context, leading to
	  all kinds of nasty issues, such as random crashes with NULL pollrecs
	  in g_main_context_check. (Hopefully closes: #471159)



Modified:
   trunk/ChangeLog
   trunk/src/backend/bacon-video-widget-gst-0.10.c

Modified: trunk/src/backend/bacon-video-widget-gst-0.10.c
==============================================================================
--- trunk/src/backend/bacon-video-widget-gst-0.10.c	(original)
+++ trunk/src/backend/bacon-video-widget-gst-0.10.c	Wed Jan  9 12:23:49 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 2003-2007 the GStreamer project
  *      Julien Moutte <julien moutte net>
  *      Ronald Bultje <rbultje ronald bitfreak net>
- *      Tim-Philipp MÃller <tim centricular net>
+ * Copyright (C) 2005-2008 Tim-Philipp MÃller <tim centricular net>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -123,8 +123,9 @@
   BaconVideoWidgetAspectRatio  ratio_type;
 
   GstElement                  *play;
-  GstXOverlay                 *xoverlay; /* protect with lock */
-  GstColorBalance             *balance;  /* protect with lock */
+  GstXOverlay                 *xoverlay;      /* protect with lock */
+  GstColorBalance             *balance;       /* protect with lock */
+  guint                        col_update_id; /* protect with lock */
   GMutex                      *lock;
 
   guint                        update_id;
@@ -231,6 +232,8 @@
 
 static int bvw_signals[LAST_SIGNAL] = { 0 };
 
+static GThread *gui_thread;
+
 GST_DEBUG_CATEGORY (_totem_gst_debug_cat);
 #define GST_CAT_DEFAULT _totem_gst_debug_cat
 
@@ -1869,6 +1872,11 @@
     bvw->priv->update_id = 0;
   }
 
+  if (bvw->priv->col_update_id) {
+    g_source_remove (bvw->priv->col_update_id);
+    bvw->priv->col_update_id = 0;
+  }
+
   if (bvw->priv->tagcache) {
     gst_tag_list_free (bvw->priv->tagcache);
     bvw->priv->tagcache = NULL;
@@ -4584,16 +4592,46 @@
 }
 
 static void
+bvw_update_brightness_and_contrast_from_gconf (BaconVideoWidget * bvw)
+{
+  GConfValue *confvalue;
+  guint i;
+
+  g_return_if_fail (g_thread_self() == gui_thread);
+
+  /* Setup brightness and contrast */
+  GST_LOG ("updating brightness and contrast from GConf settings");
+  for (i = 0; i < G_N_ELEMENTS (video_props_str); i++) {
+    confvalue = gconf_client_get_without_default (bvw->priv->gc,
+        video_props_str[i], NULL);
+    if (confvalue != NULL) {
+      bacon_video_widget_set_video_property (bvw, i,
+        gconf_value_get_int (confvalue));
+      gconf_value_free (confvalue);
+    }
+  }
+}
+
+static gboolean
+bvw_update_colorbalance_from_gconf_delayed (BaconVideoWidget * bvw)
+{
+  GST_LOG ("delayed updating of colorbalance");
+  g_mutex_lock (bvw->priv->lock);
+  bvw_update_interface_implementations (bvw);
+  bvw->priv->col_update_id = 0;
+  g_mutex_unlock (bvw->priv->lock);
+  return FALSE;
+}
+
+static void
 bvw_update_interface_implementations (BaconVideoWidget *bvw)
 {
   GstColorBalance *old_balance = bvw->priv->balance;
   GstXOverlay *old_xoverlay = bvw->priv->xoverlay;
-  GConfValue *confvalue;
   GstElement *video_sink = NULL;
   GstElement *element = NULL;
   GstIteratorResult ires;
   GstIterator *iter;
-  guint i;
 
   g_object_get (bvw->priv->play, "video-sink", &video_sink, NULL);
   g_assert (video_sink != NULL);
@@ -4643,15 +4681,18 @@
     bvw->priv->balance = NULL;
   }
 
-  /* Setup brightness and contrast */
-  for (i = 0; i < G_N_ELEMENTS (video_props_str); i++) {
-    confvalue = gconf_client_get_without_default (bvw->priv->gc,
-        video_props_str[i], NULL);
-    if (confvalue != NULL) {
-      bacon_video_widget_set_video_property (bvw, i,
-        gconf_value_get_int (confvalue));
-      gconf_value_free (confvalue);
-    }
+  /* Setup brightness and contrast from configured values (do it delayed if
+   * we're within a streaming thread, otherwise gconf/orbit/whatever may
+   * iterate or otherwise mess with the default main context and cause all
+   * kinds of nasty issues) */
+  if (g_thread_self() == gui_thread) {
+    bvw_update_brightness_and_contrast_from_gconf (bvw);
+  } else {
+    /* caller will have acquired bvw->priv->lock already */
+    if (bvw->priv->col_update_id)
+       g_source_remove (bvw->priv->col_update_id);
+    bvw->priv->col_update_id =
+        g_idle_add ((GSourceFunc) bvw_update_colorbalance_from_gconf_delayed, bvw);
   }
 
   if (old_xoverlay)
@@ -5077,6 +5118,9 @@
     gconf_value_free (confvalue);
   }
 
+  /* assume we're always called from the main Gtk+ GUI thread */
+  gui_thread = g_thread_self();
+
   return GTK_WIDGET (bvw);
 
   /* errors */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]