gst/gstelement.c: Look at the pending state too when syncing the element state to the parent. Fixes #420133.

Original commit message from CVS:
Patch by: Olivier Crete <tester at tester dot ca>
* gst/gstelement.c: (gst_element_sync_state_with_parent):
Look at the pending state too when syncing the element state to the
parent. Fixes #420133.
This commit is contained in:
Olivier Crete 2007-03-20 09:46:11 +00:00 committed by Wim Taymans
parent c248d1dba0
commit 2b3ea5e9d8
2 changed files with 27 additions and 6 deletions

View file

@ -1,3 +1,11 @@
2007-03-20 Wim Taymans <wim@fluendo.com>
Patch by: Olivier Crete <tester at tester dot ca>
* gst/gstelement.c: (gst_element_sync_state_with_parent):
Look at the pending state too when syncing the element state to the
parent. Fixes #420133.
2007-03-19 Jan Schmidt <thaytan@mad.scientist.com>
* libs/gst/base/gstbasesink.c: (gst_base_sink_set_flushing),

View file

@ -1713,38 +1713,51 @@ gboolean
gst_element_sync_state_with_parent (GstElement * element)
{
GstElement *parent;
GstState target;
GstStateChangeReturn ret;
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
if ((parent = GST_ELEMENT_CAST (gst_element_get_parent (element)))) {
GstState parent_current, parent_pending;
GstStateChangeReturn ret;
GST_OBJECT_LOCK (parent);
parent_current = GST_STATE (parent);
parent_pending = GST_STATE_PENDING (parent);
GST_OBJECT_UNLOCK (parent);
GST_CAT_DEBUG (GST_CAT_STATES,
"syncing state of element %s (%s) to %s (%s, %s)",
GST_ELEMENT_NAME (element),
/* set to pending if there is one, else we set it to the current state of
* the parent */
if (parent_pending != GST_STATE_VOID_PENDING)
target = parent_pending;
else
target = parent_current;
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
"syncing state (%s) to parent %s %s (%s, %s)",
gst_element_state_get_name (GST_STATE (element)),
GST_ELEMENT_NAME (parent), gst_element_state_get_name (parent_current),
GST_ELEMENT_NAME (parent), gst_element_state_get_name (target),
gst_element_state_get_name (parent_current),
gst_element_state_get_name (parent_pending));
ret = gst_element_set_state (element, parent_current);
ret = gst_element_set_state (element, target);
if (ret == GST_STATE_CHANGE_FAILURE)
goto failed;
gst_object_unref (parent);
return TRUE;
} else {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, "element has no parent");
}
return FALSE;
/* ERROR */
failed:
{
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
"syncing state failed (%s)",
gst_element_state_change_return_get_name (ret));
return FALSE;
}
}