Make the ghostpad a parent of the internal pad again for better backward compatibility. Don't write code that relies ...

Original commit message from CVS:
* docs/design/part-gstghostpad.txt:
* gst/gstghostpad.c: (gst_ghost_pad_dispose),
(gst_ghost_pad_new_full):
Make the ghostpad a parent of the internal pad again for better backward
compatibility. Don't write code that relies on this however.
* gst/gstpad.c: (gst_pad_activate_pull), (gst_pad_activate_push),
(gst_pad_link_check_hierarchy):
Require that parents should be GstElements in the hierarchy check.
This commit is contained in:
Wim Taymans 2007-02-20 18:02:50 +00:00
parent e561ce761b
commit 60212ff197
4 changed files with 46 additions and 9 deletions

View file

@ -1,3 +1,15 @@
2007-02-20 Wim Taymans <wim@fluendo.com>
* docs/design/part-gstghostpad.txt:
* gst/gstghostpad.c: (gst_ghost_pad_dispose),
(gst_ghost_pad_new_full):
Make the ghostpad a parent of the internal pad again for better backward
compatibility. Don't write code that relies on this however.
* gst/gstpad.c: (gst_pad_activate_pull), (gst_pad_activate_push),
(gst_pad_link_check_hierarchy):
Require that parents should be GstElements in the hierarchy check.
2007-02-20 Wim Taymans <wim@fluendo.com>
* gst/gstbin.c: (bin_replace_message), (gst_bin_add_func),

View file

@ -66,6 +66,8 @@ Ghostpads
| target *----->//
(------------)
The GstGhostPad (X) is also set as the parent of the GstProxyPad (Y).
The target is a pointer to the internal pads peer. It is an optimisation to
quickly get to the peer of a ghostpad without having to dereference the
internal->peer.

View file

@ -707,9 +707,8 @@ gst_ghost_pad_dispose (GObject * object)
GST_PROXY_PAD_INTERNAL (internal) = NULL;
/* disposes of the internal pad, since the ghostpad is the only possible object
* that has a refcount on the internal pad.
*/
gst_object_unref (internal);
* that has a refcount on the internal pad. */
gst_object_unparent (GST_OBJECT_CAST (internal));
GST_PROXY_UNLOCK (pad);
@ -782,17 +781,17 @@ gst_ghost_pad_new_full (const gchar * name, GstPadDirection dir,
GST_PROXY_LOCK (ret);
/* don't set parent, we can't link the internal pads if parents/grandparents
* are different, just take ownership. */
gst_object_ref (internal);
gst_object_sink (internal);
/* now make the ghostpad a parent of the internal pad */
if (!gst_object_set_parent (GST_OBJECT_CAST (internal),
GST_OBJECT_CAST (ret)))
goto parent_failed;
/* The ghostpad is the owner of the internal pad and is the only object that
/* The ghostpad is the parent of the internal pad and is the only object that
* can have a refcount on the internal pad.
* At this point, the GstGhostPad has a refcount of 1, and the internal pad has
* a refcount of 1.
* When the refcount of the GstGhostPad drops to 0, the ghostpad will dispose
* it's refcount on the internal pad in the dispose method by un-reffing it.
* it's refcount on the internal pad in the dispose method by un-parenting it.
* This is why we don't take extra refcounts in the assignments below
*/
GST_PROXY_PAD_INTERNAL (ret) = internal;
@ -816,6 +815,19 @@ gst_ghost_pad_new_full (const gchar * name, GstPadDirection dir,
GST_PROXY_UNLOCK (ret);
return ret;
/* ERRORS */
parent_failed:
{
GST_WARNING_OBJECT (ret, "Could not set internal pad %s:%s",
GST_DEBUG_PAD_NAME (internal));
g_critical ("Could not set internal pad %s:%s",
GST_DEBUG_PAD_NAME (internal));
GST_PROXY_UNLOCK (ret);
gst_object_unref (ret);
gst_object_unref (internal);
return NULL;
}
}
/**

View file

@ -1697,6 +1697,10 @@ gst_pad_link_check_hierarchy (GstPad * src, GstPad * sink)
if (G_UNLIKELY (psrc == NULL || psink == NULL))
goto no_parent;
/* only care about parents that are elements */
if (G_UNLIKELY (!GST_IS_ELEMENT (psrc) || !GST_IS_ELEMENT (psink)))
goto no_element_parent;
/* if the parents are the same, we have a loop */
if (G_UNLIKELY (psrc == psink))
goto same_parents;
@ -1721,6 +1725,13 @@ no_parent:
GST_PTR_FORMAT, psrc, psink);
return TRUE;
}
no_element_parent:
{
GST_CAT_DEBUG (GST_CAT_CAPS,
"one of the pads has no element parent %" GST_PTR_FORMAT " and %"
GST_PTR_FORMAT, psrc, psink);
return TRUE;
}
same_parents:
{
GST_CAT_DEBUG (GST_CAT_CAPS, "pads have same parent %" GST_PTR_FORMAT,