]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gstreamer0-10.git/blobdiff - gst/gststructure.c
gststructure: clarify _get docs about the returned reference
[glsdk/gstreamer0-10.git] / gst / gststructure.c
index d08a0616ba1fbb3ea66bd2652a8b318c692aa8b0..23c54b35f533d823d52fdf3d9e55596b175fb933 100644 (file)
@@ -169,8 +169,8 @@ gst_structure_validate_name (const gchar * name)
   while (*s && (g_ascii_isalnum (*s) || strchr ("/-_.:+ ", *s) != NULL))
     s++;
   if (G_UNLIKELY (*s != '\0')) {
-    GST_WARNING ("Invalid character '%c' at offset %lu in structure name: %s",
-        *s, ((gulong) s - (gulong) name), name);
+    GST_WARNING ("Invalid character '%c' at offset %" G_GUINTPTR_FORMAT " in"
+        " structure name: %s", *s, ((guintptr) s - (guintptr) name), name);
     return FALSE;
   }
 
@@ -2839,9 +2839,9 @@ wrong_type:
  * (as a GType), pointer(s) to a variable(s) to hold the return value(s).
  * The last variable argument should be NULL.
  *
- * For refcounted (mini)objects you will acquire your own reference which
+ * For refcounted (mini)objects you will receive a new reference which
  * you must release with a suitable _unref() when no longer needed. For
- * strings and boxed types you will acquire a copy which you will need to
+ * strings and boxed types you will receive a copy which you will need to
  * release with either g_free() or the suitable function for the boxed type.
  *
  * Returns: FALSE if there was a problem reading any of the fields (e.g.
@@ -2884,9 +2884,9 @@ gst_structure_get (const GstStructure * structure, const char *first_fieldname,
  * more efficient since it saves the string-to-quark lookup in the global
  * quark hashtable.
  *
- * For refcounted (mini)objects you will acquire your own reference which
+ * For refcounted (mini)objects you will receive a new reference which
  * you must release with a suitable _unref() when no longer needed. For
- * strings and boxed types you will acquire a copy which you will need to
+ * strings and boxed types you will receive a copy which you will need to
  * release with either g_free() or the suitable function for the boxed type.
  *
  * Returns: FALSE if there was a problem reading any of the fields (e.g.
@@ -2937,7 +2937,7 @@ gst_structure_is_equal_foreach (GQuark field_id, const GValue * val2,
  *
  * Returns: TRUE if the two structures have the same name and field.
  *
- * Since: 0.10.35
+ * Since: 0.10.36
  **/
 gboolean
 gst_structure_is_equal (const GstStructure * structure1,
@@ -2946,6 +2946,9 @@ gst_structure_is_equal (const GstStructure * structure1,
   g_return_val_if_fail (GST_IS_STRUCTURE (structure1), FALSE);
   g_return_val_if_fail (GST_IS_STRUCTURE (structure2), FALSE);
 
+  if (G_UNLIKELY (structure1 == structure2))
+    return TRUE;
+
   if (structure1->name != structure2->name) {
     return FALSE;
   }
@@ -3006,7 +3009,7 @@ gst_structure_intersect_field2 (GQuark id, const GValue * val1, gpointer data)
  *
  * Returns: Intersection of @struct1 and @struct2
  *
- * Since: 0.10.35
+ * Since: 0.10.36
  */
 GstStructure *
 gst_structure_intersect (const GstStructure * struct1,
@@ -3056,10 +3059,7 @@ gst_caps_structure_can_intersect_field (GQuark id, const GValue * val1,
 
       if (eq == GST_VALUE_UNORDERED) {
         /* we need to try interseting */
-        GValue dest_value = { 0 };
-        if (gst_value_intersect (&dest_value, val1, val2)) {
-          g_value_unset (&dest_value);
-        } else {
+        if (!gst_value_intersect (NULL, val1, val2)) {
           return FALSE;
         }
       } else if (eq != GST_VALUE_EQUAL) {
@@ -3080,7 +3080,7 @@ gst_caps_structure_can_intersect_field (GQuark id, const GValue * val1,
  *
  * Returns: %TRUE if intersection would not be empty
  *
- * Since: 0.10.35
+ * Since: 0.10.36
  */
 gboolean
 gst_structure_can_intersect (const GstStructure * struct1,
@@ -3093,11 +3093,8 @@ gst_structure_can_intersect (const GstStructure * struct1,
     return FALSE;
 
   /* tries to intersect if we have the field in both */
-  if (G_UNLIKELY (!gst_structure_foreach ((GstStructure *) struct1,
-              gst_caps_structure_can_intersect_field, (gpointer) struct2)))
-    return FALSE;
-
-  return TRUE;
+  return gst_structure_foreach ((GstStructure *) struct1,
+      gst_caps_structure_can_intersect_field, (gpointer) struct2);
 }
 
 static gboolean
@@ -3105,17 +3102,23 @@ gst_caps_structure_is_subset_field (GQuark field_id, const GValue * value,
     gpointer user_data)
 {
   GstStructure *superset = user_data;
-  GValue subtraction = { 0, };
   const GValue *other;
+  int comparison;
 
   if (!(other = gst_structure_id_get_value (superset, field_id)))
     /* field is missing in the superset => is subset */
     return TRUE;
 
+  comparison = gst_value_compare (other, value);
+
   /* equal values are subset */
-  if (gst_value_compare (other, value) == GST_VALUE_EQUAL)
+  if (comparison == GST_VALUE_EQUAL)
     return TRUE;
 
+  /* ordered, but unequal, values are not */
+  if (comparison != GST_VALUE_UNORDERED)
+    return FALSE;
+
   /*
    * 1 - [1,2] = empty
    * -> !subset
@@ -3134,14 +3137,12 @@ gst_caps_structure_is_subset_field (GQuark field_id, const GValue * value,
    *
    *  First caps subtraction needs to return a non-empty set, second
    *  subtractions needs to give en empty set.
+   *  Both substractions are switched below, as it's faster that way.
    */
-  if (gst_value_subtract (&subtraction, other, value)) {
-    g_value_unset (&subtraction);
-    /* !empty result, swapping must be empty */
-    if (!gst_value_subtract (&subtraction, value, other))
+  if (!gst_value_subtract (NULL, value, other)) {
+    if (gst_value_subtract (NULL, other, value)) {
       return TRUE;
-
-    g_value_unset (&subtraction);
+    }
   }
   return FALSE;
 }
@@ -3157,7 +3158,7 @@ gst_caps_structure_is_subset_field (GQuark field_id, const GValue * value,
  *
  * Returns: %TRUE if @subset is a subset of @superset
  *
- * Since: 0.10.35
+ * Since: 0.10.36
  */
 gboolean
 gst_structure_is_subset (const GstStructure * subset,