summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-09-02 18:54:06 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2009-09-02 18:54:06 +0200
commitf64243e037828a55a52619d62920024740484835 (patch)
tree0ed57bcbb2ce3c9cb2d0dd44c18cb9d30ee8a56a
parent1ab11faf4850237e458432816ab66acaed44f86f (diff)
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.
-rw-r--r--gst/gstbin.c28
-rw-r--r--gst/gstmessage.c4
-rw-r--r--gst/gstpad.c8
3 files changed, 19 insertions, 21 deletions
diff --git a/gst/gstbin.c b/gst/gstbin.c
index 12487ad9a8..4e07f3cd9a 100644
--- a/gst/gstbin.c
+++ b/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 */
diff --git a/gst/gstmessage.c b/gst/gstmessage.c
index 60bfddefd0..cf49920a53 100644
--- a/gst/gstmessage.c
+++ b/gst/gstmessage.c
@@ -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),
diff --git a/gst/gstpad.c b/gst/gstpad.c
index f978a6786b..d52a506334 100644
--- a/gst/gstpad.c
+++ b/gst/gstpad.c
@@ -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);
}