revert the revert, switch out the new code for the 'working' code with an #if

Original commit message from CVS:
revert the revert, switch out the new code for the 'working' code with an #if
This commit is contained in:
Erik Walthinsen 2003-01-21 20:48:23 +00:00
parent f7334fc9d2
commit bab7be2c91

View file

@ -936,13 +936,24 @@ gst_basic_scheduler_find_chain (GstBasicScheduler * sched, GstElement * element)
}
static void
gst_basic_scheduler_chain_recursive_add (GstSchedulerChain * chain, GstElement * element)
gst_basic_scheduler_chain_recursive_add (GstSchedulerChain * chain, GstElement * element, gboolean remove)
{
GList *pads;
GstPad *pad;
GstElement *peerelement;
GstSchedulerChain *prevchain;
/* add the element to the chain */
/* check to see if it's in a chain already */
prevchain = gst_basic_scheduler_find_chain (chain->sched, element);
/* if it's already in another chain, either remove or punt */
if (prevchain != NULL) {
if (remove == TRUE)
gst_basic_scheduler_chain_remove_element (prevchain, element);
else
return;
}
/* add it to this one */
gst_basic_scheduler_chain_add_element (chain, element);
GST_DEBUG (GST_CAT_SCHEDULING, "recursing on element \"%s\"", GST_ELEMENT_NAME (element));
@ -959,12 +970,9 @@ gst_basic_scheduler_chain_recursive_add (GstSchedulerChain * chain, GstElement *
GST_DEBUG (GST_CAT_SCHEDULING, "has peer %s:%s", GST_DEBUG_PAD_NAME (GST_PAD_PEER (pad)));
peerelement = GST_PAD_PARENT (GST_PAD_PEER (pad));
if (GST_ELEMENT_SCHED (GST_PAD_PARENT (pad)) == GST_ELEMENT_SCHED (peerelement)) {
GST_DEBUG (GST_CAT_SCHEDULING, "peer \"%s\" is valid for same chain",
GST_DEBUG (GST_CAT_SCHEDULING, "peer \"%s\" is valid for same chain",
GST_ELEMENT_NAME (peerelement));
/* if it's not already in a chain, add it to this one */
if (gst_basic_scheduler_find_chain (chain->sched, peerelement) == NULL) {
gst_basic_scheduler_chain_recursive_add (chain, peerelement);
}
gst_basic_scheduler_chain_recursive_add (chain, peerelement, remove);
}
}
}
@ -1209,6 +1217,12 @@ gst_basic_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad, GstPad *
chain1 = gst_basic_scheduler_find_chain (bsched, element1);
chain2 = gst_basic_scheduler_find_chain (bsched, element2);
/* FIXME: The old code still works in most cases, but does not deal with
* the problem of screwed up sched chains in some autoplugging cases.
* The new code has an infinite recursion bug during pipeline shutdown,
* which must be fixed before it can be enabled again.
*/
#if 1
if (chain1 != chain2) {
/* elements not in the same chain don't need to be separated */
GST_INFO (GST_CAT_SCHEDULING, "elements not in the same chain");
@ -1221,15 +1235,25 @@ gst_basic_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad, GstPad *
/* now create a new chain to hold element1 and build it from scratch */
chain1 = gst_basic_scheduler_chain_new (bsched);
gst_basic_scheduler_chain_recursive_add (chain1, element1);
gst_basic_scheduler_chain_recursive_add (chain1, element1, FALSE);
}
/* check the other element to see if it landed in the newly created chain */
if (gst_basic_scheduler_find_chain (bsched, element2) == NULL) {
/* if not in chain, create chain and build from scratch */
chain2 = gst_basic_scheduler_chain_new (bsched);
gst_basic_scheduler_chain_recursive_add (chain2, element2);
gst_basic_scheduler_chain_recursive_add (chain2, element2, FALSE);
}
#else
/* if they're both in the same chain, move second set of elements to a new chain */
if (chain1 && (chain1 == chain2)) {
GST_INFO (GST_CAT_SCHEDULING, "creating new chain for second element and peers");
chain2 = gst_basic_scheduler_chain_new (bsched);
gst_basic_scheduler_chain_recursive_add (chain2, element2, TRUE);
}
#endif
}
static GstPad *