From: David Schleef Date: Sat, 3 Jan 2004 09:25:04 +0000 (+0000) Subject: gst/gstelement.c: Fix to allow DELAYED to indicate that linking was successful. X-Git-Tag: BRANCH-RELEASE-0_7_4-ROOT~191 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4142ec0a048cd9227889de18a032160146bea89;p=platform%2Fupstream%2Fgstreamer.git gst/gstelement.c: Fix to allow DELAYED to indicate that linking was successful. Original commit message from CVS: * gst/gstelement.c: (gst_element_link_pads_filtered), (gst_element_negotiate_pads): Fix to allow DELAYED to indicate that linking was successful. * gst/gstpad.c: (gst_pad_link_free), (gst_pad_link_call_link_functions), (gst_pad_link_negotiate), (gst_pad_link_try), (gst_pad_link_unnegotiate), (gst_pad_unnegotiate), (gst_pad_set_explicit_caps): Pass GstPadLinkReturn correctly between functions, and don't fail when DELAYED is used (DELAYED is very important). Better cleanup on unlinking and unnegotiation. Should fix some spider bugs. --- diff --git a/ChangeLog b/ChangeLog index 39bb952..9ab5817 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2004-01-03 David Schleef + + * gst/gstelement.c: (gst_element_link_pads_filtered), + (gst_element_negotiate_pads): Fix to allow DELAYED to indicate + that linking was successful. + * gst/gstpad.c: (gst_pad_link_free), + (gst_pad_link_call_link_functions), (gst_pad_link_negotiate), + (gst_pad_link_try), (gst_pad_link_unnegotiate), + (gst_pad_unnegotiate), (gst_pad_set_explicit_caps): Pass + GstPadLinkReturn correctly between functions, and don't fail + when DELAYED is used (DELAYED is very important). Better + cleanup on unlinking and unnegotiation. Should fix some spider + bugs. + 2004-01-02 David Schleef * gst/gstelement.c: (gst_element_class_init), diff --git a/gst/gstelement.c b/gst/gstelement.c index 1abfc21..feaab2c 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -1595,7 +1595,7 @@ gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname, if (srcpadname && destpadname) { /* two explicitly specified pads */ - return gst_pad_link_filtered (srcpad, destpad, filtercaps); + return gst_pad_link_filtered (srcpad, destpad, filtercaps); } if (srcpad) { /* loop through the allowed pads in the source, trying to find a @@ -2500,7 +2500,7 @@ gst_element_negotiate_pads (GstElement *element) "perform negotiate for %s:%s and %s:%s", GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); - if (!gst_pad_renegotiate (pad)) + if (gst_pad_renegotiate (pad) == GST_PAD_LINK_REFUSED) return FALSE; } else { diff --git a/gst/gstpad.c b/gst/gstpad.c index aec4d5c..e2bc26b 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -993,6 +993,11 @@ gst_pad_link_free (GstPadLink *link) if (link->sinkcaps) gst_caps_free (link->sinkcaps); if (link->filtercaps) gst_caps_free (link->filtercaps); if (link->caps) gst_caps_free (link->caps); + GST_RPAD_LINK (link->srcpad) = NULL; + GST_RPAD_LINK (link->sinkpad) = NULL; +#ifdef USE_POISONING + memset(link,0xff, sizeof(*link)); +#endif g_free (link); } @@ -1091,7 +1096,7 @@ gst_pad_link_fixate (GstPadLink *link) link->caps = caps; } -static gboolean +static GstPadLinkReturn gst_pad_link_call_link_functions (GstPadLink *link) { gboolean negotiating; @@ -1119,7 +1124,7 @@ gst_pad_link_call_link_functions (GstPadLink *link) if (GST_PAD_LINK_FAILED (res)) { GST_CAT_INFO (GST_CAT_CAPS, "pad %s:%s doesn't accept caps", GST_DEBUG_PAD_NAME (link->srcpad)); - return FALSE; + return res; } } @@ -1145,11 +1150,11 @@ gst_pad_link_call_link_functions (GstPadLink *link) if (GST_PAD_LINK_FAILED (res)) { GST_CAT_INFO (GST_CAT_CAPS, "pad %s:%s doesn't accept caps", GST_DEBUG_PAD_NAME (link->sinkpad)); - return FALSE; + return res; } } - return TRUE; + return GST_PAD_LINK_OK; } static GstPadLinkReturn @@ -1170,11 +1175,7 @@ gst_pad_link_negotiate (GstPadLink *link) if (gst_caps_is_empty (link->caps)) return GST_PAD_LINK_REFUSED; - if (!gst_pad_link_call_link_functions (link)) { - return GST_PAD_LINK_REFUSED; - } - - return GST_PAD_LINK_OK; + return gst_pad_link_call_link_functions (link); } /** @@ -1204,17 +1205,20 @@ gst_pad_link_try (GstPadLink *link) g_assert (oldlink == GST_RPAD_LINK (sinkpad)); ret = gst_pad_link_negotiate (link); - if (ret == GST_PAD_LINK_REFUSED) { - if (oldlink && oldlink->caps) { - oldlink->srcnotify = link->srcnotify; - oldlink->sinknotify = link->sinknotify; - if (!gst_pad_link_call_link_functions (oldlink)) { - g_warning ("pads don't accept old caps. We assume they did though"); - } + if (GST_PAD_LINK_FAILED (ret) && oldlink && oldlink->caps) { + oldlink->srcnotify = link->srcnotify; + oldlink->sinknotify = link->sinknotify; + if (GST_PAD_LINK_FAILED (gst_pad_link_call_link_functions (oldlink))) { + g_warning ("pads don't accept old caps. We assume they did though"); } + } + if (ret == GST_PAD_LINK_REFUSED) { gst_pad_link_free (link); return ret; } + if (ret == GST_PAD_LINK_DELAYED) { + gst_caps_replace (&link->caps, NULL); + } GST_RPAD_PEER (srcpad) = GST_REAL_PAD(link->sinkpad); GST_RPAD_PEER (sinkpad) = GST_REAL_PAD(link->srcpad); @@ -1222,8 +1226,10 @@ gst_pad_link_try (GstPadLink *link) gst_pad_link_free (oldlink); GST_RPAD_LINK (srcpad) = link; GST_RPAD_LINK (sinkpad) = link; - g_object_notify (G_OBJECT (srcpad), "caps"); - g_object_notify (G_OBJECT (sinkpad), "caps"); + if (ret == GST_PAD_LINK_OK) { + g_object_notify (G_OBJECT (srcpad), "caps"); + g_object_notify (G_OBJECT (sinkpad), "caps"); + } return ret; } @@ -1849,6 +1855,8 @@ gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad) void gst_pad_link_unnegotiate (GstPadLink *link) { + g_return_if_fail (link != NULL); + if (link->caps) { gst_caps_free (link->caps); link->caps = NULL; @@ -1875,10 +1883,13 @@ gst_pad_link_unnegotiate (GstPadLink *link) void gst_pad_unnegotiate (GstPad *pad) { + GstPadLink *link; + g_return_if_fail (GST_IS_PAD (pad)); - if (GST_RPAD_LINK (pad)) - gst_pad_link_unnegotiate (GST_RPAD_LINK (pad)); + link = GST_RPAD_LINK (GST_PAD_REALIZE (pad)); + if (link) + gst_pad_link_unnegotiate (link); } /** @@ -2132,7 +2143,13 @@ gst_pad_set_explicit_caps (GstPad *pad, GstCaps *caps) gst_caps_replace (&GST_RPAD_EXPLICIT_CAPS (pad), caps); - if (caps == NULL || !GST_PAD_IS_LINKED (pad)) { + if (caps == NULL) { + GST_CAT_DEBUG (GST_CAT_PADS, "caps is NULL"); + return TRUE; + } + + if (!GST_PAD_IS_LINKED (pad)) { + GST_CAT_DEBUG (GST_CAT_PADS, "pad is not linked"); return TRUE; } link_ret = gst_pad_try_set_caps (pad, caps);