- Make the return GList of gst_element_get_pad_list as const

Original commit message from CVS:
- Make the return GList of gst_element_get_pad_list as const
- Pad scheduler refactoring
- Remove gst_pad_set/unset_scheduler as it's not needed
- Reimplement gst_pad_get_scheduler using the parent scheduler
- Remove gst_pad_peek as it cannot work reliably
- Remove the pad bufpen, replace with scheduler private gpointer
- Make queue use the new _get_scheduler implementation
- Remove _pad_unset_scheduler from GstScheduler
- Remove LOOP_SEEK mode from aggregator
- Other fixes for API changes.
This commit is contained in:
Wim Taymans 2002-09-12 20:52:03 +00:00
parent 498d3181d7
commit 37a127d9ed
21 changed files with 121 additions and 188 deletions

View file

@ -410,7 +410,7 @@ void
gst_spider_identity_plug (GstSpiderIdentity *ident) gst_spider_identity_plug (GstSpiderIdentity *ident)
{ {
GstSpider *spider; GstSpider *spider;
GList *padlist; const GList *padlist;
GstPadDirection dir; GstPadDirection dir;
GstSpiderConnection *conn; GstSpiderConnection *conn;

View file

@ -144,7 +144,7 @@ gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest)
static gboolean static gboolean
gst_autoplug_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink) gst_autoplug_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink)
{ {
GList *sinkpads; const GList *sinkpads;
gboolean connected = FALSE; gboolean connected = FALSE;
GST_DEBUG (0,"gstpipeline: autoplug pad connect function for \"%s\" to \"%s\"", GST_DEBUG (0,"gstpipeline: autoplug pad connect function for \"%s\" to \"%s\"",
@ -190,7 +190,7 @@ static void
autoplug_dynamic_pad (GstElement *element, GstPad *pad, gpointer data) autoplug_dynamic_pad (GstElement *element, GstPad *pad, gpointer data)
{ {
dynamic_pad_struct *info = (dynamic_pad_struct *)data; dynamic_pad_struct *info = (dynamic_pad_struct *)data;
GList *pads = gst_element_get_pad_list (element); const GList *pads = gst_element_get_pad_list (element);
GST_DEBUG (0,"attempting to dynamically create a ghostpad for %s=%s", GST_ELEMENT_NAME (element), GST_DEBUG (0,"attempting to dynamically create a ghostpad for %s=%s", GST_ELEMENT_NAME (element),
GST_PAD_NAME (pad)); GST_PAD_NAME (pad));
@ -216,7 +216,7 @@ autoplug_dynamic_pad (GstElement *element, GstPad *pad, gpointer data)
static void static void
gst_autoplug_pads_autoplug (GstElement *src, GstElement *sink) gst_autoplug_pads_autoplug (GstElement *src, GstElement *sink)
{ {
GList *srcpads; const GList *srcpads;
gboolean connected = FALSE; gboolean connected = FALSE;
srcpads = gst_element_get_pad_list(src); srcpads = gst_element_get_pad_list(src);
@ -391,7 +391,7 @@ gst_static_autoplug_to_caps (GstAutoplug *autoplug, GstCaps *srccaps, GstCaps *s
} }
/* this is the first element, find a good ghostpad */ /* this is the first element, find a good ghostpad */
else { else {
GList *pads; const GList *pads;
pads = gst_element_get_pad_list (element); pads = gst_element_get_pad_list (element);
@ -453,7 +453,7 @@ differ:
*/ */
{ {
GstCaps *endcap = (GstCaps *)(endcaps->data); GstCaps *endcap = (GstCaps *)(endcaps->data);
GList *pads = gst_element_get_pad_list (thesrcelement); const GList *pads = gst_element_get_pad_list (thesrcelement);
gboolean have_pad = FALSE; gboolean have_pad = FALSE;
endcaps = g_list_next (endcaps); endcaps = g_list_next (endcaps);

View file

@ -171,7 +171,7 @@ gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest)
static gboolean static gboolean
gst_autoplug_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink) gst_autoplug_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink)
{ {
GList *sinkpads; const GList *sinkpads;
gboolean connected = FALSE; gboolean connected = FALSE;
GstElementState state = GST_STATE (gst_element_get_parent (src)); GstElementState state = GST_STATE (gst_element_get_parent (src));
@ -212,7 +212,7 @@ gst_autoplug_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink)
static void static void
gst_autoplug_pads_autoplug (GstElement *src, GstElement *sink) gst_autoplug_pads_autoplug (GstElement *src, GstElement *sink)
{ {
GList *srcpads; const GList *srcpads;
gboolean connected = FALSE; gboolean connected = FALSE;
srcpads = gst_element_get_pad_list(src); srcpads = gst_element_get_pad_list(src);
@ -406,7 +406,7 @@ next:
} }
/* this is the first element, find a good ghostpad */ /* this is the first element, find a good ghostpad */
else { else {
GList *pads; const GList *pads;
pads = gst_element_get_pad_list (element); pads = gst_element_get_pad_list (element);

View file

@ -61,7 +61,6 @@ gst_aggregator_sched_get_type (void)
static GType aggregator_sched_type = 0; static GType aggregator_sched_type = 0;
static GEnumValue aggregator_sched[] = { static GEnumValue aggregator_sched[] = {
{ AGGREGATOR_LOOP, "1", "Loop Based"}, { AGGREGATOR_LOOP, "1", "Loop Based"},
{ AGGREGATOR_LOOP_PEEK, "2", "Loop Based Peek"},
{ AGGREGATOR_LOOP_SELECT, "3", "Loop Based Select"}, { AGGREGATOR_LOOP_SELECT, "3", "Loop Based Select"},
{ AGGREGATOR_CHAIN, "4", "Chain Based"}, { AGGREGATOR_CHAIN, "4", "Chain Based"},
{0, NULL, NULL}, {0, NULL, NULL},
@ -286,26 +285,16 @@ gst_aggregator_loop (GstElement *element)
aggregator = GST_AGGREGATOR (element); aggregator = GST_AGGREGATOR (element);
if (aggregator->sched == AGGREGATOR_LOOP || if (aggregator->sched == AGGREGATOR_LOOP) {
aggregator->sched == AGGREGATOR_LOOP_PEEK) {
GList *pads = aggregator->sinkpads; GList *pads = aggregator->sinkpads;
while (pads) { while (pads) {
GstPad *pad = GST_PAD (pads->data); GstPad *pad = GST_PAD (pads->data);
pads = g_list_next (pads); pads = g_list_next (pads);
if (aggregator->sched == AGGREGATOR_LOOP_PEEK) { buf = gst_pad_pull (pad);
buf = gst_pad_peek (pad); debug = "loop";
if (buf == NULL)
continue;
g_assert (buf == gst_pad_pull (pad));
debug = "loop_peek";
}
else {
buf = gst_pad_pull (pad);
debug = "loop";
}
gst_aggregator_push (aggregator, pad, buf, debug); gst_aggregator_push (aggregator, pad, buf, debug);
} }
} }

View file

@ -35,7 +35,6 @@ extern GstElementDetails gst_aggregator_details;
typedef enum { typedef enum {
AGGREGATOR_LOOP = 1, AGGREGATOR_LOOP = 1,
AGGREGATOR_LOOP_PEEK,
AGGREGATOR_LOOP_SELECT, AGGREGATOR_LOOP_SELECT,
AGGREGATOR_CHAIN, AGGREGATOR_CHAIN,
} GstAggregatorSchedType; } GstAggregatorSchedType;

View file

@ -308,6 +308,7 @@ gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ)
srcpad = gst_pad_new_from_template (templ, name); srcpad = gst_pad_new_from_template (templ, name);
gst_element_add_pad (GST_ELEMENT (fakesrc), srcpad); gst_element_add_pad (GST_ELEMENT (fakesrc), srcpad);
gst_fakesrc_update_functions (fakesrc);
g_free (name); g_free (name);
@ -783,7 +784,7 @@ static void
gst_fakesrc_loop(GstElement *element) gst_fakesrc_loop(GstElement *element)
{ {
GstFakeSrc *src; GstFakeSrc *src;
GList *pads; const GList *pads;
g_return_if_fail(element != NULL); g_return_if_fail(element != NULL);
g_return_if_fail(GST_IS_FAKESRC(element)); g_return_if_fail(GST_IS_FAKESRC(element));

View file

@ -122,7 +122,7 @@ static GstPadConnectReturn
gst_tee_sinkconnect (GstPad *pad, GstCaps *caps) gst_tee_sinkconnect (GstPad *pad, GstCaps *caps)
{ {
GstTee *tee; GstTee *tee;
GList *pads; const GList *pads;
GstPadConnectReturn set_retval; GstPadConnectReturn set_retval;
tee = GST_TEE (gst_pad_get_parent (pad)); tee = GST_TEE (gst_pad_get_parent (pad));
@ -177,8 +177,8 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar
gchar *name; gchar *name;
GstPad *srcpad; GstPad *srcpad;
GstTee *tee; GstTee *tee;
int i = 0; gint i = 0;
GList *pads; const GList *pads;
g_return_val_if_fail (GST_IS_TEE (element), NULL); g_return_val_if_fail (GST_IS_TEE (element), NULL);
@ -196,7 +196,7 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar
while (!name) while (!name)
{ {
name = g_strdup_printf ("src%d", i); name = g_strdup_printf ("src%d", i);
if (g_list_find_custom (pads, (gconstpointer) name, name_pad_compare) != NULL) if (g_list_find_custom ((GList *)pads, (gconstpointer) name, name_pad_compare) != NULL)
{ {
/* this name is taken, use the next one */ /* this name is taken, use the next one */
++i; ++i;
@ -279,7 +279,7 @@ static void
gst_tee_chain (GstPad *pad, GstBuffer *buf) gst_tee_chain (GstPad *pad, GstBuffer *buf)
{ {
GstTee *tee; GstTee *tee;
GList *pads; const GList *pads;
g_return_if_fail (pad != NULL); g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad)); g_return_if_fail (GST_IS_PAD (pad));

View file

@ -1199,7 +1199,7 @@ gst_element_get_request_pad (GstElement *element, const gchar *name)
* *
* Returns: the #GList of pads. * Returns: the #GList of pads.
*/ */
GList* const GList*
gst_element_get_pad_list (GstElement *element) gst_element_get_pad_list (GstElement *element)
{ {
g_return_val_if_fail (element != NULL, NULL); g_return_val_if_fail (element != NULL, NULL);
@ -1391,7 +1391,7 @@ GstPad*
gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad, gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad,
GstCaps *filtercaps) GstCaps *filtercaps)
{ {
GList *pads; const GList *pads;
GstPadTemplate *templ; GstPadTemplate *templ;
GstCaps *templcaps; GstCaps *templcaps;
GstPad *foundpad = NULL; GstPad *foundpad = NULL;
@ -1482,7 +1482,7 @@ gboolean
gst_element_connect_filtered (GstElement *src, GstElement *dest, gst_element_connect_filtered (GstElement *src, GstElement *dest,
GstCaps *filtercaps) GstCaps *filtercaps)
{ {
GList *srcpads, *destpads, *srctempls, *desttempls, *l; const GList *srcpads, *destpads, *srctempls, *desttempls, *l;
GstPad *srcpad, *destpad; GstPad *srcpad, *destpad;
GstPadTemplate *srctempl, *desttempl; GstPadTemplate *srctempl, *desttempl;
@ -1769,7 +1769,7 @@ gst_element_disconnect_many (GstElement *element_1, GstElement *element_2, ...)
void void
gst_element_disconnect (GstElement *src, GstElement *dest) gst_element_disconnect (GstElement *src, GstElement *dest)
{ {
GList *srcpads; const GList *srcpads;
GstPad *pad; GstPad *pad;
g_return_if_fail (GST_IS_ELEMENT (src)); g_return_if_fail (GST_IS_ELEMENT (src));

View file

@ -236,7 +236,7 @@ GstPad* gst_element_get_static_pad (GstElement *element, const gchar *name);
GstPad* gst_element_get_request_pad (GstElement *element, const gchar *name); GstPad* gst_element_get_request_pad (GstElement *element, const gchar *name);
void gst_element_release_request_pad (GstElement *element, GstPad *pad); void gst_element_release_request_pad (GstElement *element, GstPad *pad);
GList* gst_element_get_pad_list (GstElement *element); const GList* gst_element_get_pad_list (GstElement *element);
GstPad* gst_element_get_compatible_pad (GstElement *element, GstPad *pad); GstPad* gst_element_get_compatible_pad (GstElement *element, GstPad *pad);
GstPad* gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad, GstPad* gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad,
GstCaps *filtercaps); GstCaps *filtercaps);

View file

@ -207,9 +207,6 @@ gst_real_pad_init (GstRealPad *pad)
pad->direction = GST_PAD_UNKNOWN; pad->direction = GST_PAD_UNKNOWN;
pad->peer = NULL; pad->peer = NULL;
pad->sched = NULL;
pad->sched_private = NULL;
pad->chainfunc = NULL; pad->chainfunc = NULL;
pad->getfunc = NULL; pad->getfunc = NULL;
@ -245,6 +242,7 @@ gst_real_pad_set_property (GObject *object, guint prop_id,
gst_pad_set_active (GST_PAD (object), g_value_get_boolean (value)); gst_pad_set_active (GST_PAD (object), g_value_get_boolean (value));
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
} }
} }
@ -253,7 +251,6 @@ static void
gst_real_pad_get_property (GObject *object, guint prop_id, gst_real_pad_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec) GValue *value, GParamSpec *pspec)
{ {
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_PAD (object)); g_return_if_fail (GST_IS_PAD (object));
switch (prop_id) { switch (prop_id) {
@ -261,6 +258,7 @@ gst_real_pad_get_property (GObject *object, guint prop_id,
g_value_set_boolean (value, !GST_FLAG_IS_SET (object, GST_PAD_DISABLED)); g_value_set_boolean (value, !GST_FLAG_IS_SET (object, GST_PAD_DISABLED));
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
} }
} }
@ -784,6 +782,7 @@ gst_pad_disconnect (GstPad *srcpad,
GstPad *sinkpad) GstPad *sinkpad)
{ {
GstRealPad *realsrc, *realsink; GstRealPad *realsrc, *realsink;
GstScheduler *src_sched, *sink_sched;
/* generic checks */ /* generic checks */
g_return_if_fail (srcpad != NULL); g_return_if_fail (srcpad != NULL);
@ -813,6 +812,10 @@ gst_pad_disconnect (GstPad *srcpad,
g_return_if_fail ((GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC) && g_return_if_fail ((GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC) &&
(GST_RPAD_DIRECTION (realsink) == GST_PAD_SINK)); (GST_RPAD_DIRECTION (realsink) == GST_PAD_SINK));
/* get the schedulers before we disconnect */
src_sched = gst_pad_get_scheduler (GST_PAD_CAST (realsrc));
sink_sched = gst_pad_get_scheduler (GST_PAD_CAST (realsink));
/* first clear peers */ /* first clear peers */
GST_RPAD_PEER (realsrc) = NULL; GST_RPAD_PEER (realsrc) = NULL;
GST_RPAD_PEER (realsink) = NULL; GST_RPAD_PEER (realsink) = NULL;
@ -824,13 +827,11 @@ gst_pad_disconnect (GstPad *srcpad,
GST_RPAD_FILTER (realsrc) = NULL; GST_RPAD_FILTER (realsrc) = NULL;
} }
/* now tell the scheduler */ /* now tell the scheduler, the schedulers on both paths are guaranteed to be the same,
if (GST_PAD_PARENT (realsrc)->sched) * so we can just take one */
gst_scheduler_pad_disconnect (GST_PAD_PARENT (realsrc)->sched, if (src_sched && src_sched == sink_sched)
(GstPad *) realsrc, (GstPad *) realsink); gst_scheduler_pad_disconnect (src_sched,
else if (GST_PAD_PARENT (realsink)->sched) GST_PAD_CAST (realsrc), GST_PAD_CAST (realsink));
gst_scheduler_pad_disconnect (GST_PAD_PARENT (realsink)->sched,
(GstPad *) realsrc, (GstPad *) realsink);
/* hold a reference, as they can go away in the signal handlers */ /* hold a reference, as they can go away in the signal handlers */
gst_object_ref (GST_OBJECT (realsrc)); gst_object_ref (GST_OBJECT (realsrc));
@ -850,6 +851,28 @@ gst_pad_disconnect (GstPad *srcpad,
gst_object_unref (GST_OBJECT (realsink)); gst_object_unref (GST_OBJECT (realsink));
} }
static gboolean
gst_pad_check_schedulers (GstRealPad *realsrc, GstRealPad *realsink)
{
GstScheduler *src_sched, *sink_sched;
gint num_decoupled = 0;
src_sched = gst_pad_get_scheduler (GST_PAD_CAST (realsrc));
sink_sched = gst_pad_get_scheduler (GST_PAD_CAST (realsink));
if (src_sched && sink_sched) {
if (GST_FLAG_IS_SET (GST_PAD_PARENT (realsrc), GST_ELEMENT_DECOUPLED))
num_decoupled++;
if (GST_FLAG_IS_SET (GST_PAD_PARENT (realsink), GST_ELEMENT_DECOUPLED))
num_decoupled++;
if (src_sched != sink_sched && num_decoupled != 1) {
return FALSE;
}
}
return TRUE;
}
/** /**
* gst_pad_can_connect_filtered: * gst_pad_can_connect_filtered:
* @srcpad: the source #GstPad to connect. * @srcpad: the source #GstPad to connect.
@ -865,7 +888,6 @@ gboolean
gst_pad_can_connect_filtered (GstPad *srcpad, GstPad *sinkpad, gst_pad_can_connect_filtered (GstPad *srcpad, GstPad *sinkpad,
GstCaps *filtercaps) GstCaps *filtercaps)
{ {
gint num_decoupled = 0;
GstRealPad *realsrc, *realsink; GstRealPad *realsrc, *realsink;
/* generic checks */ /* generic checks */
@ -883,17 +905,10 @@ gst_pad_can_connect_filtered (GstPad *srcpad, GstPad *sinkpad,
g_return_val_if_fail (GST_PAD_PARENT (realsrc) != NULL, FALSE); g_return_val_if_fail (GST_PAD_PARENT (realsrc) != NULL, FALSE);
g_return_val_if_fail (GST_PAD_PARENT (realsink) != NULL, FALSE); g_return_val_if_fail (GST_PAD_PARENT (realsink) != NULL, FALSE);
if (realsrc->sched && realsink->sched) { if (!gst_pad_check_schedulers (realsrc, realsink)) {
if (GST_FLAG_IS_SET (GST_PAD_PARENT (realsrc), GST_ELEMENT_DECOUPLED)) g_warning ("connecting pads with different scheds requires "
num_decoupled++; "exactly one decoupled element (queue)");
if (GST_FLAG_IS_SET (GST_PAD_PARENT (realsink), GST_ELEMENT_DECOUPLED)) return FALSE;
num_decoupled++;
if (realsrc->sched != realsink->sched && num_decoupled != 1) {
g_warning ("connecting pads with different scheds requires "
"exactly one decoupled element (queue)");
return FALSE;
}
} }
/* check if the directions are compatible */ /* check if the directions are compatible */
@ -935,7 +950,7 @@ gboolean
gst_pad_connect_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps) gst_pad_connect_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps)
{ {
GstRealPad *realsrc, *realsink; GstRealPad *realsrc, *realsink;
gint num_decoupled = 0; GstScheduler *src_sched, *sink_sched;
/* generic checks */ /* generic checks */
g_return_val_if_fail (srcpad != NULL, FALSE); g_return_val_if_fail (srcpad != NULL, FALSE);
@ -960,19 +975,12 @@ gst_pad_connect_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps)
g_return_val_if_fail (GST_PAD_PARENT (realsrc) != NULL, FALSE); g_return_val_if_fail (GST_PAD_PARENT (realsrc) != NULL, FALSE);
g_return_val_if_fail (GST_PAD_PARENT (realsink) != NULL, FALSE); g_return_val_if_fail (GST_PAD_PARENT (realsink) != NULL, FALSE);
if (realsrc->sched && realsink->sched) { if (!gst_pad_check_schedulers (realsrc, realsink)) {
if (GST_FLAG_IS_SET (GST_PAD_PARENT (realsrc), GST_ELEMENT_DECOUPLED)) g_warning ("connecting pads with different scheds requires "
num_decoupled++; "exactly one decoupled element (such as queue)");
if (GST_FLAG_IS_SET (GST_PAD_PARENT (realsink), GST_ELEMENT_DECOUPLED)) return FALSE;
num_decoupled++;
if (realsrc->sched != realsink->sched && num_decoupled != 1) {
g_warning ("connecting pads with different scheds "
"requires exactly one decoupled element (queue)\n");
return FALSE;
}
} }
/* check for reversed directions and swap if necessary */ /* check for reversed directions and swap if necessary */
if ((GST_RPAD_DIRECTION (realsrc) == GST_PAD_SINK) && if ((GST_RPAD_DIRECTION (realsrc) == GST_PAD_SINK) &&
(GST_RPAD_DIRECTION (realsink) == GST_PAD_SRC)) { (GST_RPAD_DIRECTION (realsink) == GST_PAD_SRC)) {
@ -1007,13 +1015,14 @@ gst_pad_connect_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps)
g_signal_emit (G_OBJECT (realsink), gst_real_pad_signals[REAL_CONNECTED], g_signal_emit (G_OBJECT (realsink), gst_real_pad_signals[REAL_CONNECTED],
0, realsrc); 0, realsrc);
/* now tell the scheduler(s) */ src_sched = gst_pad_get_scheduler (GST_PAD_CAST (realsrc));
if (realsrc->sched) sink_sched = gst_pad_get_scheduler (GST_PAD_CAST (realsink));
gst_scheduler_pad_connect (realsrc->sched,
(GstPad *) realsrc, (GstPad *) realsink); /* now tell the scheduler, the schedulers on both paths have to be the same,
else if (realsink->sched) * so we can just take one */
gst_scheduler_pad_connect (realsink->sched, if (src_sched && src_sched == sink_sched)
(GstPad *) realsrc, (GstPad *) realsink); gst_scheduler_pad_connect (src_sched,
GST_PAD_CAST (realsrc), GST_PAD_CAST (realsink));
GST_INFO (GST_CAT_PADS, "connected %s:%s and %s:%s", GST_INFO (GST_CAT_PADS, "connected %s:%s and %s:%s",
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
@ -1093,22 +1102,6 @@ gst_pad_get_pad_template (GstPad *pad)
} }
/**
* gst_pad_set_scheduler:
* @pad: a #GstPad to set the scheduler of.
* @sched: the #GstScheduler to set.
*
* Sets the scheduler on the pad.
*/
void
gst_pad_set_scheduler (GstPad *pad, GstScheduler *sched)
{
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
GST_RPAD_SCHED(pad) = sched;
}
/** /**
* gst_pad_get_scheduler: * gst_pad_get_scheduler:
* @pad: a #GstPad to get the scheduler of. * @pad: a #GstPad to get the scheduler of.
@ -1120,27 +1113,29 @@ gst_pad_set_scheduler (GstPad *pad, GstScheduler *sched)
GstScheduler* GstScheduler*
gst_pad_get_scheduler (GstPad *pad) gst_pad_get_scheduler (GstPad *pad)
{ {
GstScheduler *scheduler = NULL;
GstElement *parent;
g_return_val_if_fail (pad != NULL, NULL); g_return_val_if_fail (pad != NULL, NULL);
g_return_val_if_fail (GST_IS_PAD (pad), NULL); g_return_val_if_fail (GST_IS_PAD (pad), NULL);
parent = gst_pad_get_parent (pad);
if (parent) {
if (GST_FLAG_IS_SET (parent, GST_ELEMENT_DECOUPLED)) {
GstRealPad *peer = GST_RPAD_PEER (pad);
if (peer) {
scheduler = gst_element_get_scheduler (gst_pad_get_parent (GST_PAD_CAST (peer)));
}
}
else {
scheduler = gst_element_get_scheduler (parent);
}
}
return GST_RPAD_SCHED (pad); return scheduler;
} }
/**
* gst_pad_unset_scheduler:
* @pad: a #GstPad to unset the scheduler for.
*
* Unsets the scheduler for the pad.
*/
void
gst_pad_unset_scheduler (GstPad *pad)
{
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
GST_RPAD_SCHED (pad) = NULL;
}
/** /**
* gst_pad_get_real_parent: * gst_pad_get_real_parent:
* @pad: a #GstPad to get the real parent of. * @pad: a #GstPad to get the real parent of.
@ -2148,23 +2143,6 @@ gst_pad_pull (GstPad *pad)
return NULL; return NULL;
} }
/**
* gst_pad_peek:
* @pad: the #GstPad to peek at.
*
* Peeks for the presence of a buffer on the peer pad.
*
* Returns: a #GstBuffer waiting on the the peer pad,
* or NULL if the peer has no waiting buffer.
*/
GstBuffer*
gst_pad_peek (GstPad *pad)
{
g_return_val_if_fail (GST_PAD_DIRECTION (pad) == GST_PAD_SINK, NULL);
return GST_RPAD_BUFPEN (GST_RPAD_PEER (pad));
}
/** /**
* gst_pad_select: * gst_pad_select:
* @padlist: a #GList of pads. * @padlist: a #GList of pads.

View file

@ -197,13 +197,10 @@ struct _GstRealPad {
GstPadDirection direction; GstPadDirection direction;
GstScheduler *sched;
gpointer sched_private;
GstPadConnectFunction connectfunc; GstPadConnectFunction connectfunc;
GstRealPad *peer; GstRealPad *peer;
GstBuffer *bufpen; gpointer sched_private;
/* data transport functions */ /* data transport functions */
GstPadChainFunction chainfunc; GstPadChainFunction chainfunc;
@ -264,8 +261,6 @@ struct _GstGhostPadClass {
#define GST_RPAD_FILTER(pad) (((GstRealPad *)(pad))->filter) #define GST_RPAD_FILTER(pad) (((GstRealPad *)(pad))->filter)
#define GST_RPAD_APPFILTER(pad) (((GstRealPad *)(pad))->appfilter) #define GST_RPAD_APPFILTER(pad) (((GstRealPad *)(pad))->appfilter)
#define GST_RPAD_PEER(pad) (((GstRealPad *)(pad))->peer) #define GST_RPAD_PEER(pad) (((GstRealPad *)(pad))->peer)
#define GST_RPAD_BUFPEN(pad) (((GstRealPad *)(pad))->bufpen)
#define GST_RPAD_SCHED(pad) (((GstRealPad *)(pad))->sched)
#define GST_RPAD_CHAINFUNC(pad) (((GstRealPad *)(pad))->chainfunc) #define GST_RPAD_CHAINFUNC(pad) (((GstRealPad *)(pad))->chainfunc)
#define GST_RPAD_CHAINHANDLER(pad) (((GstRealPad *)(pad))->chainhandler) #define GST_RPAD_CHAINHANDLER(pad) (((GstRealPad *)(pad))->chainhandler)
#define GST_RPAD_GETFUNC(pad) (((GstRealPad *)(pad))->getfunc) #define GST_RPAD_GETFUNC(pad) (((GstRealPad *)(pad))->getfunc)
@ -394,9 +389,7 @@ void gst_pad_set_parent (GstPad *pad, GstElement *parent);
GstElement* gst_pad_get_parent (GstPad *pad); GstElement* gst_pad_get_parent (GstPad *pad);
GstElement* gst_pad_get_real_parent (GstPad *pad); GstElement* gst_pad_get_real_parent (GstPad *pad);
void gst_pad_set_scheduler (GstPad *pad, GstScheduler *sched);
GstScheduler* gst_pad_get_scheduler (GstPad *pad); GstScheduler* gst_pad_get_scheduler (GstPad *pad);
void gst_pad_unset_scheduler (GstPad *pad);
void gst_pad_add_ghost_pad (GstPad *pad, GstPad *ghostpad); void gst_pad_add_ghost_pad (GstPad *pad, GstPad *ghostpad);
void gst_pad_remove_ghost_pad (GstPad *pad, GstPad *ghostpad); void gst_pad_remove_ghost_pad (GstPad *pad, GstPad *ghostpad);
@ -446,7 +439,6 @@ void gst_pad_push (GstPad *pad, GstBuffer *buf);
GstBuffer* gst_pad_pull (GstPad *pad); GstBuffer* gst_pad_pull (GstPad *pad);
gboolean gst_pad_send_event (GstPad *pad, GstEvent *event); gboolean gst_pad_send_event (GstPad *pad, GstEvent *event);
gboolean gst_pad_event_default (GstPad *pad, GstEvent *event); gboolean gst_pad_event_default (GstPad *pad, GstEvent *event);
GstBuffer* gst_pad_peek (GstPad *pad);
GstPad* gst_pad_select (GList *padlist); GstPad* gst_pad_select (GList *padlist);
GstPad* gst_pad_selectv (GstPad *pad, ...); GstPad* gst_pad_selectv (GstPad *pad, ...);

View file

@ -394,7 +394,7 @@ restart:
if (queue->interrupt) { if (queue->interrupt) {
GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "interrupted!!"); GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "interrupted!!");
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
if (gst_scheduler_interrupt (GST_RPAD_SCHED (queue->sinkpad), GST_ELEMENT (queue))) if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad), GST_ELEMENT (queue)))
return; return;
/* if we got here bacause we were unlocked after a flush, we don't need /* if we got here bacause we were unlocked after a flush, we don't need
* to add the buffer to the queue again */ * to add the buffer to the queue again */
@ -487,7 +487,7 @@ restart:
if (queue->interrupt) { if (queue->interrupt) {
GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "interrupted!!"); GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "interrupted!!");
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
if (gst_scheduler_interrupt (GST_RPAD_SCHED (queue->srcpad), GST_ELEMENT (queue))) if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad), GST_ELEMENT (queue)))
return NULL; return NULL;
goto restart; goto restart;
} }

View file

@ -211,6 +211,8 @@ gst_scheduler_add_element (GstScheduler *sched, GstElement *element)
GST_DEBUG (GST_CAT_CLOCK, "added clock receiver %s", GST_ELEMENT_NAME (element)); GST_DEBUG (GST_CAT_CLOCK, "added clock receiver %s", GST_ELEMENT_NAME (element));
} }
gst_element_set_scheduler (element, sched);
if (CLASS (sched)->add_element) if (CLASS (sched)->add_element)
CLASS (sched)->add_element (sched, element); CLASS (sched)->add_element (sched, element);
} }
@ -225,24 +227,16 @@ gst_scheduler_add_element (GstScheduler *sched, GstElement *element)
void void
gst_scheduler_remove_element (GstScheduler *sched, GstElement *element) gst_scheduler_remove_element (GstScheduler *sched, GstElement *element)
{ {
GList *pads;
g_return_if_fail (GST_IS_SCHEDULER (sched)); g_return_if_fail (GST_IS_SCHEDULER (sched));
g_return_if_fail (GST_IS_ELEMENT (element)); g_return_if_fail (GST_IS_ELEMENT (element));
sched->clock_providers = g_list_remove (sched->clock_providers, element); sched->clock_providers = g_list_remove (sched->clock_providers, element);
sched->clock_receivers = g_list_remove (sched->clock_receivers, element); sched->clock_receivers = g_list_remove (sched->clock_receivers, element);
gst_element_set_scheduler (element, NULL);
if (CLASS (sched)->remove_element) if (CLASS (sched)->remove_element)
CLASS (sched)->remove_element (sched, element); CLASS (sched)->remove_element (sched, element);
for (pads = element->pads; pads; pads = pads->next) {
GstPad *pad = GST_PAD (pads->data);
if (GST_IS_REAL_PAD (pad)) {
gst_pad_unset_scheduler (GST_PAD (pads->data));
}
}
} }
/** /**

View file

@ -27,8 +27,8 @@
typedef struct _GstSchedulerChain GstSchedulerChain; typedef struct _GstSchedulerChain GstSchedulerChain;
#define GST_PAD_THREADSTATE(pad) (cothread*) (GST_PAD_CAST (pad)->sched_private)
#define GST_ELEMENT_THREADSTATE(elem) (cothread*) (GST_ELEMENT_CAST (elem)->sched_private) #define GST_ELEMENT_THREADSTATE(elem) (cothread*) (GST_ELEMENT_CAST (elem)->sched_private)
#define GST_RPAD_BUFPEN(pad) (GstBuffer*) (GST_REAL_PAD_CAST(pad)->sched_private)
#define GST_ELEMENT_COTHREAD_STOPPING GST_ELEMENT_SCHEDULER_PRIVATE1 #define GST_ELEMENT_COTHREAD_STOPPING GST_ELEMENT_SCHEDULER_PRIVATE1
#define GST_ELEMENT_IS_COTHREAD_STOPPING(element) GST_FLAG_IS_SET((element), GST_ELEMENT_COTHREAD_STOPPING) #define GST_ELEMENT_IS_COTHREAD_STOPPING(element) GST_FLAG_IS_SET((element), GST_ELEMENT_COTHREAD_STOPPING)
@ -527,7 +527,7 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain)
GList *elements; GList *elements;
GstElement *element; GstElement *element;
cothread_func wrapper_function; cothread_func wrapper_function;
GList *pads; const GList *pads;
GstPad *pad; GstPad *pad;
GST_DEBUG (GST_CAT_SCHEDULING, "chain is using COTHREADS"); GST_DEBUG (GST_CAT_SCHEDULING, "chain is using COTHREADS");
@ -623,7 +623,6 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain)
GST_DEBUG_PAD_NAME (peerpad)); GST_DEBUG_PAD_NAME (peerpad));
GST_RPAD_GETHANDLER (peerpad) = GST_RPAD_GETFUNC (peerpad); GST_RPAD_GETHANDLER (peerpad) = GST_RPAD_GETFUNC (peerpad);
} }
gst_pad_set_scheduler (peerpad, GST_SCHEDULER (chain->sched));
} }
} }
} }
@ -1058,9 +1057,6 @@ gst_basic_scheduler_add_element (GstScheduler * sched, GstElement * element)
if (!GST_IS_REAL_PAD (pad)) if (!GST_IS_REAL_PAD (pad))
continue; continue;
/* set the pad's sched pointer */
gst_pad_set_scheduler (pad, sched);
/* if the peer element exists and is a candidate */ /* if the peer element exists and is a candidate */
if (GST_PAD_PEER (pad)) { if (GST_PAD_PEER (pad)) {
peerelement = GST_PAD_PARENT (GST_PAD_PEER (pad)); peerelement = GST_PAD_PARENT (GST_PAD_PEER (pad));
@ -1287,9 +1283,6 @@ gst_basic_scheduler_pad_select (GstScheduler * sched, GList * padlist)
while (padlist2) { while (padlist2) {
pad = GST_PAD (padlist2->data); pad = GST_PAD (padlist2->data);
if (gst_pad_peek (pad)) {
return pad;
}
padlist2 = g_list_next (padlist2); padlist2 = g_list_next (padlist2);
} }

View file

@ -27,8 +27,8 @@
typedef struct _GstSchedulerChain GstSchedulerChain; typedef struct _GstSchedulerChain GstSchedulerChain;
#define GST_PAD_THREADSTATE(pad) (cothread*) (GST_PAD_CAST (pad)->sched_private)
#define GST_ELEMENT_THREADSTATE(elem) (cothread*) (GST_ELEMENT_CAST (elem)->sched_private) #define GST_ELEMENT_THREADSTATE(elem) (cothread*) (GST_ELEMENT_CAST (elem)->sched_private)
#define GST_RPAD_BUFPEN(pad) (GstBuffer*) (GST_REAL_PAD_CAST(pad)->sched_private)
#define GST_ELEMENT_COTHREAD_STOPPING GST_ELEMENT_SCHEDULER_PRIVATE1 #define GST_ELEMENT_COTHREAD_STOPPING GST_ELEMENT_SCHEDULER_PRIVATE1
#define GST_ELEMENT_IS_COTHREAD_STOPPING(element) GST_FLAG_IS_SET((element), GST_ELEMENT_COTHREAD_STOPPING) #define GST_ELEMENT_IS_COTHREAD_STOPPING(element) GST_FLAG_IS_SET((element), GST_ELEMENT_COTHREAD_STOPPING)
@ -287,7 +287,7 @@ static gboolean
gst_fast_scheduler_cothreaded_element (GstBin * bin, GstElement *element) gst_fast_scheduler_cothreaded_element (GstBin * bin, GstElement *element)
{ {
cothread_func wrapper_function; cothread_func wrapper_function;
GList *pads; const GList *pads;
GstFastScheduler *sched; GstFastScheduler *sched;
GST_DEBUG (GST_CAT_SCHEDULING, "element is using COTHREADS"); GST_DEBUG (GST_CAT_SCHEDULING, "element is using COTHREADS");
@ -344,7 +344,7 @@ gst_fast_scheduler_event_proxy (GstPad *pad, GstBuffer *buf)
static gboolean static gboolean
gst_fast_scheduler_chained_element (GstBin *bin, GstElement *element) { gst_fast_scheduler_chained_element (GstBin *bin, GstElement *element) {
GList *pads; const GList *pads;
GstPad *pad; GstPad *pad;
GST_DEBUG (GST_CAT_SCHEDULING,"chain entered"); GST_DEBUG (GST_CAT_SCHEDULING,"chain entered");
@ -712,9 +712,6 @@ gst_fast_scheduler_add_element (GstScheduler * sched, GstElement * element)
if (!GST_IS_REAL_PAD (pad)) if (!GST_IS_REAL_PAD (pad))
continue; continue;
/* set the pad's sched pointer */
gst_pad_set_scheduler (pad, sched);
/* if the peer element exists and is a candidate */ /* if the peer element exists and is a candidate */
if (GST_PAD_PEER (pad)) { if (GST_PAD_PEER (pad)) {
peerelement = GST_PAD_PARENT (GST_PAD_PEER (pad)); peerelement = GST_PAD_PARENT (GST_PAD_PEER (pad));
@ -993,7 +990,7 @@ gst_fast_scheduler_iterate (GstScheduler * sched)
else { else {
GstElement *entry = chain->entry; GstElement *entry = chain->entry;
if (entry) { if (entry) {
GList *pads = gst_element_get_pad_list (entry); const GList *pads = gst_element_get_pad_list (entry);
GST_DEBUG (GST_CAT_DATAFLOW, "starting chained iteration"); GST_DEBUG (GST_CAT_DATAFLOW, "starting chained iteration");

View file

@ -61,7 +61,6 @@ gst_aggregator_sched_get_type (void)
static GType aggregator_sched_type = 0; static GType aggregator_sched_type = 0;
static GEnumValue aggregator_sched[] = { static GEnumValue aggregator_sched[] = {
{ AGGREGATOR_LOOP, "1", "Loop Based"}, { AGGREGATOR_LOOP, "1", "Loop Based"},
{ AGGREGATOR_LOOP_PEEK, "2", "Loop Based Peek"},
{ AGGREGATOR_LOOP_SELECT, "3", "Loop Based Select"}, { AGGREGATOR_LOOP_SELECT, "3", "Loop Based Select"},
{ AGGREGATOR_CHAIN, "4", "Chain Based"}, { AGGREGATOR_CHAIN, "4", "Chain Based"},
{0, NULL, NULL}, {0, NULL, NULL},
@ -286,26 +285,16 @@ gst_aggregator_loop (GstElement *element)
aggregator = GST_AGGREGATOR (element); aggregator = GST_AGGREGATOR (element);
if (aggregator->sched == AGGREGATOR_LOOP || if (aggregator->sched == AGGREGATOR_LOOP) {
aggregator->sched == AGGREGATOR_LOOP_PEEK) {
GList *pads = aggregator->sinkpads; GList *pads = aggregator->sinkpads;
while (pads) { while (pads) {
GstPad *pad = GST_PAD (pads->data); GstPad *pad = GST_PAD (pads->data);
pads = g_list_next (pads); pads = g_list_next (pads);
if (aggregator->sched == AGGREGATOR_LOOP_PEEK) { buf = gst_pad_pull (pad);
buf = gst_pad_peek (pad); debug = "loop";
if (buf == NULL)
continue;
g_assert (buf == gst_pad_pull (pad));
debug = "loop_peek";
}
else {
buf = gst_pad_pull (pad);
debug = "loop";
}
gst_aggregator_push (aggregator, pad, buf, debug); gst_aggregator_push (aggregator, pad, buf, debug);
} }
} }

View file

@ -35,7 +35,6 @@ extern GstElementDetails gst_aggregator_details;
typedef enum { typedef enum {
AGGREGATOR_LOOP = 1, AGGREGATOR_LOOP = 1,
AGGREGATOR_LOOP_PEEK,
AGGREGATOR_LOOP_SELECT, AGGREGATOR_LOOP_SELECT,
AGGREGATOR_CHAIN, AGGREGATOR_CHAIN,
} GstAggregatorSchedType; } GstAggregatorSchedType;

View file

@ -308,6 +308,7 @@ gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ)
srcpad = gst_pad_new_from_template (templ, name); srcpad = gst_pad_new_from_template (templ, name);
gst_element_add_pad (GST_ELEMENT (fakesrc), srcpad); gst_element_add_pad (GST_ELEMENT (fakesrc), srcpad);
gst_fakesrc_update_functions (fakesrc);
g_free (name); g_free (name);
@ -783,7 +784,7 @@ static void
gst_fakesrc_loop(GstElement *element) gst_fakesrc_loop(GstElement *element)
{ {
GstFakeSrc *src; GstFakeSrc *src;
GList *pads; const GList *pads;
g_return_if_fail(element != NULL); g_return_if_fail(element != NULL);
g_return_if_fail(GST_IS_FAKESRC(element)); g_return_if_fail(GST_IS_FAKESRC(element));

View file

@ -394,7 +394,7 @@ restart:
if (queue->interrupt) { if (queue->interrupt) {
GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "interrupted!!"); GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "interrupted!!");
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
if (gst_scheduler_interrupt (GST_RPAD_SCHED (queue->sinkpad), GST_ELEMENT (queue))) if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad), GST_ELEMENT (queue)))
return; return;
/* if we got here bacause we were unlocked after a flush, we don't need /* if we got here bacause we were unlocked after a flush, we don't need
* to add the buffer to the queue again */ * to add the buffer to the queue again */
@ -487,7 +487,7 @@ restart:
if (queue->interrupt) { if (queue->interrupt) {
GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "interrupted!!"); GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "interrupted!!");
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
if (gst_scheduler_interrupt (GST_RPAD_SCHED (queue->srcpad), GST_ELEMENT (queue))) if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad), GST_ELEMENT (queue)))
return NULL; return NULL;
goto restart; goto restart;
} }

View file

@ -122,7 +122,7 @@ static GstPadConnectReturn
gst_tee_sinkconnect (GstPad *pad, GstCaps *caps) gst_tee_sinkconnect (GstPad *pad, GstCaps *caps)
{ {
GstTee *tee; GstTee *tee;
GList *pads; const GList *pads;
GstPadConnectReturn set_retval; GstPadConnectReturn set_retval;
tee = GST_TEE (gst_pad_get_parent (pad)); tee = GST_TEE (gst_pad_get_parent (pad));
@ -177,8 +177,8 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar
gchar *name; gchar *name;
GstPad *srcpad; GstPad *srcpad;
GstTee *tee; GstTee *tee;
int i = 0; gint i = 0;
GList *pads; const GList *pads;
g_return_val_if_fail (GST_IS_TEE (element), NULL); g_return_val_if_fail (GST_IS_TEE (element), NULL);
@ -196,7 +196,7 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar
while (!name) while (!name)
{ {
name = g_strdup_printf ("src%d", i); name = g_strdup_printf ("src%d", i);
if (g_list_find_custom (pads, (gconstpointer) name, name_pad_compare) != NULL) if (g_list_find_custom ((GList *)pads, (gconstpointer) name, name_pad_compare) != NULL)
{ {
/* this name is taken, use the next one */ /* this name is taken, use the next one */
++i; ++i;
@ -279,7 +279,7 @@ static void
gst_tee_chain (GstPad *pad, GstBuffer *buf) gst_tee_chain (GstPad *pad, GstBuffer *buf)
{ {
GstTee *tee; GstTee *tee;
GList *pads; const GList *pads;
g_return_if_fail (pad != NULL); g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad)); g_return_if_fail (GST_IS_PAD (pad));

View file

@ -4,7 +4,8 @@
int main(int argc,char *argv[]) { int main(int argc,char *argv[]) {
xmlDocPtr doc; xmlDocPtr doc;
xmlNodePtr factorynode, padnode, argnode, optionnode; xmlNodePtr factorynode, padnode, argnode, optionnode;
GList *plugins, *features, *padtemplates, *pads; GList *plugins, *features, *padtemplates;
const GList *pads;
GstElement *element; GstElement *element;
GstPad *pad; GstPad *pad;
GstPadTemplate *padtemplate; GstPadTemplate *padtemplate;