goto not_linked_together;
if (GST_PAD_UNLINKFUNC (srcpad)) {
- GST_PAD_UNLINKFUNC (srcpad) (srcpad);
+ GstObject *tmpparent;
+
+ ACQUIRE_PARENT (srcpad, tmpparent, no_src_parent);
+
+ GST_PAD_UNLINKFUNC (srcpad) (srcpad, tmpparent);
+ RELEASE_PARENT (parent);
}
+no_src_parent:
if (GST_PAD_UNLINKFUNC (sinkpad)) {
- GST_PAD_UNLINKFUNC (sinkpad) (sinkpad);
+ GstObject *tmpparent;
+
+ ACQUIRE_PARENT (sinkpad, tmpparent, no_sink_parent);
+
+ GST_PAD_UNLINKFUNC (sinkpad) (sinkpad, tmpparent);
+ RELEASE_PARENT (parent);
}
+no_sink_parent:
/* first clear peers */
GST_PAD_PEER (srcpad) = NULL;
GST_OBJECT_UNLOCK (srcpad);
if (srcfunc) {
+ GstObject *tmpparent;
+
+ ACQUIRE_PARENT (srcpad, tmpparent, no_parent);
/* this one will call the peer link function */
- result = srcfunc (srcpad, sinkpad);
+ result = srcfunc (srcpad, tmpparent, sinkpad);
+ RELEASE_PARENT (tmpparent);
} else if (sinkfunc) {
+ GstObject *tmpparent;
+
+ ACQUIRE_PARENT (sinkpad, tmpparent, no_parent);
/* if no source link function, we need to call the sink link
* function ourselves. */
- result = sinkfunc (sinkpad, srcpad);
+ result = sinkfunc (sinkpad, tmpparent, srcpad);
+ RELEASE_PARENT (tmpparent);
}
+ no_parent:
GST_OBJECT_LOCK (srcpad);
GST_OBJECT_LOCK (sinkpad);
/**
* GstPadLinkFunction:
* @pad: the #GstPad that is linked.
+ * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
+ * @parent is guaranteed to be not-NULL and remain valid during the
+ * execution of this function.
* @peer: the peer #GstPad of the link
*
* Function signature to handle a new link on the pad.
*
* Returns: the result of the link with the specified peer.
*/
-typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstPad *peer);
+typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstObject *parent, GstPad *peer);
/**
* GstPadUnlinkFunction:
* @pad: the #GstPad that is linked.
+ * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
+ * @parent is guaranteed to be not-NULL and remain valid during the
+ * execution of this function.
*
* Function signature to handle a unlinking the pad prom its peer.
*/
-typedef void (*GstPadUnlinkFunction) (GstPad *pad);
+typedef void (*GstPadUnlinkFunction) (GstPad *pad, GstObject *parent);
/* misc */
static gint unlinked_count2;
static GstPadLinkReturn
-pad_linked1 (GstPad * pad, GstPad * peer)
+pad_linked1 (GstPad * pad, GstObject * parent, GstPad * peer)
{
linked_count1++;
}
static void
-pad_unlinked1 (GstPad * pad)
+pad_unlinked1 (GstPad * pad, GstObject * parent)
{
unlinked_count1++;
}
static GstPadLinkReturn
-pad_linked2 (GstPad * pad, GstPad * peer)
+pad_linked2 (GstPad * pad, GstObject * parent, GstPad * peer)
{
linked_count2++;
}
static void
-pad_unlinked2 (GstPad * pad)
+pad_unlinked2 (GstPad * pad, GstObject * parent)
{
unlinked_count2++;
}