From b515b8a729d95087e98ab009f4853187f4a57ae7 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Tue, 20 Jul 2004 09:55:13 +0000 Subject: [PATCH] fix for #147894 (opt scheduler decoupled elements mismanagement) Original commit message from CVS: fix for #147894 (opt scheduler decoupled elements mismanagement) --- ChangeLog | 11 ++++ gst/schedulers/gstoptimalscheduler.c | 61 +++++++++++++++++----- tests/old/testsuite/schedulers/Makefile.am | 4 +- testsuite/schedulers/Makefile.am | 4 +- 4 files changed, 63 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 76a232007f..439096e31b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-07-20 Thomas Vander Stichele + + patch by: Wim Taymans + + * gst/schedulers/gstoptimalscheduler.c: (group_num_elements), + (group_has_element), (element_get_reachables_func), + (group_migrate_connected): + fix for #147894 (opt scheduler decoupled elements mismanagement) + * testsuite/schedulers/Makefile.am: + testsuite app now passes + 2004-07-19 Wim Taymans * testsuite/schedulers/147819.c: (handoff_identity1), diff --git a/gst/schedulers/gstoptimalscheduler.c b/gst/schedulers/gstoptimalscheduler.c index d3860b3a2a..ac2a0e2d5f 100644 --- a/gst/schedulers/gstoptimalscheduler.c +++ b/gst/schedulers/gstoptimalscheduler.c @@ -942,6 +942,37 @@ remove_from_group (GstOptSchedulerGroup * group, GstElement * element) return group; } +/* count number of elements in the group. Have to be careful because + * decoupled elements are added as entry point but are not added to + * the elements list */ +static gint +group_num_elements (GstOptSchedulerGroup * group) +{ + gint num; + + num = group->num_elements; + /* decoupled elements are not added to the group but are + * added as an entry */ + if (group->entry) { + if (GST_ELEMENT_IS_DECOUPLED (group->entry)) { + num++; + } + } + return num; +} + +/* check if an element is part of the given group. We have to be carefull + * as decoupled elements are added as entry but are not added to the elements + * list */ +static gboolean +group_has_element (GstOptSchedulerGroup * group, GstElement * element) +{ + if (group->entry == element) + return TRUE; + + return (g_slist_find (group->elements, element) != NULL); +} + /* FIXME need to check if the groups are of the same type -- otherwise need to setup the scheduler again, if it is setup */ static GstOptSchedulerGroup * @@ -2121,7 +2152,7 @@ element_get_reachables_func (GstElement * element, GstOptSchedulerGroup * group, const GList *pads; /* if no element or element not in group or been there, return NULL */ - if (element == NULL || g_slist_find (group->elements, element) == NULL || + if (element == NULL || !group_has_element (group, element) || GST_ELEMENT_IS_VISITED (element)) return NULL; @@ -2337,6 +2368,7 @@ group_migrate_connected (GstOptScheduler * osched, GstElement * element, gint len; if (GST_ELEMENT_IS_DECOUPLED (element)) { + GST_LOG ("element is decoupled and thus not in the group"); /* the element is decoupled and is therefore not in the group */ return NULL; } @@ -2359,7 +2391,7 @@ group_migrate_connected (GstOptScheduler * osched, GstElement * element, gst_element_get_name (element)); return NULL; } else if (len == 1) { - remove_from_group (group, GST_ELEMENT (connected->data)); + group = remove_from_group (group, GST_ELEMENT (connected->data)); GST_LOG ("not migrating to new group as the group would only contain 1 element"); g_list_free (connected); @@ -2385,7 +2417,7 @@ group_migrate_connected (GstOptScheduler * osched, GstElement * element, /* remove last element from the group if any. Make sure not to remove * the loop based entry point of a group as this always needs one group */ if (group != NULL) { - if (g_slist_length (group->elements) == 1 && + if (group_num_elements (group) == 1 && group->type != GST_OPT_SCHEDULER_GROUP_LOOP) { GST_LOG ("removing last element from old group"); group = remove_from_group (group, GST_ELEMENT (group->elements->data)); @@ -2393,18 +2425,21 @@ group_migrate_connected (GstOptScheduler * osched, GstElement * element, } } - if (g_slist_length (new_group->elements) == 1 && - new_group->type != GST_OPT_SCHEDULER_GROUP_LOOP) { - GST_LOG ("removing last element from new group"); - new_group = - remove_from_group (new_group, GST_ELEMENT (new_group->elements->data)); - return NULL; + if (new_group != NULL) { + if (group_num_elements (new_group) == 1 && + new_group->type != GST_OPT_SCHEDULER_GROUP_LOOP) { + GST_LOG ("removing last element from new group"); + new_group = + remove_from_group (new_group, + GST_ELEMENT (new_group->elements->data)); + return NULL; + } + /* at this point the new group lives in its own chain but might + * have to be merged with another chain, this happens when the new + * group has a link with another group in another chain */ + rechain_group (new_group); } - /* at this point the new group lives in its own chain but might - * have to be merged with another chain, this happens when the new - * group has a link with another group in another chain */ - rechain_group (new_group); return new_group; } diff --git a/tests/old/testsuite/schedulers/Makefile.am b/tests/old/testsuite/schedulers/Makefile.am index 0bb006ddf0..5ca979cde0 100644 --- a/tests/old/testsuite/schedulers/Makefile.am +++ b/tests/old/testsuite/schedulers/Makefile.am @@ -4,12 +4,12 @@ tests_pass = \ unlink_src unlink_sink \ relink_src relink_sink \ unref_src unref_sink \ - 143777 143777-2 147713 + 143777 143777-2 147713 147894 # don't enable this one unless it actually works. # useless_iteration -tests_fail = 142183 142183-2 147894 147819 +tests_fail = 142183 142183-2 147819 tests_ignore = unlink_src_SOURCES = unlink.c diff --git a/testsuite/schedulers/Makefile.am b/testsuite/schedulers/Makefile.am index 0bb006ddf0..5ca979cde0 100644 --- a/testsuite/schedulers/Makefile.am +++ b/testsuite/schedulers/Makefile.am @@ -4,12 +4,12 @@ tests_pass = \ unlink_src unlink_sink \ relink_src relink_sink \ unref_src unref_sink \ - 143777 143777-2 147713 + 143777 143777-2 147713 147894 # don't enable this one unless it actually works. # useless_iteration -tests_fail = 142183 142183-2 147894 147819 +tests_fail = 142183 142183-2 147819 tests_ignore = unlink_src_SOURCES = unlink.c