From 04873712143fae6c97dacfd6822894b65a9952df Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 28 Feb 2001 21:40:03 +0000 Subject: [PATCH] Make sure a cothreaded element is selected as the first one to start the cothread_switch Original commit message from CVS: Make sure a cothreaded element is selected as the first one to start the cothread_switch --- gst/gstbin.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gst/gstbin.c b/gst/gstbin.c index ac35edc..452aa05 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -800,11 +800,27 @@ gst_bin_iterate_func (GstBin *bin) if (!chain->need_scheduling) continue; if (chain->need_cothreads) { + GList *entries; + // all we really have to do is switch to the first child // FIXME this should be lots more intelligent about where to start GST_DEBUG (0,"starting iteration via cothreads\n"); - entry = GST_ELEMENT (chain->elements->data); + entries = chain->elements; + entry = NULL; + + // find an element with a threadstate to start with + while (entries) { + entry = GST_ELEMENT (entries->data); + + if (entry->threadstate) + break; + entries = g_list_next (entries); + } + // if we couldn't find one, bail out + if (entries == NULL) + GST_ERROR(GST_ELEMENT(bin),"no cothreaded elements found!"); + GST_FLAG_SET (entry, GST_ELEMENT_COTHREAD_STOPPING); GST_DEBUG (0,"set COTHREAD_STOPPING flag on \"%s\"(@%p)\n", GST_ELEMENT_NAME (entry),entry); -- 2.7.4