aggregator: Assert if the sink/src pad type that is to be used is not a GstAggregator...
[platform/upstream/gstreamer.git] / gst / gststructure.c
index dae2b63..ee60ce0 100644 (file)
@@ -413,7 +413,7 @@ gst_structure_free (GstStructure * structure)
  **/
 #undef gst_clear_structure
 void
-gst_clear_structure (volatile GstStructure ** structure_ptr)
+gst_clear_structure (GstStructure ** structure_ptr)
 {
   g_clear_pointer (structure_ptr, gst_structure_free);
 }
@@ -631,6 +631,7 @@ gst_structure_set_valist_internal (GstStructure * structure,
     G_VALUE_COLLECT_INIT (&field.value, type, varargs, 0, &err);
     if (G_UNLIKELY (err)) {
       g_critical ("%s", err);
+      g_free (err);
       return;
     }
     gst_structure_set_field (structure, &field);
@@ -697,6 +698,7 @@ gst_structure_id_set_valist_internal (GstStructure * structure,
     G_VALUE_COLLECT_INIT (&field.value, type, varargs, 0, &err);
     if (G_UNLIKELY (err)) {
       g_critical ("%s", err);
+      g_free (err);
       return;
     }
     gst_structure_set_field (structure, &field);
@@ -2206,14 +2208,20 @@ gst_structure_fixate_field_nearest_int (GstStructure * structure,
     /* already fixed */
     return FALSE;
   } else if (G_VALUE_TYPE (value) == GST_TYPE_INT_RANGE) {
-    int x;
+    int min, max, step;
+
+    min = gst_value_get_int_range_min (value);
+    max = gst_value_get_int_range_max (value);
+    step = gst_value_get_int_range_step (value);
+
+    target = CLAMP (target, min, max);
+    if (G_UNLIKELY (step != 1)) {
+      gint rem = target % step;
+      target -= rem;
+      if (rem > step / 2)
+        target += step;
+    }
 
-    x = gst_value_get_int_range_min (value);
-    if (target < x)
-      target = x;
-    x = gst_value_get_int_range_max (value);
-    if (target > x)
-      target = x;
     gst_structure_set (structure, field_name, G_TYPE_INT, target, NULL);
     return TRUE;
   } else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
@@ -3093,7 +3101,7 @@ gst_structure_get_array (GstStructure * structure, const gchar * fieldname,
  * with @fieldname or the existing field did not contain a %GST_TYPE_LIST, this
  * function returns %FALSE.
  *
- * Since 1.12
+ * Since: 1.12
  */
 gboolean
 gst_structure_get_list (GstStructure * structure, const gchar * fieldname,
@@ -3141,7 +3149,7 @@ _gst_structure_set_any_list (GstStructure * structure, GType type,
  * the field specified by @fieldname.  Be aware that this is slower then using
  * %GST_TYPE_ARRAY in a #GValue directly.
  *
- * Since 1.12
+ * Since: 1.12
  */
 void
 gst_structure_set_array (GstStructure * structure, const gchar * fieldname,
@@ -3161,7 +3169,7 @@ gst_structure_set_array (GstStructure * structure, const gchar * fieldname,
  * the field specified by @fieldname. Be aware that this is slower then using
  * %GST_TYPE_LIST in a #GValue directly.
  *
- * Since 1.12
+ * Since: 1.12
  */
 void
 gst_structure_set_list (GstStructure * structure, const gchar * fieldname,