gst/gstcaps.c: Clarify behaviour of _is_equal() when passing NULL parameters.

Original commit message from CVS:
* gst/gstcaps.c:
Clarify behaviour of _is_equal() when passing NULL parameters.

* gst/gstpad.c: (gst_pad_link_check_compatible_unlocked),
(gst_pad_set_caps):
Cleanups. Don't unref NULL caps.
When setting the same caps, protect caps of the pad with
proper lock.
Use full functionality of _is_equal() when comparing caps.
This commit is contained in:
Wim Taymans 2006-01-20 09:53:24 +00:00
parent 1dad4aea3a
commit b5b28e2e39
3 changed files with 42 additions and 13 deletions

View file

@ -1,3 +1,15 @@
2006-01-20 Wim Taymans <wim@fluendo.com>
* gst/gstcaps.c:
Clarify behaviour of _is_equal() when passing NULL parameters.
* gst/gstpad.c: (gst_pad_link_check_compatible_unlocked),
(gst_pad_set_caps):
Cleanups. Don't unref NULL caps.
When setting the same caps, protect caps of the pad with
proper lock.
Use full functionality of _is_equal() when comparing caps.
2006-01-20 Jan Schmidt <thaytan@mad.scientist.com>
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_is_collected):

View file

@ -875,7 +875,9 @@ gst_caps_is_subset (const GstCaps * subset, const GstCaps * superset)
* <note>This function does not work reliably if optional properties for caps
* are included on one caps and omitted on the other.</note>
*
* Returns: TRUE if both caps are equal
* This function deals correctly with passing NULL for any of the caps.
*
* Returns: TRUE if both caps are equal.
*/
gboolean
gst_caps_is_equal (const GstCaps * caps1, const GstCaps * caps2)

View file

@ -1510,10 +1510,12 @@ gst_pad_link_check_compatible_unlocked (GstPad * src, GstPad * sink)
srccaps = gst_pad_get_caps_unlocked (src);
sinkcaps = gst_pad_get_caps_unlocked (sink);
GST_CAT_DEBUG (GST_CAT_CAPS, "src caps %" GST_PTR_FORMAT, srccaps);
GST_CAT_DEBUG (GST_CAT_CAPS, "sink caps %" GST_PTR_FORMAT, sinkcaps);
/* if we have caps on both pads we can check the intersection */
/* if we have caps on both pads we can check the intersection. If one
* of the caps is NULL, we return TRUE. */
if (srccaps && sinkcaps) {
GstCaps *icaps;
@ -1521,18 +1523,31 @@ gst_pad_link_check_compatible_unlocked (GstPad * src, GstPad * sink)
gst_caps_unref (srccaps);
gst_caps_unref (sinkcaps);
if (icaps == NULL)
goto was_null;
GST_CAT_DEBUG (GST_CAT_CAPS,
"intersection caps %p %" GST_PTR_FORMAT, icaps, icaps);
if (!icaps || gst_caps_is_empty (icaps)) {
GST_CAT_DEBUG (GST_CAT_CAPS, "intersection is empty");
gst_caps_unref (icaps);
return FALSE;
}
if (gst_caps_is_empty (icaps))
goto was_empty;
gst_caps_unref (icaps);
}
return TRUE;
/* incompatible cases */
was_null:
{
GST_CAT_DEBUG (GST_CAT_CAPS, "intersection gave NULL");
return FALSE;
}
was_empty:
{
GST_CAT_DEBUG (GST_CAT_CAPS, "intersection is EMPTY");
gst_caps_unref (icaps);
return FALSE;
}
}
/* check if the grandparents of both pads are the same.
@ -2136,12 +2151,11 @@ gst_pad_set_caps (GstPad * pad, GstCaps * caps)
setcaps = GST_PAD_SETCAPSFUNC (pad);
existing = GST_PAD_CAPS (pad);
if (caps == existing)
goto setting_same_caps;
else if (caps && existing && gst_caps_is_equal (caps, existing))
if (gst_caps_is_equal (caps, existing))
goto setting_same_caps;
/* call setcaps function to configure the pad */
/* call setcaps function to configure the pad only if the
* caps is not NULL */
if (setcaps != NULL && caps) {
if (!GST_PAD_IS_IN_SETCAPS (pad)) {
GST_OBJECT_FLAG_SET (pad, GST_PAD_IN_SETCAPS);
@ -2167,10 +2181,11 @@ gst_pad_set_caps (GstPad * pad, GstCaps * caps)
setting_same_caps:
{
GST_OBJECT_UNLOCK (pad);
gst_caps_replace (&GST_PAD_CAPS (pad), caps);
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad,
"caps %" GST_PTR_FORMAT " same as existing, updating ptr only", caps);
GST_OBJECT_UNLOCK (pad);
return TRUE;
}
/* errors */