Fix for #159852 - make iterate emission threadsafe

Original commit message from CVS:
Fix for #159852 - make iterate emission threadsafe
This commit is contained in:
Thomas Vander Stichele 2004-12-21 11:16:32 +00:00
parent 691dc33054
commit d5e4273820
2 changed files with 21 additions and 2 deletions

View file

@ -1,3 +1,10 @@
2004-12-21 Thomas Vander Stichele <thomas at apestaart dot org>
patch by: Wim Taymans
* gst/gstbin.c:
Fix for #159852 - make iterate emission threadsafe
2004-12-21 Thomas Vander Stichele <thomas at apestaart dot org>
* docs/faq/cvs.xml:

View file

@ -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");