mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-04 22:48:49 +00:00
fixes 123774 - setting state on a bin should set state on children as well
Original commit message from CVS: fixes 123774 - setting state on a bin should set state on children as well
This commit is contained in:
parent
683546fcb5
commit
b645d7ab8c
7 changed files with 74 additions and 61 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
||||||
|
2004-07-09 Thomas Vander Stichele <thomas (at) apestaart (dot) org>
|
||||||
|
|
||||||
|
* docs/gst/tmpl/gstelement.sgml:
|
||||||
|
* docs/gst/tmpl/gsttypes.sgml:
|
||||||
|
* gst/gstbin.c: (gst_bin_change_state):
|
||||||
|
* gst/gstelement.c: (gst_element_set_state),
|
||||||
|
(gst_element_change_state):
|
||||||
|
rework so that for bins we try to set the state on all children
|
||||||
|
as well even if the bin is in the correct state already.
|
||||||
|
change while to do so at least one iteration is done.
|
||||||
|
For regular elements, we fall back to the previous behaviour for
|
||||||
|
now since we first need a new plugins release.
|
||||||
|
* testsuite/states/parent.c: (main):
|
||||||
|
test for this case
|
||||||
|
Fixes #123774
|
||||||
|
|
||||||
2004-07-09 Thomas Vander Stichele <thomas (at) apestaart (dot) org>
|
2004-07-09 Thomas Vander Stichele <thomas (at) apestaart (dot) org>
|
||||||
|
|
||||||
* gst/gstqueue.c: (gst_queue_class_init), (gst_queue_finalize),
|
* gst/gstqueue.c: (gst_queue_class_init), (gst_queue_finalize),
|
||||||
|
|
|
@ -76,8 +76,6 @@ and gst_element_set_clock(). You can wait for the clock to reach a given
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@:
|
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@gstelement: the object which received the signal.
|
||||||
|
|
||||||
<!-- ##### SIGNAL GstElement::error ##### -->
|
<!-- ##### SIGNAL GstElement::error ##### -->
|
||||||
|
@ -85,11 +83,6 @@ and gst_element_set_clock(). You can wait for the clock to reach a given
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@:
|
|
||||||
@:
|
|
||||||
@:
|
|
||||||
@:
|
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@gstelement: the object which received the signal.
|
||||||
@arg1:
|
@arg1:
|
||||||
@arg2:
|
@arg2:
|
||||||
|
@ -100,10 +93,6 @@ and gst_element_set_clock(). You can wait for the clock to reach a given
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@:
|
|
||||||
@:
|
|
||||||
@:
|
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@gstelement: the object which received the signal.
|
||||||
@arg1:
|
@arg1:
|
||||||
@arg2:
|
@arg2:
|
||||||
|
@ -113,9 +102,6 @@ and gst_element_set_clock(). You can wait for the clock to reach a given
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@:
|
|
||||||
@:
|
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@gstelement: the object which received the signal.
|
||||||
@arg1:
|
@arg1:
|
||||||
|
|
||||||
|
@ -124,8 +110,6 @@ and gst_element_set_clock(). You can wait for the clock to reach a given
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@:
|
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@gstelement: the object which received the signal.
|
||||||
|
|
||||||
<!-- ##### SIGNAL GstElement::pad-removed ##### -->
|
<!-- ##### SIGNAL GstElement::pad-removed ##### -->
|
||||||
|
@ -133,9 +117,6 @@ and gst_element_set_clock(). You can wait for the clock to reach a given
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@:
|
|
||||||
@:
|
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@gstelement: the object which received the signal.
|
||||||
@arg1:
|
@arg1:
|
||||||
|
|
||||||
|
@ -144,10 +125,6 @@ and gst_element_set_clock(). You can wait for the clock to reach a given
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@:
|
|
||||||
@:
|
|
||||||
@:
|
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@gstelement: the object which received the signal.
|
||||||
@arg1:
|
@arg1:
|
||||||
@arg2:
|
@arg2:
|
||||||
|
|
|
@ -127,58 +127,58 @@ template.
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@:
|
||||||
|
|
||||||
<!-- ##### SIGNAL GstElement::error ##### -->
|
<!-- ##### SIGNAL GstElement::error ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@:
|
||||||
@arg1:
|
@:
|
||||||
@arg2:
|
@:
|
||||||
@arg3:
|
@:
|
||||||
|
|
||||||
<!-- ##### SIGNAL GstElement::found-tag ##### -->
|
<!-- ##### SIGNAL GstElement::found-tag ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@:
|
||||||
@arg1:
|
@:
|
||||||
@arg2:
|
@:
|
||||||
|
|
||||||
<!-- ##### SIGNAL GstElement::new-pad ##### -->
|
<!-- ##### SIGNAL GstElement::new-pad ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@:
|
||||||
@arg1:
|
@:
|
||||||
|
|
||||||
<!-- ##### SIGNAL GstElement::no-more-pads ##### -->
|
<!-- ##### SIGNAL GstElement::no-more-pads ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@:
|
||||||
|
|
||||||
<!-- ##### SIGNAL GstElement::pad-removed ##### -->
|
<!-- ##### SIGNAL GstElement::pad-removed ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@:
|
||||||
@arg1:
|
@:
|
||||||
|
|
||||||
<!-- ##### SIGNAL GstElement::state-change ##### -->
|
<!-- ##### SIGNAL GstElement::state-change ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@gstelement: the object which received the signal.
|
@:
|
||||||
@arg1:
|
@:
|
||||||
@arg2:
|
@:
|
||||||
|
|
||||||
<!-- ##### STRUCT GstElementClass ##### -->
|
<!-- ##### STRUCT GstElementClass ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
16
gst/gstbin.c
16
gst/gstbin.c
|
@ -726,12 +726,16 @@ gst_bin_change_state (GstElement * element)
|
||||||
if (pending == GST_STATE_VOID_PENDING)
|
if (pending == GST_STATE_VOID_PENDING)
|
||||||
return GST_STATE_SUCCESS;
|
return GST_STATE_SUCCESS;
|
||||||
|
|
||||||
if (old_state == pending) {
|
/* we want to recurse into children anyway, regardless of our old
|
||||||
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element,
|
* state */
|
||||||
"old and pending state are both %s, returning",
|
/*
|
||||||
gst_element_state_get_name (pending));
|
if (old_state == pending) {
|
||||||
return GST_STATE_SUCCESS;
|
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element,
|
||||||
}
|
"old and pending state are both %s, returning",
|
||||||
|
gst_element_state_get_name (pending));
|
||||||
|
return GST_STATE_SUCCESS;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
children = bin->children;
|
children = bin->children;
|
||||||
|
|
||||||
|
|
|
@ -2725,13 +2725,22 @@ gst_element_set_state (GstElement * element, GstElementState state)
|
||||||
GstElementStateReturn return_val = GST_STATE_SUCCESS;
|
GstElementStateReturn return_val = GST_STATE_SUCCESS;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
|
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
|
||||||
|
oclass = GST_ELEMENT_GET_CLASS (element);
|
||||||
|
|
||||||
|
/* for bins, we allow calls to change_state where old == new
|
||||||
|
* for elements, too many of them break with g_assert_not_reached(),
|
||||||
|
* so weed those out first. This is done in gst-plugins CVS and can
|
||||||
|
* be fixed here after a new plugins reelase.
|
||||||
|
* FIXME: of course this file should not have ties to gstbin.h *at all*,
|
||||||
|
* but someone else added a function at the bottom using it.
|
||||||
|
* Fix this properly for 0.9 */
|
||||||
|
|
||||||
/* start with the current state */
|
/* start with the current state */
|
||||||
curpending = GST_STATE (element);
|
curpending = GST_STATE (element);
|
||||||
|
|
||||||
if (state == curpending) {
|
if (!GST_IS_BIN (element) && state == curpending) {
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
|
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
|
||||||
"element is already in requested state %s",
|
"non-bin element is already in requested state %s, returning",
|
||||||
gst_element_state_get_name (state));
|
gst_element_state_get_name (state));
|
||||||
return (GST_STATE_SUCCESS);
|
return (GST_STATE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -2740,17 +2749,11 @@ gst_element_set_state (GstElement * element, GstElementState state)
|
||||||
gst_element_state_get_name (curpending),
|
gst_element_state_get_name (curpending),
|
||||||
gst_element_state_get_name (state));
|
gst_element_state_get_name (state));
|
||||||
|
|
||||||
/* loop until the final requested state is set */
|
/* loop until the final requested state is set;
|
||||||
while (GST_STATE (element) != state
|
* loop at least once, starting with the current state */
|
||||||
&& GST_STATE (element) != GST_STATE_VOID_PENDING) {
|
do {
|
||||||
/* move the curpending state in the correct direction */
|
|
||||||
if (curpending < state)
|
|
||||||
curpending <<= 1;
|
|
||||||
else
|
|
||||||
curpending >>= 1;
|
|
||||||
|
|
||||||
/* set the pending state variable */
|
/* set the pending state variable */
|
||||||
/* FIXME: should probably check to see that we don't already have one */
|
|
||||||
GST_STATE_PENDING (element) = curpending;
|
GST_STATE_PENDING (element) = curpending;
|
||||||
|
|
||||||
if (curpending != state) {
|
if (curpending != state) {
|
||||||
|
@ -2758,10 +2761,13 @@ gst_element_set_state (GstElement * element, GstElementState state)
|
||||||
"intermediate: setting state from %s to %s",
|
"intermediate: setting state from %s to %s",
|
||||||
gst_element_state_get_name (GST_STATE (element)),
|
gst_element_state_get_name (GST_STATE (element)),
|
||||||
gst_element_state_get_name (curpending));
|
gst_element_state_get_name (curpending));
|
||||||
|
} else {
|
||||||
|
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
|
||||||
|
"start: setting current state %s again",
|
||||||
|
gst_element_state_get_name (GST_STATE (element)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* call the state change function so it can set the state */
|
/* call the state change function so it can set the state */
|
||||||
oclass = GST_ELEMENT_GET_CLASS (element);
|
|
||||||
if (oclass->change_state)
|
if (oclass->change_state)
|
||||||
return_val = (oclass->change_state) (element);
|
return_val = (oclass->change_state) (element);
|
||||||
|
|
||||||
|
@ -2780,7 +2786,8 @@ gst_element_set_state (GstElement * element, GstElementState state)
|
||||||
/* if it did not, this is an error - fix the element that does this */
|
/* if it did not, this is an error - fix the element that does this */
|
||||||
if (GST_STATE (element) != curpending) {
|
if (GST_STATE (element) != curpending) {
|
||||||
g_warning ("element %s claimed state-change success,"
|
g_warning ("element %s claimed state-change success,"
|
||||||
"but state didn't change to %s. State is %s (%s pending), fix the element",
|
"but state didn't change to %s. State is %s (%s pending), "
|
||||||
|
"fix the element",
|
||||||
GST_ELEMENT_NAME (element),
|
GST_ELEMENT_NAME (element),
|
||||||
gst_element_state_get_name (curpending),
|
gst_element_state_get_name (curpending),
|
||||||
gst_element_state_get_name (GST_STATE (element)),
|
gst_element_state_get_name (GST_STATE (element)),
|
||||||
|
@ -2793,7 +2800,14 @@ gst_element_set_state (GstElement * element, GstElementState state)
|
||||||
/* somebody added a GST_STATE_ and forgot to do stuff here ! */
|
/* somebody added a GST_STATE_ and forgot to do stuff here ! */
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
}
|
/* move the curpending state in the correct direction */
|
||||||
|
if (curpending < state)
|
||||||
|
curpending <<= 1;
|
||||||
|
else
|
||||||
|
curpending >>= 1;
|
||||||
|
} while (GST_STATE (element) != state
|
||||||
|
&& GST_STATE (element) != GST_STATE_VOID_PENDING);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
return return_val;
|
return return_val;
|
||||||
|
|
|
@ -100,8 +100,9 @@ main (gint argc, gchar * argv[])
|
||||||
g_assert (GST_STATE (bin2) == GST_STATE_PAUSED);
|
g_assert (GST_STATE (bin2) == GST_STATE_PAUSED);
|
||||||
g_assert (GST_STATE (fakesrc) == GST_STATE_PAUSED);
|
g_assert (GST_STATE (fakesrc) == GST_STATE_PAUSED);
|
||||||
//FIXME: fix core so that this assert works
|
//FIXME: fix core so that this assert works
|
||||||
//g_assert (GST_STATE (identity) == GST_STATE_PAUSED);
|
g_assert (GST_STATE (identity) == GST_STATE_PAUSED);
|
||||||
g_assert (GST_STATE (fakesink) == GST_STATE_PAUSED);
|
g_assert (GST_STATE (fakesink) == GST_STATE_PAUSED);
|
||||||
|
|
||||||
|
g_print ("passed.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,8 +100,9 @@ main (gint argc, gchar * argv[])
|
||||||
g_assert (GST_STATE (bin2) == GST_STATE_PAUSED);
|
g_assert (GST_STATE (bin2) == GST_STATE_PAUSED);
|
||||||
g_assert (GST_STATE (fakesrc) == GST_STATE_PAUSED);
|
g_assert (GST_STATE (fakesrc) == GST_STATE_PAUSED);
|
||||||
//FIXME: fix core so that this assert works
|
//FIXME: fix core so that this assert works
|
||||||
//g_assert (GST_STATE (identity) == GST_STATE_PAUSED);
|
g_assert (GST_STATE (identity) == GST_STATE_PAUSED);
|
||||||
g_assert (GST_STATE (fakesink) == GST_STATE_PAUSED);
|
g_assert (GST_STATE (fakesink) == GST_STATE_PAUSED);
|
||||||
|
|
||||||
|
g_print ("passed.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue