X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fgststructure.c;h=cc3d1f4a18cf7c23dd645b048176a0bbd163b900;hb=790f193d632979b1fc0e7e851837b9f8f3a59d1a;hp=5f7aad228de80e44620eaa7d0ebe9556ab48fdc1;hpb=6dba0d91ed54bc651dc7cb09d157a772e618b4c2;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gststructure.c b/gst/gststructure.c index 5f7aad2..cc3d1f4 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -395,6 +395,30 @@ gst_structure_free (GstStructure * structure) } /** + * gst_clear_structure: (skip) + * @structure_ptr: a pointer to a #GstStructure reference + * + * Clears a reference to a #GstStructure. + * + * @structure_ptr must not be %NULL. + * + * If the reference is %NULL then this function does nothing. + * Otherwise, the structure is free'd using gst_structure_free() and the + * pointer is set to %NULL. + * + * A macro is also included that allows this function to be used without + * pointer casts. + * + * Since: 1.16 + **/ +#undef gst_clear_structure +void +gst_clear_structure (GstStructure ** structure_ptr) +{ + g_clear_pointer (structure_ptr, gst_structure_free); +} + +/** * gst_structure_get_name: * @structure: a #GstStructure * @@ -607,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); @@ -673,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); @@ -2182,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) { @@ -3038,13 +3070,13 @@ _gst_structure_get_any_list (GstStructure * structure, GType type, * @array: (out): a pointer to a #GValueArray * * This is useful in language bindings where unknown #GValue types are not - * supported. This function will convert the %GST_TYPE_ARRAY and - * %GST_TYPE_LIST into a newly allocated #GValueArray and return it through - * @array. Be aware that this is slower then getting the #GValue directly. + * supported. This function will convert the %GST_TYPE_ARRAY into a newly + * allocated #GValueArray and return it through @array. Be aware that this is + * slower then getting the #GValue directly. * * Returns: %TRUE if the value could be set correctly. If there was no field - * with @fieldname or the existing field did not contain an int, this function - * returns %FALSE. + * with @fieldname or the existing field did not contain a %GST_TYPE_ARRAY, + * this function returns %FALSE. */ gboolean gst_structure_get_array (GstStructure * structure, const gchar * fieldname, @@ -3061,13 +3093,13 @@ gst_structure_get_array (GstStructure * structure, const gchar * fieldname, * @array: (out): a pointer to a #GValueArray * * This is useful in language bindings where unknown #GValue types are not - * supported. This function will convert the %GST_TYPE_ARRAY and - * %GST_TYPE_LIST into a newly allocated GValueArray and return it through - * @array. Be aware that this is slower then getting the #GValue directly. + * supported. This function will convert the %GST_TYPE_LIST into a newly + * allocated GValueArray and return it through @array. Be aware that this is + * slower then getting the #GValue directly. * * Returns: %TRUE if the value could be set correctly. If there was no field - * with @fieldname or the existing field did not contain an int, this function - * returns %FALSE. + * with @fieldname or the existing field did not contain a %GST_TYPE_LIST, this + * function returns %FALSE. * * Since 1.12 */ @@ -3133,9 +3165,9 @@ gst_structure_set_array (GstStructure * structure, const gchar * fieldname, * @array: a pointer to a #GValueArray * * This is useful in language bindings where unknown GValue types are not - * supported. This function will convert a @array to %GST_TYPE_ARRAY and set + * supported. This function will convert a @array to %GST_TYPE_LIST and set * the field specified by @fieldname. Be aware that this is slower then using - * %GST_TYPE_ARRAY in a #GValue directly. + * %GST_TYPE_LIST in a #GValue directly. * * Since 1.12 */