mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
query: add method to remove allocation_meta
Also g_return_if_fail for out-of-bounds access instead of silently failing.
This commit is contained in:
parent
d6a28a6e3a
commit
b1dfe92f5c
2 changed files with 37 additions and 22 deletions
|
@ -1500,9 +1500,7 @@ gst_query_parse_nth_buffering_range (GstQuery * query, guint index,
|
||||||
|
|
||||||
array = ensure_array (structure, GST_QUARK (BUFFERING_RANGES),
|
array = ensure_array (structure, GST_QUARK (BUFFERING_RANGES),
|
||||||
sizeof (GstQueryBufferingRange), NULL);
|
sizeof (GstQueryBufferingRange), NULL);
|
||||||
|
g_return_val_if_fail (index < array->len, FALSE);
|
||||||
if (index >= array->len)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
range = &g_array_index (array, GstQueryBufferingRange, index);
|
range = &g_array_index (array, GstQueryBufferingRange, index);
|
||||||
|
|
||||||
|
@ -1770,7 +1768,6 @@ GType
|
||||||
gst_query_parse_nth_allocation_meta (GstQuery * query, guint index)
|
gst_query_parse_nth_allocation_meta (GstQuery * query, guint index)
|
||||||
{
|
{
|
||||||
GArray *array;
|
GArray *array;
|
||||||
GType ret = 0;
|
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
|
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
|
||||||
|
@ -1778,10 +1775,32 @@ gst_query_parse_nth_allocation_meta (GstQuery * query, guint index)
|
||||||
structure = GST_QUERY_STRUCTURE (query);
|
structure = GST_QUERY_STRUCTURE (query);
|
||||||
array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
|
array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
|
||||||
|
|
||||||
if (index < array->len)
|
g_return_val_if_fail (index < array->len, 0);
|
||||||
ret = g_array_index (array, GType, index);
|
|
||||||
|
|
||||||
return ret;
|
return g_array_index (array, GType, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_query_remove_nth_allocation_meta:
|
||||||
|
* @query: a GST_QUERY_ALLOCATION type query #GstQuery
|
||||||
|
* @index: position in the metadata API array to remove
|
||||||
|
*
|
||||||
|
* Remove the metadata API at @index of the metadata API array.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_query_remove_nth_allocation_meta (GstQuery * query, guint index)
|
||||||
|
{
|
||||||
|
GArray *array;
|
||||||
|
GstStructure *structure;
|
||||||
|
|
||||||
|
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
|
||||||
|
g_return_if_fail (gst_query_is_writable (query));
|
||||||
|
|
||||||
|
structure = GST_QUERY_STRUCTURE (query);
|
||||||
|
array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
|
||||||
|
g_return_if_fail (index < array->len);
|
||||||
|
|
||||||
|
g_array_remove_index (array, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1882,7 +1901,6 @@ GstAllocator *
|
||||||
gst_query_parse_nth_allocation_memory (GstQuery * query, guint index)
|
gst_query_parse_nth_allocation_memory (GstQuery * query, guint index)
|
||||||
{
|
{
|
||||||
GArray *array;
|
GArray *array;
|
||||||
GstAllocator *ret = NULL;
|
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, NULL);
|
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, NULL);
|
||||||
|
@ -1891,11 +1909,9 @@ gst_query_parse_nth_allocation_memory (GstQuery * query, guint index)
|
||||||
array =
|
array =
|
||||||
ensure_array (structure, GST_QUARK (ALLOCATOR), sizeof (GstAllocator *),
|
ensure_array (structure, GST_QUARK (ALLOCATOR), sizeof (GstAllocator *),
|
||||||
(GDestroyNotify) gst_allocator_unref);
|
(GDestroyNotify) gst_allocator_unref);
|
||||||
|
g_return_val_if_fail (index < array->len, NULL);
|
||||||
|
|
||||||
if (index < array->len)
|
return g_array_index (array, GstAllocator *, index);
|
||||||
ret = g_array_index (array, GstAllocator *, index);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2036,20 +2052,18 @@ gst_query_get_n_scheduling_modes (GstQuery * query)
|
||||||
GstPadMode
|
GstPadMode
|
||||||
gst_query_parse_nth_scheduling_mode (GstQuery * query, guint index)
|
gst_query_parse_nth_scheduling_mode (GstQuery * query, guint index)
|
||||||
{
|
{
|
||||||
GstPadMode ret = GST_PAD_MODE_NONE;
|
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
GArray *array;
|
GArray *array;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING, ret);
|
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING,
|
||||||
|
GST_PAD_MODE_NONE);
|
||||||
|
|
||||||
structure = GST_QUERY_STRUCTURE (query);
|
structure = GST_QUERY_STRUCTURE (query);
|
||||||
array =
|
array =
|
||||||
ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
|
ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
|
||||||
|
g_return_val_if_fail (index < array->len, GST_PAD_MODE_NONE);
|
||||||
|
|
||||||
if (index < array->len)
|
return g_array_index (array, GstPadMode, index);
|
||||||
ret = g_array_index (array, GstPadMode, index);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -372,10 +372,11 @@ void gst_query_parse_allocation_params (GstQuery *query, guint *size,
|
||||||
guint *max_buffers, guint *prefix, guint *alignment,
|
guint *max_buffers, guint *prefix, guint *alignment,
|
||||||
GstBufferPool **pool);
|
GstBufferPool **pool);
|
||||||
|
|
||||||
void gst_query_add_allocation_meta (GstQuery *query, GType api);
|
void gst_query_add_allocation_meta (GstQuery *query, GType api);
|
||||||
guint gst_query_get_n_allocation_metas (GstQuery *query);
|
guint gst_query_get_n_allocation_metas (GstQuery *query);
|
||||||
GType gst_query_parse_nth_allocation_meta (GstQuery *query, guint index);
|
GType gst_query_parse_nth_allocation_meta (GstQuery *query, guint index);
|
||||||
gboolean gst_query_has_allocation_meta (GstQuery *query, GType api);
|
void gst_query_remove_nth_allocation_meta (GstQuery *query, guint index);
|
||||||
|
gboolean gst_query_has_allocation_meta (GstQuery *query, GType api);
|
||||||
|
|
||||||
void gst_query_add_allocation_memory (GstQuery *query, GstAllocator *allocator);
|
void gst_query_add_allocation_memory (GstQuery *query, GstAllocator *allocator);
|
||||||
guint gst_query_get_n_allocation_memories (GstQuery *query);
|
guint gst_query_get_n_allocation_memories (GstQuery *query);
|
||||||
|
|
Loading…
Reference in a new issue