wtay gstreamer: gstreamer/ gstreamer/gst/

[email protected] Mon, 5 Jan 2009 02:14:43 -0800 (PST)
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gstreamer
Changes by:     wtay
Date:           Mon Jan 05 2009  10:14:43 UTC

Log message:
* gst/gstbin.c: (gst_bin_set_index_func), (gst_bin_set_clock_func),
(gst_bin_change_state_func):
Use an iterator to set the clock and the index so that we can release
the object lock appropriately. Fixes #566393.

Modified files:
    .               : ChangeLog
    gst             : gstbin.c

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.4211&r2=1.4212
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstbin.c.diff?r1=1.390&r2=1.391

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v
retrieving revision 1.4211
retrieving revision 1.4212
diff -u -d -r1.4211 -r1.4212
--- ChangeLog	3 Jan 2009 18:39:36 -0000	1.4211
+++ ChangeLog	5 Jan 2009 10:14:27 -0000	1.4212
@@ -1,3 +1,10 @@
+2009-01-05  Wim Taymans  <[email protected]>
+
+	* gst/gstbin.c: (gst_bin_set_index_func), (gst_bin_set_clock_func),
+	(gst_bin_change_state_func):
+	Use an iterator to set the clock and the index so that we can release
+	the object lock appropriately. Fixes #566393.
 2009-01-03  Edward Hervey  <[email protected]>
 
 	* libs/gst/base/gstcollectpads.c: (gst_collect_pads_available):
Index: gstbin.c
RCS file: /cvs/gstreamer/gstreamer/gst/gstbin.c,v
retrieving revision 1.390
retrieving revision 1.391
diff -u -d -r1.390 -r1.391
--- gstbin.c	19 Nov 2008 12:06:41 -0000	1.390
+++ gstbin.c	5 Jan 2009 10:14:28 -0000	1.391
@@ -624,17 +624,40 @@
 gst_bin_set_index_func (GstElement * element, GstIndex * index)
 {
   GstBin *bin;
-  GList *children;
+  gboolean done;
+  GstIterator *it;
   bin = GST_BIN (element);
-  GST_OBJECT_LOCK (bin);
-  for (children = bin->children; children; children = g_list_next (children)) {
-    GstElement *child = GST_ELEMENT (children->data);
+  it = gst_bin_iterate_elements (bin);
-    gst_element_set_index (child, index);
+  done = FALSE;
+  while (!done) {
+    gpointer data;
+    switch (gst_iterator_next (it, &data)) {
+      case GST_ITERATOR_OK:
+      {
+        GstElement *child = GST_ELEMENT_CAST (data);
+        GST_DEBUG_OBJECT (bin, "setting index on %s", GST_ELEMENT_NAME (child));
+        gst_element_set_index (child, index);
+        gst_object_unref (child);
+        break;
+      }
+      case GST_ITERATOR_RESYNC:
+        GST_DEBUG_OBJECT (bin, "iterator doing resync");
+        gst_iterator_resync (it);
+      default:
+      case GST_ITERATOR_DONE:
+        GST_DEBUG_OBJECT (bin, "iterator done");
+        done = TRUE;
+    }
   }
-  GST_OBJECT_UNLOCK (bin);
+  gst_iterator_free (it);
 }
 /* set the clock on all elements in this bin
@@ -644,21 +667,42 @@
 static gboolean
 gst_bin_set_clock_func (GstElement * element, GstClock * clock)
   gboolean res = TRUE;
-  if (element->clock != clock) {
-    for (children = bin->children; children; children = g_list_next (children)) {
-      GstElement *child = GST_ELEMENT (children->data);
-      res &= gst_element_set_clock (child, clock);
+        res &= gst_element_set_clock (child, clock);
+        res = TRUE;
     }
   return res;

------------------------------------------------------------------------------