query: gst_query_add_buffering_range() optimisations

Don't create a new GValueArray copy for every single _add_buffering_range()
call, but append to the existing value array owned by the structure instead.
This commit is contained in:
Tim-Philipp Müller 2010-09-16 00:30:14 +01:00
parent 608628d10d
commit 58e5d5e5b9

View file

@ -1321,19 +1321,26 @@ gst_query_add_buffering_range (GstQuery * query, gint64 start, gint64 stop)
if (start > gst_value_get_int64_range_min (last_array_value))
ret = TRUE;
} else {
GValue new_array_val = { 0, };
array = g_value_array_new (0);
g_value_init (&new_array_val, G_TYPE_VALUE_ARRAY);
g_value_take_boxed (&new_array_val, array);
/* set the value array only once, so we then modify (append to) the
* existing value array owned by the GstStructure / the field's GValue */
gst_structure_id_take_value (structure, GST_QUARK (BUFFERING_RANGES),
&new_array_val);
ret = TRUE;
}
if (ret) {
g_value_array_append (array, &range_value);
gst_structure_id_set (structure, GST_QUARK (BUFFERING_RANGES),
G_TYPE_VALUE_ARRAY, array, NULL);
}
g_value_unset (&range_value);
if (!value)
g_value_array_free (array);
return ret;
}