From: Thomas Vander Stichele Date: Tue, 21 Dec 2004 11:16:32 +0000 (+0000) Subject: Fix for #159852 - make iterate emission threadsafe X-Git-Tag: RELEASE-0_8_8~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d5e4273820c63ef1b671f0010aed380cd005857f;p=platform%2Fupstream%2Fgstreamer.git Fix for #159852 - make iterate emission threadsafe Original commit message from CVS: Fix for #159852 - make iterate emission threadsafe --- diff --git a/ChangeLog b/ChangeLog index 68cfe7d..f5eac94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2004-12-21 Thomas Vander Stichele + patch by: Wim Taymans + + * gst/gstbin.c: + Fix for #159852 - make iterate emission threadsafe + +2004-12-21 Thomas Vander Stichele + * docs/faq/cvs.xml: notes about new fdo account request diff --git a/gst/gstbin.c b/gst/gstbin.c index 75f49e8..6975432 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -1204,11 +1204,15 @@ gst_bin_restore_thyself (GstObject * object, xmlNodePtr self) } #endif /* GST_DISABLE_LOADSAVE */ +static GStaticRecMutex iterate_lock = G_STATIC_REC_MUTEX_INIT; + static gboolean gst_bin_iterate_func (GstBin * bin) { GstScheduler *sched = GST_ELEMENT_SCHED (bin); + g_static_rec_mutex_unlock (&iterate_lock); + /* only iterate if this is the manager bin */ if (sched && sched->parent == GST_ELEMENT (bin)) { GstSchedulerState state; @@ -1216,7 +1220,7 @@ gst_bin_iterate_func (GstBin * bin) state = gst_scheduler_iterate (sched); if (state == GST_SCHEDULER_STATE_RUNNING) { - return TRUE; + goto done; } else if (state == GST_SCHEDULER_STATE_ERROR) { gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); } else if (state == GST_SCHEDULER_STATE_STOPPED) { @@ -1233,7 +1237,7 @@ gst_bin_iterate_func (GstBin * bin) "current bin is not iterating, but children are, " "so returning TRUE anyway..."); g_usleep (1); - return TRUE; + goto done; } } } @@ -1242,7 +1246,13 @@ gst_bin_iterate_func (GstBin * bin) GST_ELEMENT_NAME (bin)); } + g_static_rec_mutex_lock (&iterate_lock); + return FALSE; + +done: + g_static_rec_mutex_lock (&iterate_lock); + return TRUE; } /** @@ -1265,8 +1275,10 @@ gst_bin_iterate (GstBin * bin) GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, bin, "starting iteration"); gst_object_ref (GST_OBJECT (bin)); + g_static_rec_mutex_lock (&iterate_lock); running = FALSE; g_signal_emit (G_OBJECT (bin), gst_bin_signals[ITERATE], 0, &running); + g_static_rec_mutex_unlock (&iterate_lock); gst_object_unref (GST_OBJECT (bin)); GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, bin, "finished iteration");