summaryrefslogtreecommitdiff
path: root/gst/gstghostpad.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2011-11-21 13:29:05 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2011-11-21 13:29:05 +0100
commit2f1ed6533946e19e1801be0a3d7cc628f056c26c (patch)
treed67c5e3e4aacb8ec779bdd2fef53cca158d56b98 /gst/gstghostpad.c
parent9e3aa102d7fa3ebcfedb5e86721ab7701b797196 (diff)
downloadgstreamer-2f1ed6533946e19e1801be0a3d7cc628f056c26c.tar.gz
pad: Merge pad mode activation functions
Add the pad mode to the activate function so that we can reuse the same function for all activation modes. This makes the core logic smaller and allows for some elements to make their activation code easier. It would allow us to add more scheduling modes later without having to add more activate functions.
Diffstat (limited to 'gst/gstghostpad.c')
-rw-r--r--gst/gstghostpad.c142
1 files changed, 75 insertions, 67 deletions
diff --git a/gst/gstghostpad.c b/gst/gstghostpad.c
index 6ccc02b864..8ec724d6f5 100644
--- a/gst/gstghostpad.c
+++ b/gst/gstghostpad.c
@@ -458,61 +458,31 @@ G_DEFINE_TYPE (GstGhostPad, gst_ghost_pad, GST_TYPE_PROXY_PAD);
static void gst_ghost_pad_dispose (GObject * object);
-/**
- * gst_ghost_pad_internal_activate_push_default:
- * @pad: the #GstPad to activate or deactivate.
- * @parent: the parent of @pad or NULL
- * @active: whether the pad should be active or not.
- *
- * Invoke the default activate push function of a proxy pad that is
- * owned by a ghost pad.
- *
- * Returns: %TRUE if the operation was successful.
- *
- * Since: 0.10.36
- */
-gboolean
+static gboolean
gst_ghost_pad_internal_activate_push_default (GstPad * pad, GstObject * parent,
gboolean active)
{
gboolean ret;
GstPad *other;
- g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
-
GST_LOG_OBJECT (pad, "%sactivate push on %s:%s, we're ok",
(active ? "" : "de"), GST_DEBUG_PAD_NAME (pad));
/* in both cases (SRC and SINK) we activate just the internal pad. The targets
* will be activated later (or already in case of a ghost sinkpad). */
other = GST_PROXY_PAD_INTERNAL (pad);
- ret = gst_pad_activate_push (other, active);
+ ret = gst_pad_activate_mode (other, GST_PAD_MODE_PUSH, active);
return ret;
}
-/**
- * gst_ghost_pad_internal_activate_pull_default:
- * @pad: the #GstPad to activate or deactivate.
- * @parent: the parent of @pad or NULL
- * @active: whether the pad should be active or not.
- *
- * Invoke the default activate pull function of a proxy pad that is
- * owned by a ghost pad.
- *
- * Returns: %TRUE if the operation was successful.
- *
- * Since: 0.10.36
- */
-gboolean
+static gboolean
gst_ghost_pad_internal_activate_pull_default (GstPad * pad, GstObject * parent,
gboolean active)
{
gboolean ret;
GstPad *other;
- g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
-
GST_LOG_OBJECT (pad, "%sactivate pull on %s:%s", (active ? "" : "de"),
GST_DEBUG_PAD_NAME (pad));
@@ -524,12 +494,12 @@ gst_ghost_pad_internal_activate_pull_default (GstPad * pad, GstObject * parent,
* further upstream */
GST_LOG_OBJECT (pad, "pad is src, activate internal");
other = GST_PROXY_PAD_INTERNAL (pad);
- ret = gst_pad_activate_pull (other, active);
+ ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
} else if (G_LIKELY ((other = gst_pad_get_peer (pad)))) {
/* We are SINK, the ghostpad is SRC, we propagate the activation upstream
* since we hold a pointer to the upstream peer. */
GST_LOG_OBJECT (pad, "activating peer");
- ret = gst_pad_activate_pull (other, active);
+ ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
gst_object_unref (other);
} else {
/* this is failure, we can't activate pull if there is no peer */
@@ -541,18 +511,41 @@ gst_ghost_pad_internal_activate_pull_default (GstPad * pad, GstObject * parent,
}
/**
- * gst_ghost_pad_activate_push_default:
+ * gst_ghost_pad_internal_activate_mode_default:
* @pad: the #GstPad to activate or deactivate.
* @parent: the parent of @pad or NULL
+ * @mode: the requested activation mode
* @active: whether the pad should be active or not.
*
- * Invoke the default activate push function of a ghost pad.
+ * Invoke the default activate mode function of a proxy pad that is
+ * owned by a ghost pad.
*
* Returns: %TRUE if the operation was successful.
- *
- * Since: 0.10.36
*/
gboolean
+gst_ghost_pad_internal_activate_mode_default (GstPad * pad, GstObject * parent,
+ GstPadMode mode, gboolean active)
+{
+ gboolean res;
+
+ g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
+
+ switch (mode) {
+ case GST_PAD_MODE_PULL:
+ res = gst_ghost_pad_internal_activate_pull_default (pad, parent, active);
+ break;
+ case GST_PAD_MODE_PUSH:
+ res = gst_ghost_pad_internal_activate_push_default (pad, parent, active);
+ break;
+ default:
+ GST_LOG_OBJECT (pad, "unknown activation mode %d");
+ res = FALSE;
+ break;
+ }
+ return res;
+}
+
+static gboolean
gst_ghost_pad_activate_push_default (GstPad * pad, GstObject * parent,
gboolean active)
{
@@ -566,32 +559,18 @@ gst_ghost_pad_activate_push_default (GstPad * pad, GstObject * parent,
/* just activate the internal pad */
other = GST_PROXY_PAD_INTERNAL (pad);
- ret = gst_pad_activate_push (other, active);
+ ret = gst_pad_activate_mode (other, GST_PAD_MODE_PUSH, active);
return ret;
}
-/**
- * gst_ghost_pad_activate_pull_default:
- * @pad: the #GstPad to activate or deactivate.
- * @parent: the parent of @pad or NULL
- * @active: whether the pad should be active or not.
- *
- * Invoke the default activate pull function of a ghost pad.
- *
- * Returns: %TRUE if the operation was successful.
- *
- * Since: 0.10.36
- */
-gboolean
+static gboolean
gst_ghost_pad_activate_pull_default (GstPad * pad, GstObject * parent,
gboolean active)
{
gboolean ret;
GstPad *other;
- g_return_val_if_fail (GST_IS_GHOST_PAD (pad), FALSE);
-
GST_LOG_OBJECT (pad, "%sactivate pull on %s:%s", (active ? "" : "de"),
GST_DEBUG_PAD_NAME (pad));
@@ -601,12 +580,12 @@ gst_ghost_pad_activate_pull_default (GstPad * pad, GstObject * parent,
* upstream */
GST_LOG_OBJECT (pad, "pad is src, activate internal");
other = GST_PROXY_PAD_INTERNAL (pad);
- ret = gst_pad_activate_pull (other, active);
+ ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
} else if (G_LIKELY ((other = gst_pad_get_peer (pad)))) {
/* We are SINK and activated by the internal pad, propagate activation
* upstream because we hold a ref to the upstream peer */
GST_LOG_OBJECT (pad, "activating peer");
- ret = gst_pad_activate_pull (other, active);
+ ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
gst_object_unref (other);
} else {
/* no peer, we fail */
@@ -618,6 +597,40 @@ gst_ghost_pad_activate_pull_default (GstPad * pad, GstObject * parent,
}
/**
+ * gst_ghost_pad_activate_mode_default:
+ * @pad: the #GstPad to activate or deactivate.
+ * @parent: the parent of @pad or NULL
+ * @mode: the requested activation mode
+ * @active: whether the pad should be active or not.
+ *
+ * Invoke the default activate mode function of a ghost pad.
+ *
+ * Returns: %TRUE if the operation was successful.
+ */
+gboolean
+gst_ghost_pad_activate_mode_default (GstPad * pad, GstObject * parent,
+ GstPadMode mode, gboolean active)
+{
+ gboolean res;
+
+ g_return_val_if_fail (GST_IS_GHOST_PAD (pad), FALSE);
+
+ switch (mode) {
+ case GST_PAD_MODE_PULL:
+ res = gst_ghost_pad_activate_pull_default (pad, parent, active);
+ break;
+ case GST_PAD_MODE_PUSH:
+ res = gst_ghost_pad_activate_push_default (pad, parent, active);
+ break;
+ default:
+ GST_LOG_OBJECT (pad, "unknown activation mode %d");
+ res = FALSE;
+ break;
+ }
+ return res;
+}
+
+/**
* gst_ghost_pad_link_default:
* @pad: the #GstPad to link.
* @peer: the #GstPad peer
@@ -687,10 +700,8 @@ gst_ghost_pad_init (GstGhostPad * pad)
GST_GHOST_PAD_PRIVATE (pad) = G_TYPE_INSTANCE_GET_PRIVATE (pad,
GST_TYPE_GHOST_PAD, GstGhostPadPrivate);
- gst_pad_set_activatepull_function (GST_PAD_CAST (pad),
- gst_ghost_pad_activate_pull_default);
- gst_pad_set_activatepush_function (GST_PAD_CAST (pad),
- gst_ghost_pad_activate_push_default);
+ gst_pad_set_activatemode_function (GST_PAD_CAST (pad),
+ gst_ghost_pad_activate_mode_default);
}
static void
@@ -721,8 +732,7 @@ gst_ghost_pad_dispose (GObject * object)
GST_OBJECT_LOCK (pad);
internal = GST_PROXY_PAD_INTERNAL (pad);
- gst_pad_set_activatepull_function (internal, NULL);
- gst_pad_set_activatepush_function (internal, NULL);
+ gst_pad_set_activatemode_function (internal, NULL);
/* disposes of the internal pad, since the ghostpad is the only possible object
* that has a refcount on the internal pad. */
@@ -821,10 +831,8 @@ gst_ghost_pad_construct (GstGhostPad * gpad)
GST_PROXY_PAD_INTERNAL (internal) = pad;
/* special activation functions for the internal pad */
- gst_pad_set_activatepull_function (internal,
- gst_ghost_pad_internal_activate_pull_default);
- gst_pad_set_activatepush_function (internal,
- gst_ghost_pad_internal_activate_push_default);
+ gst_pad_set_activatemode_function (internal,
+ gst_ghost_pad_internal_activate_mode_default);
GST_OBJECT_UNLOCK (pad);