From: Wim T. <wt...@us...> - 2002-12-16 21:21:17
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Mon Dec 16 2002 13:21:16 PST Log message: - Factor out some error functions - handle the cases where multipad get to multi-sink loop/chain based elements are connected. Modified files: gst/schedulers : gstoptimalscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c.diff?r1=1.14&r2=1.15 ====Begin Diffs==== Index: gstoptimalscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- gstoptimalscheduler.c 15 Dec 2002 22:52:48 -0000 1.14 +++ gstoptimalscheduler.c 16 Dec 2002 21:21:02 -0000 1.15 @@ -123,6 +123,10 @@ GST_OPT_SCHEDULER_GROUP_LOOP = 2, } GstOptSchedulerGroupType; +#define GST_OPT_SCHEDULER_GROUP_SET_FLAG(group,flag) ((group)->flags |= (flag)) +#define GST_OPT_SCHEDULER_GROUP_UNSET_FLAG(group,flag) ((group)->flags &= (flag)) +#define GST_OPT_SCHEDULER_GROUP_IS_FLAG_SET(group,flag) ((group)->flags & (flag)) + #define GST_OPT_SCHEDULER_GROUP_DISABLE(group) ((group)->flags |= GST_OPT_SCHEDULER_GROUP_DISABLED) #define GST_OPT_SCHEDULER_GROUP_ENABLE(group) ((group)->flags &= ~GST_OPT_SCHEDULER_GROUP_DISABLED) #define GST_OPT_SCHEDULER_GROUP_IS_ENABLED(group) (!((group)->flags & GST_OPT_SCHEDULER_GROUP_DISABLED)) @@ -583,6 +587,13 @@ } } +static void +group_error_handler (GstOptSchedulerGroup *group) +{ + chain_group_set_enabled (group->chain, group, FALSE); + group->chain->sched->state = GST_OPT_SCHEDULER_STATE_ERROR; +} + /* this function enables/disables an element, it will set/clear a flag on the element * and tells the chain that the group is enabled if all elements inside the group are * enabled */ @@ -621,6 +632,9 @@ static gboolean schedule_group (GstOptSchedulerGroup *group) { + if (!group->entry) + return FALSE; + #ifdef USE_COTHREADS if (group->cothread) do_cothread_switch (group->cothread); @@ -649,7 +663,10 @@ GST_INFO (GST_CAT_SCHEDULING, "scheduling %p", group); - schedule_group (group); + if (!schedule_group (group)) { + g_warning ("error scheduling group %p", group); + group_error_handler (group); + } GST_INFO (GST_CAT_SCHEDULING, "done scheduling %p", group); } @@ -763,8 +780,7 @@ GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) argv; g_warning ("(internal error) unkown group type %d, disabling\n", group->type); - chain_group_set_enabled (group->chain, group, FALSE); - group->chain->sched->state = GST_OPT_SCHEDULER_STATE_ERROR; + group_error_handler (group); return 0; } @@ -787,8 +803,7 @@ #ifdef USE_COTHREADS if (GST_PAD_BUFLIST (GST_RPAD_PEER (sinkpad))) { g_warning ("deadlock detected, disabling group %p", group); - chain_group_set_enabled (group->chain, group, FALSE); - group->chain->sched->state = GST_OPT_SCHEDULER_STATE_ERROR; + group_error_handler (group); } else { GST_PAD_BUFLIST (GST_RPAD_PEER (sinkpad)) = g_list_append (GST_PAD_BUFLIST (GST_RPAD_PEER (sinkpad)), buffer); @@ -834,8 +849,7 @@ } else { g_warning ("deadlock detected, disabling group %p", group); - chain_group_set_enabled (group->chain, group, FALSE); - group->chain->sched->state = GST_OPT_SCHEDULER_STATE_ERROR; + group_error_handler (group); return NULL; } #endif @@ -1167,6 +1181,10 @@ gst_opt_scheduler_error (GstScheduler *sched, GstElement *element) { GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + GstOptSchedulerGroup *group; + get_group (element, &group); + if (group) + group_error_handler (group); osched->state = GST_OPT_SCHEDULER_STATE_ERROR; } @@ -1200,11 +1218,17 @@ /* this could be tricky, the get based source could * already be part of a loop based group in another pad, * we assert on that for now */ - if (GST_ELEMENT_SCHED_CONTEXT (element1) && + if (GST_ELEMENT_SCHED_CONTEXT (element1) != NULL && GST_ELEMENT_SCHED_GROUP (element1) != NULL) { - g_error ("internal error: cannot schedule get to loop with get in group"); - return; + GstOptSchedulerGroup *group = GST_ELEMENT_SCHED_GROUP (element1); + + /* if the loop based element is the entry point we're ok, if it + * isn't then we have multiple loop based elements in this group */ + if (group->entry != element2) { + g_error ("internal error: cannot schedule get to loop in multi-loop based group"); + return; + } } } else @@ -1215,11 +1239,17 @@ type = GST_OPT_GET_TO_CHAIN; /* the get based source could already be part of a loop * based group in another pad, we assert on that for now */ - if (GST_ELEMENT_SCHED_CONTEXT (element1) && + if (GST_ELEMENT_SCHED_CONTEXT (element1) != NULL && GST_ELEMENT_SCHED_GROUP (element1) != NULL) { - g_error ("internal error: cannot schedule get to loop with get in group"); - return; + GstOptSchedulerGroup *group = GST_ELEMENT_SCHED_GROUP (element1); + + /* if the get based element is the entry point we're ok, if it + * isn't then we have a mixed loop/chain based group */ + if (group->entry != element1) { + g_error ("internal error: cannot schedule get to chain with mixed loop/chain based group"); + return; + } } } else |