mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 12:32:29 +00:00
gst/gstelement.c: Better pad activation code: Reset the collect value too on resync.
Original commit message from CVS: * gst/gstelement.c: (activate_pads), (iterator_activate_fold_with_resync), (gst_element_pads_activate): Better pad activation code: Reset the collect value too on resync. Add some comments.
This commit is contained in:
parent
9d81fe82c7
commit
8b23eed267
2 changed files with 57 additions and 45 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2006-07-09 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/gstelement.c: (activate_pads),
|
||||||
|
(iterator_activate_fold_with_resync), (gst_element_pads_activate):
|
||||||
|
Better pad activation code: Reset the collect value too on resync.
|
||||||
|
Add some comments.
|
||||||
|
|
||||||
2006-07-09 Wim Taymans <wim@fluendo.com>
|
2006-07-09 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/gstpad.c: (gst_pad_init), (gst_pad_activate_pull),
|
* gst/gstpad.c: (gst_pad_init), (gst_pad_activate_pull),
|
||||||
|
|
|
@ -2252,8 +2252,10 @@ invalid_return:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* gst_iterator_fold functions for pads_activate */
|
/* gst_iterator_fold functions for pads_activate
|
||||||
|
* Note how we don't stop the iterator when we fail an activation. This is
|
||||||
|
* probably a FIXME since when one pad activation fails, we don't want to
|
||||||
|
* continue our state change. */
|
||||||
static gboolean
|
static gboolean
|
||||||
activate_pads (GstPad * pad, GValue * ret, gboolean * active)
|
activate_pads (GstPad * pad, GValue * ret, gboolean * active)
|
||||||
{
|
{
|
||||||
|
@ -2262,67 +2264,70 @@ activate_pads (GstPad * pad, GValue * ret, gboolean * active)
|
||||||
else if (!*active)
|
else if (!*active)
|
||||||
gst_pad_set_caps (pad, NULL);
|
gst_pad_set_caps (pad, NULL);
|
||||||
|
|
||||||
|
/* unref the object that was reffed for us by _fold */
|
||||||
gst_object_unref (pad);
|
gst_object_unref (pad);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns false on error or early cutout of the fold, true otherwise */
|
/* returns false on error or early cutout (will never happen because the fold
|
||||||
|
* function always returns TRUE, see FIXME above) of the fold, true if all
|
||||||
|
* pads in @iter were (de)activated successfully. */
|
||||||
static gboolean
|
static gboolean
|
||||||
iterator_fold_with_resync (GstIterator * iter, GstIteratorFoldFunction func,
|
iterator_activate_fold_with_resync (GstIterator * iter, gpointer user_data)
|
||||||
GValue * ret, gpointer user_data)
|
|
||||||
{
|
{
|
||||||
GstIteratorResult ires;
|
GstIteratorResult ires;
|
||||||
gboolean res = TRUE;
|
GValue ret = { 0 };
|
||||||
|
|
||||||
while (1) {
|
|
||||||
ires = gst_iterator_fold (iter, func, ret, user_data);
|
|
||||||
|
|
||||||
switch (ires) {
|
|
||||||
case GST_ITERATOR_RESYNC:
|
|
||||||
gst_iterator_resync (iter);
|
|
||||||
break;
|
|
||||||
case GST_ITERATOR_DONE:
|
|
||||||
res = TRUE;
|
|
||||||
goto done;
|
|
||||||
default:
|
|
||||||
res = FALSE;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* is called with STATE_LOCK
|
|
||||||
*/
|
|
||||||
static gboolean
|
|
||||||
gst_element_pads_activate (GstElement * element, gboolean active)
|
|
||||||
{
|
|
||||||
GValue ret = { 0, };
|
|
||||||
GstIterator *iter;
|
|
||||||
gboolean fold_ok;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (element, "pads_activate with active %d", active);
|
|
||||||
|
|
||||||
/* no need to unset this later, it's just a boolean */
|
/* no need to unset this later, it's just a boolean */
|
||||||
g_value_init (&ret, G_TYPE_BOOLEAN);
|
g_value_init (&ret, G_TYPE_BOOLEAN);
|
||||||
g_value_set_boolean (&ret, TRUE);
|
g_value_set_boolean (&ret, TRUE);
|
||||||
|
|
||||||
iter = gst_element_iterate_src_pads (element);
|
while (1) {
|
||||||
|
ires = gst_iterator_fold (iter, (GstIteratorFoldFunction) activate_pads,
|
||||||
|
&ret, user_data);
|
||||||
|
switch (ires) {
|
||||||
|
case GST_ITERATOR_RESYNC:
|
||||||
|
/* need to reset the result again */
|
||||||
|
g_value_set_boolean (&ret, TRUE);
|
||||||
|
gst_iterator_resync (iter);
|
||||||
|
break;
|
||||||
|
case GST_ITERATOR_DONE:
|
||||||
|
/* all pads iterated, return collected value */
|
||||||
|
goto done;
|
||||||
|
default:
|
||||||
|
/* iterator returned _ERROR or premature end with _OK,
|
||||||
|
* mark an error and exit */
|
||||||
|
g_value_set_boolean (&ret, FALSE);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
done:
|
||||||
|
/* return collected value */
|
||||||
|
return g_value_get_boolean (&ret);
|
||||||
|
}
|
||||||
|
|
||||||
fold_ok = iterator_fold_with_resync
|
/* is called with STATE_LOCK
|
||||||
(iter, (GstIteratorFoldFunction) activate_pads, &ret, &active);
|
*
|
||||||
|
* Pads are activated from source pads to sinkpads.
|
||||||
|
*/
|
||||||
|
static gboolean
|
||||||
|
gst_element_pads_activate (GstElement * element, gboolean active)
|
||||||
|
{
|
||||||
|
GstIterator *iter;
|
||||||
|
gboolean res;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (element, "pads_activate with active %d", active);
|
||||||
|
|
||||||
|
iter = gst_element_iterate_src_pads (element);
|
||||||
|
res = iterator_activate_fold_with_resync (iter, &active);
|
||||||
gst_iterator_free (iter);
|
gst_iterator_free (iter);
|
||||||
if (G_UNLIKELY (!fold_ok || !g_value_get_boolean (&ret)))
|
if (G_UNLIKELY (!res))
|
||||||
goto src_failed;
|
goto src_failed;
|
||||||
|
|
||||||
iter = gst_element_iterate_sink_pads (element);
|
iter = gst_element_iterate_sink_pads (element);
|
||||||
|
res = iterator_activate_fold_with_resync (iter, &active);
|
||||||
fold_ok = iterator_fold_with_resync
|
|
||||||
(iter, (GstIteratorFoldFunction) activate_pads, &ret, &active);
|
|
||||||
gst_iterator_free (iter);
|
gst_iterator_free (iter);
|
||||||
if (G_UNLIKELY (!fold_ok || !g_value_get_boolean (&ret)))
|
if (G_UNLIKELY (!res))
|
||||||
goto sink_failed;
|
goto sink_failed;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (element, "pads_activate successful");
|
GST_DEBUG_OBJECT (element, "pads_activate successful");
|
||||||
|
|
Loading…
Reference in a new issue