mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
states: post structure change on sinkpads
Post the structure change messages on the sinkpads of the elements. This allows us to catch unlinked pads earlier without ending up with inconsistent element degrees.
This commit is contained in:
parent
1ab11faf48
commit
f64243e037
3 changed files with 19 additions and 21 deletions
28
gst/gstbin.c
28
gst/gstbin.c
|
@ -1814,24 +1814,22 @@ update_degree (GstElement * element, GstBinSortIterator * bit)
|
|||
|
||||
pad = GST_PAD_CAST (pads->data);
|
||||
|
||||
/* we're iterating over the sinkpads, check if it's busy in a link/unlink */
|
||||
if (G_UNLIKELY (find_message (bit->bin, GST_OBJECT_CAST (pad),
|
||||
GST_MESSAGE_STRUCTURE_CHANGE))) {
|
||||
/* mark the iterator as dirty because we won't be updating the degree
|
||||
* of the peer parent now. This would result in the 'loop detected'
|
||||
* later on because the peer parent element could become the best next
|
||||
* element with a degree > 0. We will simply continue our state
|
||||
* changes and we'll eventually resync when the unlink completed and
|
||||
* the iterator cookie is updated. */
|
||||
bit->dirty = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((peer = gst_pad_get_peer (pad))) {
|
||||
GstElement *peer_element;
|
||||
|
||||
/* we're iterating over the sinkpads, this is the peer and thus the
|
||||
* srcpad, check if it's busy in a link/unlink */
|
||||
if (G_UNLIKELY (find_message (bit->bin, GST_OBJECT_CAST (peer),
|
||||
GST_MESSAGE_STRUCTURE_CHANGE))) {
|
||||
/* mark the iterator as dirty because we won't be updating the degree
|
||||
* of the peer parent now. This would result in the 'loop detected'
|
||||
* later on because the peer parent element could become the best next
|
||||
* element with a degree > 0. We will simply continue our state
|
||||
* changes and we'll eventually resync when the unlink completed and
|
||||
* the iterator cookie is updated. */
|
||||
bit->dirty = TRUE;
|
||||
gst_object_unref (peer);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((peer_element = gst_pad_get_parent_element (peer))) {
|
||||
GST_OBJECT_LOCK (peer_element);
|
||||
/* check that we don't go outside of this bin */
|
||||
|
|
|
@ -695,7 +695,7 @@ gst_message_new_new_clock (GstObject * src, GstClock * clock)
|
|||
* structure of a pipeline is in the process of being changed, for example
|
||||
* when pads are linked or unlinked.
|
||||
*
|
||||
* @src should be the srcpad that unlinked or linked.
|
||||
* @src should be the sinkpad that unlinked or linked.
|
||||
*
|
||||
* Returns: The new structure change message.
|
||||
*
|
||||
|
@ -711,7 +711,7 @@ gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
|
|||
GstStructure *structure;
|
||||
|
||||
g_return_val_if_fail (GST_IS_PAD (src), NULL);
|
||||
g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SRC, NULL);
|
||||
g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL);
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
|
||||
|
||||
structure = gst_structure_id_new (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
|
||||
|
|
|
@ -1673,7 +1673,7 @@ gst_pad_unlink (GstPad * srcpad, GstPad * sinkpad)
|
|||
if ((parent = GST_ELEMENT_CAST (gst_pad_get_parent (srcpad)))) {
|
||||
if (GST_IS_ELEMENT (parent)) {
|
||||
gst_element_post_message (parent,
|
||||
gst_message_new_structure_change (GST_OBJECT_CAST (srcpad),
|
||||
gst_message_new_structure_change (GST_OBJECT_CAST (sinkpad),
|
||||
GST_STRUCTURE_CHANGE_TYPE_PAD_UNLINK, parent, TRUE));
|
||||
} else {
|
||||
gst_object_unref (parent);
|
||||
|
@ -1715,7 +1715,7 @@ gst_pad_unlink (GstPad * srcpad, GstPad * sinkpad)
|
|||
done:
|
||||
if (parent != NULL) {
|
||||
gst_element_post_message (parent,
|
||||
gst_message_new_structure_change (GST_OBJECT_CAST (srcpad),
|
||||
gst_message_new_structure_change (GST_OBJECT_CAST (sinkpad),
|
||||
GST_STRUCTURE_CHANGE_TYPE_PAD_UNLINK, parent, FALSE));
|
||||
gst_object_unref (parent);
|
||||
}
|
||||
|
@ -1997,7 +1997,7 @@ gst_pad_link (GstPad * srcpad, GstPad * sinkpad)
|
|||
if ((parent = GST_ELEMENT_CAST (gst_pad_get_parent (srcpad)))) {
|
||||
if (GST_IS_ELEMENT (parent)) {
|
||||
gst_element_post_message (parent,
|
||||
gst_message_new_structure_change (GST_OBJECT_CAST (srcpad),
|
||||
gst_message_new_structure_change (GST_OBJECT_CAST (sinkpad),
|
||||
GST_STRUCTURE_CHANGE_TYPE_PAD_LINK, parent, TRUE));
|
||||
} else {
|
||||
gst_object_unref (parent);
|
||||
|
@ -2059,7 +2059,7 @@ gst_pad_link (GstPad * srcpad, GstPad * sinkpad)
|
|||
done:
|
||||
if (parent) {
|
||||
gst_element_post_message (parent,
|
||||
gst_message_new_structure_change (GST_OBJECT_CAST (srcpad),
|
||||
gst_message_new_structure_change (GST_OBJECT_CAST (sinkpad),
|
||||
GST_STRUCTURE_CHANGE_TYPE_PAD_LINK, parent, FALSE));
|
||||
gst_object_unref (parent);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue