[gst-devel] gst_pad_unlink simple question

Sean McNamara smcnam at gmail.com
Wed Mar 10 18:28:04 CET 2010


Hi,

On Tue, Mar 9, 2010 at 1:46 PM, wanting2learn
<wanting2learn at hotmail.co.uk> wrote:
>
> If I check that a pad is alrealy linked and I try to unlink it like so:
> if ( GST_PAD_IS_LINKED( sinkpad ) )
>  {
>      gst_pad_unlink (pad, sinkpad))
>  }
>
> Why would gst_pad_unlink fail to unlink and give me a return code of:
> GST_PAD_LINK_WAS_LINKED?

How does gst_pad_unlink provide a return code of
GST_PAD_LINK_WAS_LINKED at all? This is the function signature of
gst_pad_unlink:

gboolean gst_pad_unlink(GstPad *srcpad, GstPad *sinkpad);

It returns a boolean, not an error code... if it returns true, then
the link was successful; otherwise, it failed because srcpad is not
linked to sinkpad.

Also, your test GST_PAD_IS_LINKED(sinkpad) is not sufficient to
determine for sure that srcpad was linked to sinkpad. sinkpad could be
linked to `padprime', another pad that is not the same one as `pad'.

To check that `pad' is linked to `sinkpad', you would have to test an
expression like:

 (GST_PAD_IS_LINKED(pad) && gst_pad_get_peer(pad) == sinkpad &&
gst_pad_get_direction(pad) == GST_PAD_SRC &&
gst_pad_get_direction(sinkpad) == GST_PAD_SINK)

I'm not sure if this exhaustively determines whether pad is linked to
sinkpad (untested code), but it should work better than what you are
doing now.

>
> Why does gst_pad_unlink simply not just unlink a pad?

gst_pad_unlink() will unlink a pair of pads if all of the following are true:
1) Both pads are non-NULL (obviously)
2) The pads are linked to eachother
3) srcpad, the first parameter, is the source pad -- that is,
gst_pad_get_direction(srcpad) == GST_PAD_SRC
4) sinkpad, the second parameter, is the sink pad -- that is,
gst_pad_get_direction(sinkpad) == GST_PAD_SINK


HTH,

-Sean

>
> Thanks
>
> --
> View this message in context: http://n4.nabble.com/gst-pad-unlink-simple-question-tp1586435p1586435.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>




More information about the gstreamer-devel mailing list