From 9955ea95b9c7d30a6ab08c52dd19220aca37338e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 7 Nov 2002 18:50:06 +0000 Subject: [PATCH] Remove groups from chains and elements from groups when they are destroyed. Original commit message from CVS: Remove groups from chains and elements from groups when they are destroyed. --- gst/schedulers/gstoptimalscheduler.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/gst/schedulers/gstoptimalscheduler.c b/gst/schedulers/gstoptimalscheduler.c index 9367757..67cd7d5 100644 --- a/gst/schedulers/gstoptimalscheduler.c +++ b/gst/schedulers/gstoptimalscheduler.c @@ -313,12 +313,23 @@ GstPluginDesc plugin_desc = { static void delete_chain (GstOptScheduler *osched, GstOptSchedulerChain *chain) { + GSList *groups; + GST_INFO (GST_CAT_SCHEDULING, "delete chain %p", chain); g_assert (chain->sched == osched); osched->chains = g_slist_remove (osched->chains, chain); + groups = chain->groups; + while (groups) { + GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) groups->data; + + group->chain = NULL; + + groups = g_slist_next (groups); + } + g_slist_free (chain->groups); g_free (chain); } @@ -460,6 +471,8 @@ destroy_group_scheduler (GstOptSchedulerGroup *group) static void delete_group (GstOptSchedulerGroup *group) { + GSList *elements; + GST_INFO (GST_CAT_SCHEDULING, "delete group %p", group); g_assert (group->chain == NULL); @@ -467,6 +480,16 @@ delete_group (GstOptSchedulerGroup *group) if (group->flags & GST_OPT_SCHEDULER_GROUP_SCHEDULABLE) destroy_group_scheduler (group); + /* remove all elements from the group */ + elements = group->elements; + while (elements) { + GstElement *element = GST_ELEMENT (elements->data); + + GST_ELEMENT_SCHED_GROUP (element) = NULL; + + elements = g_slist_next (elements); + } + g_slist_free (group->elements); g_free (group); } @@ -1030,9 +1053,14 @@ gst_opt_scheduler_remove_element (GstScheduler *sched, GstElement *element) /* the element is guaranteed to live in it's own group/chain now */ get_group (element, &group); if (group) { + if (group->chain) { - remove_from_chain (group->chain, group); - delete_chain (osched, group->chain); + GstOptSchedulerChain *chain; + + chain = group->chain; + + remove_from_chain (chain, group); + delete_chain (osched, chain); } delete_group (group); -- 2.7.4