memory: add method to check memory type

Add a method to check if a memory was allocated from an allocator of
a given type.

API: gst_memory_is_type()
This commit is contained in:
Wim Taymans 2013-02-26 15:37:24 +01:00
parent b339b0c12e
commit 4df4fd33b1
3 changed files with 26 additions and 0 deletions

View file

@ -1345,6 +1345,8 @@ GstMemoryIsSpanFunction
gst_memory_init
gst_memory_is_type
gst_memory_ref
gst_memory_unref

View file

@ -138,6 +138,27 @@ gst_memory_init (GstMemory * mem, GstMemoryFlags flags,
offset, size);
}
/**
* gst_memory_is_type:
* @mem: a #GstMemory
* @mem_type: a memory type
*
* Check if @mem if allocated with an allocator for @mem_type.
*
* Returns: %TRUE if @mem was allocated from an allocator for @mem_type.
*
* Since: 1.2
*/
gboolean
gst_memory_is_type (GstMemory * mem, const gchar * mem_type)
{
g_return_val_if_fail (mem != NULL, FALSE);
g_return_val_if_fail (mem->allocator != NULL, FALSE);
g_return_val_if_fail (mem_type != NULL, FALSE);
return (g_strcmp0 (mem->allocator->mem_type, mem_type) == 0);
}
/**
* gst_memory_get_sizes:
* @mem: a #GstMemory

View file

@ -287,6 +287,9 @@ void gst_memory_init (GstMemory *mem, GstMemoryFlags flags,
GstAllocator *allocator, GstMemory *parent,
gsize maxsize, gsize align,
gsize offset, gsize size);
gboolean gst_memory_is_type (GstMemory *mem, const gchar *mem_type);
/* refcounting */
/**
* gst_memory_ref: