From d12738b4fa3e058a2cb0a51c3e61085ec2010ac5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 15 Aug 2011 14:17:39 +0200 Subject: [PATCH] pad: fix default acceptcaps Make the acceptcaps function behave like all the other functions with a default implementation. Don't try to chain up to the default implementation when it was set to NULL explicitly but return FALSE instead. Fix some docs --- gst/gstpad.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/gst/gstpad.c b/gst/gstpad.c index 64ba962..5b258f8 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2350,7 +2350,7 @@ done: * gst_pad_has_current_caps: * @pad: a #GstPad to check * - * Check if @pad has caps set on it with gst_pad_set_caps(). + * Check if @pad has caps set on it with a #GST_EVENT_CAPS event. * * Returns: TRUE when @pad has caps associated with it. */ @@ -2373,8 +2373,8 @@ gst_pad_has_current_caps (GstPad * pad) * gst_pad_get_current_caps: * @pad: a #GstPad to get the current capabilities of. * - * Gets the capabilities currently configured on @pad with the last call to - * gst_pad_set_caps(). + * Gets the capabilities currently configured on @pad with the last + * #GST_EVENT_CAPS event. * * Returns: the current caps of the pad with incremented ref-count. */ @@ -2598,27 +2598,26 @@ gst_pad_accept_caps (GstPad * pad, GstCaps * caps) return TRUE; /* lock for checking the existing caps */ - GST_OBJECT_LOCK (pad); GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "accept caps of %p", caps); #if 0 + GST_OBJECT_LOCK (pad); /* The current caps on a pad are trivially acceptable */ if (G_LIKELY ((existing = GST_PAD_CAPS (pad)))) { if (caps == existing || gst_caps_is_equal (caps, existing)) goto is_same_caps; } + GST_OBJECT_UNLOCK (pad); #endif acceptfunc = GST_PAD_ACCEPTCAPSFUNC (pad); - GST_OBJECT_UNLOCK (pad); - if (G_LIKELY (acceptfunc)) { - /* we can call the function */ - result = acceptfunc (pad, caps); - GST_DEBUG_OBJECT (pad, "acceptfunc returned %d", result); - } else { - /* Only null if the element explicitly unset it */ - result = gst_pad_acceptcaps_default (pad, caps); - GST_DEBUG_OBJECT (pad, "default acceptcaps returned %d", result); - } + /* Only null if the element explicitly unset it */ + if (G_UNLIKELY (acceptfunc == NULL)) + goto no_func; + + /* we can call the function */ + result = acceptfunc (pad, caps); + GST_DEBUG_OBJECT (pad, "acceptfunc returned %d", result); + return result; #if 0 @@ -2629,6 +2628,11 @@ is_same_caps: return TRUE; } #endif +no_func: + { + GST_DEBUG_OBJECT (pad, "no acceptcase function"); + return FALSE; + } } /** -- 2.7.4