- some cleanups

Original commit message from CVS:
- some cleanups
- revert a patch that needs more thinking..
- move common code and sanity checks in gstscheduler.c instead of the
real schedulers.
- remove sanity checks from the schedulers
This commit is contained in:
Wim Taymans 2002-09-13 23:02:54 +00:00
parent 1e4b4cf6c2
commit e6e1dc2e0e
6 changed files with 19 additions and 40 deletions

View file

@ -2475,7 +2475,7 @@ gst_element_set_scheduler (GstElement *element,
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element, "setting scheduler to %p", sched);
element->sched = sched;
GST_ELEMENT_SCHED (element) = sched;
}
/**
@ -2491,7 +2491,7 @@ gst_element_get_scheduler (GstElement *element)
{
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
return element->sched;
return GST_ELEMENT_SCHED (element);
}
/**

View file

@ -827,11 +827,13 @@ gst_pad_disconnect (GstPad *srcpad,
GST_RPAD_FILTER (realsrc) = NULL;
}
/* now tell the scheduler, the schedulers on both paths are guaranteed to be the same,
* so we can just take one */
if (src_sched && src_sched == sink_sched)
/* now tell the scheduler */
if (src_sched)
gst_scheduler_pad_disconnect (src_sched,
GST_PAD_CAST (realsrc), GST_PAD_CAST (realsink));
else if (sink_sched)
gst_scheduler_pad_disconnect (sink_sched,
GST_PAD_CAST (realsrc), GST_PAD_CAST (realsink));
/* hold a reference, as they can go away in the signal handlers */
gst_object_ref (GST_OBJECT (realsrc));
@ -1018,8 +1020,7 @@ gst_pad_connect_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps)
src_sched = gst_pad_get_scheduler (GST_PAD_CAST (realsrc));
sink_sched = gst_pad_get_scheduler (GST_PAD_CAST (realsink));
/* now tell the scheduler, the schedulers on both paths have to be the same,
* so we can just take one */
/* now tell the scheduler */
if (src_sched)
gst_scheduler_pad_connect (src_sched,
GST_PAD_CAST (realsrc), GST_PAD_CAST (realsink));

View file

@ -202,6 +202,13 @@ gst_scheduler_add_element (GstScheduler *sched, GstElement *element)
g_return_if_fail (GST_IS_SCHEDULER (sched));
g_return_if_fail (GST_IS_ELEMENT (element));
/* if it's already in this scheduler, don't bother doing anything */
if (GST_ELEMENT_SCHED (element) == sched)
return;
/* if it's not inside this scheduler, it has to be NULL */
g_assert (GST_ELEMENT_SCHED (element) == NULL);
if (element->getclockfunc) {
sched->clock_providers = g_list_prepend (sched->clock_providers, element);
GST_DEBUG (GST_CAT_CLOCK, "added clock provider %s", GST_ELEMENT_NAME (element));
@ -211,7 +218,7 @@ gst_scheduler_add_element (GstScheduler *sched, GstElement *element)
GST_DEBUG (GST_CAT_CLOCK, "added clock receiver %s", GST_ELEMENT_NAME (element));
}
/* gst_element_set_scheduler (element, sched); */
gst_element_set_scheduler (element, sched);
if (CLASS (sched)->add_element)
CLASS (sched)->add_element (sched, element);
@ -233,10 +240,10 @@ gst_scheduler_remove_element (GstScheduler *sched, GstElement *element)
sched->clock_providers = g_list_remove (sched->clock_providers, element);
sched->clock_receivers = g_list_remove (sched->clock_receivers, element);
/* gst_element_set_scheduler (element, NULL); */
if (CLASS (sched)->remove_element)
CLASS (sched)->remove_element (sched, element);
gst_element_set_scheduler (element, NULL);
}
/**

View file

@ -1018,27 +1018,13 @@ gst_basic_scheduler_add_element (GstScheduler * sched, GstElement * element)
GstSchedulerChain *chain;
GstBasicScheduler *bsched = GST_BASIC_SCHEDULER (sched);
/* if it's already in this scheduler, don't bother doing anything */
if (GST_ELEMENT_SCHED (element) == sched)
return;
GST_INFO (GST_CAT_SCHEDULING, "adding element \"%s\" to scheduler", GST_ELEMENT_NAME (element));
/* if the element already has a scheduler something went wrong */
if (GST_ELEMENT_SCHED (element)) {
GST_ERROR (element, "grave error");
return;
}
/* set the sched pointer in the element itself */
GST_ELEMENT_SCHED (element) = sched;
/* only deal with elements after this point, not bins */
/* exception is made for Bin's that are schedulable, like the autoplugger */
if (GST_IS_BIN (element) && !GST_FLAG_IS_SET (element, GST_BIN_SELF_SCHEDULABLE))
return;
/* first add it to the list of elements that are to be scheduled */
bsched->elements = g_list_prepend (bsched->elements, element);
bsched->num_elements++;
@ -1098,7 +1084,6 @@ gst_basic_scheduler_remove_element (GstScheduler * sched, GstElement * element)
/* unset the scheduler pointer in the element */
}
GST_ELEMENT_SCHED (element) = NULL;
}
static GstElementStateReturn

View file

@ -675,20 +675,8 @@ gst_fast_scheduler_add_element (GstScheduler * sched, GstElement * element)
GstSchedulerChain *chain;
GstFastScheduler *bsched = GST_FAST_SCHEDULER (sched);
/* if it's already in this scheduler, don't bother doing anything */
if (GST_ELEMENT_SCHED (element) == sched)
return;
GST_INFO (GST_CAT_SCHEDULING, "adding element \"%s\" to scheduler", GST_ELEMENT_NAME (element));
/* if the element already has a different scheduler, remove the element from it */
if (GST_ELEMENT_SCHED (element)) {
gst_fast_scheduler_remove_element (GST_ELEMENT_SCHED (element), element);
}
/* set the sched pointer in the element itself */
GST_ELEMENT_SCHED (element) = sched;
/* only deal with elements after this point, not bins */
/* exception is made for Bin's that are schedulable, like the autoplugger */
if (GST_IS_BIN (element) && !GST_FLAG_IS_SET (element, GST_BIN_SELF_SCHEDULABLE))
@ -743,9 +731,6 @@ gst_fast_scheduler_remove_element (GstScheduler * sched, GstElement * element)
/* remove it from the list of elements */
bsched->elements = g_list_remove (bsched->elements, element);
bsched->num_elements--;
/* unset the scheduler pointer in the element */
GST_ELEMENT_SCHED (element) = NULL;
}
}

View file

@ -120,6 +120,7 @@ typedef enum {
#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))
#define GST_OPT_SCHEDULER_GROUP_IS_DISABLED(group) ((group)->flags & GST_OPT_SCHEDULER_GROUP_DISABLED)
typedef struct _GstOptSchedulerGroup GstOptSchedulerGroup;