caps: make _normalize take ownership of input
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 12 Mar 2012 11:21:34 +0000 (12:21 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 12 Mar 2012 11:21:34 +0000 (12:21 +0100)
Make gst_caps_normalize() take ownership of the input so that it can more
intelligently decide when to copy or not.

gst/gstcaps.c
tests/check/gst/gstcaps.c

index f4964d0..a51f113 100644 (file)
@@ -1616,13 +1616,15 @@ gst_caps_normalize_foreach (GQuark field_id, const GValue * value, gpointer ptr)
 
 /**
  * gst_caps_normalize:
- * @caps: a #GstCaps to normalize
+ * @caps: (transfer full): a #GstCaps to normalize
  *
- * Creates a new #GstCaps that represents the same set of formats as
+ * Returns a #GstCaps that represents the same set of formats as
  * @caps, but contains no lists.  Each list is expanded into separate
  * @GstStructures.
  *
- * Returns: the new #GstCaps
+ * This function takes ownership of @caps.
+ *
+ * Returns: (transfer full): the normalized #GstCaps
  */
 GstCaps *
 gst_caps_normalize (GstCaps * caps)
@@ -1633,7 +1635,7 @@ gst_caps_normalize (GstCaps * caps)
 
   g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
 
-  newcaps = _gst_caps_copy (caps);
+  newcaps = gst_caps_make_writable (caps);
   nf.caps = newcaps;
 
   for (i = 0; i < gst_caps_get_size (newcaps); i++) {
index 1e32555..a0090a2 100644 (file)
@@ -839,7 +839,6 @@ GST_START_TEST (test_normalize)
     fail_unless (gst_structure_foreach (st, _caps_is_fixed_foreach, NULL));
   }
 
-  gst_caps_unref (in);
   gst_caps_unref (out);
   gst_caps_unref (norm);
 
@@ -858,7 +857,6 @@ GST_START_TEST (test_normalize)
     fail_unless (gst_structure_foreach (st, _caps_is_fixed_foreach, NULL));
   }
 
-  gst_caps_unref (in);
   gst_caps_unref (out);
   gst_caps_unref (norm);
 
@@ -876,7 +874,6 @@ GST_START_TEST (test_normalize)
     fail_unless (gst_structure_foreach (st, _caps_is_fixed_foreach, NULL));
   }
 
-  gst_caps_unref (in);
   gst_caps_unref (out);
   gst_caps_unref (norm);
 }