mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 22:06:41 +00:00
dmabuf: Make the allocator sub-classable
This should allos for cleaner code when implement such allocator. https://bugzilla.gnome.org/show_bug.cgi?id=768794
This commit is contained in:
parent
eddb543719
commit
c37b1e8c56
3 changed files with 53 additions and 18 deletions
|
@ -7,9 +7,19 @@
|
||||||
gst_dmabuf_allocator_new
|
gst_dmabuf_allocator_new
|
||||||
gst_dmabuf_allocator_alloc
|
gst_dmabuf_allocator_alloc
|
||||||
gst_dmabuf_memory_get_fd
|
gst_dmabuf_memory_get_fd
|
||||||
|
gst_dmabuf_allocator_get_type
|
||||||
gst_is_dmabuf_memory
|
gst_is_dmabuf_memory
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
|
GstDmaBufAllocator
|
||||||
|
GstDmaBufAllocatorClass
|
||||||
GST_ALLOCATOR_DMABUF
|
GST_ALLOCATOR_DMABUF
|
||||||
|
GST_DMABUF_ALLOCATOR
|
||||||
|
GST_DMABUF_ALLOCATOR_CAST
|
||||||
|
GST_DMABUF_ALLOCATOR_CLASS
|
||||||
|
GST_DMABUF_ALLOCATOR_GET_CLASS
|
||||||
|
GST_IS_DMABUF_ALLOCATOR
|
||||||
|
GST_IS_DMABUF_ALLOCATOR_CLASS
|
||||||
|
GST_TYPE_DMABUF_ALLOCATOR
|
||||||
<SUBSECTION Private>
|
<SUBSECTION Private>
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
|
|
@ -41,29 +41,15 @@
|
||||||
GST_DEBUG_CATEGORY_STATIC (dmabuf_debug);
|
GST_DEBUG_CATEGORY_STATIC (dmabuf_debug);
|
||||||
#define GST_CAT_DEFAULT dmabuf_debug
|
#define GST_CAT_DEFAULT dmabuf_debug
|
||||||
|
|
||||||
typedef struct
|
G_DEFINE_TYPE (GstDmaBufAllocator, gst_dmabuf_allocator, GST_TYPE_FD_ALLOCATOR);
|
||||||
{
|
|
||||||
GstFdAllocator parent;
|
|
||||||
} GstDmaBufAllocator;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GstFdAllocatorClass parent_class;
|
|
||||||
} GstDmaBufAllocatorClass;
|
|
||||||
|
|
||||||
GType dmabuf_mem_allocator_get_type (void);
|
|
||||||
G_DEFINE_TYPE (GstDmaBufAllocator, dmabuf_mem_allocator, GST_TYPE_FD_ALLOCATOR);
|
|
||||||
|
|
||||||
#define GST_TYPE_DMABUF_ALLOCATOR (dmabuf_mem_allocator_get_type())
|
|
||||||
#define GST_IS_DMABUF_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DMABUF_ALLOCATOR))
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dmabuf_mem_allocator_class_init (GstDmaBufAllocatorClass * klass)
|
gst_dmabuf_allocator_class_init (GstDmaBufAllocatorClass * klass)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dmabuf_mem_allocator_init (GstDmaBufAllocator * allocator)
|
gst_dmabuf_allocator_init (GstDmaBufAllocator * allocator)
|
||||||
{
|
{
|
||||||
GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator);
|
GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator);
|
||||||
|
|
||||||
|
@ -144,5 +130,7 @@ gst_dmabuf_memory_get_fd (GstMemory * mem)
|
||||||
gboolean
|
gboolean
|
||||||
gst_is_dmabuf_memory (GstMemory * mem)
|
gst_is_dmabuf_memory (GstMemory * mem)
|
||||||
{
|
{
|
||||||
return gst_memory_is_type (mem, GST_ALLOCATOR_DMABUF);
|
g_return_val_if_fail (mem != NULL, FALSE);
|
||||||
|
|
||||||
|
return GST_IS_DMABUF_ALLOCATOR (mem->allocator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,43 @@
|
||||||
#define __GST_DMABUF_H__
|
#define __GST_DMABUF_H__
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
#include <gst/allocators/gstfdmemory.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_ALLOCATOR_DMABUF "dmabuf"
|
#define GST_ALLOCATOR_DMABUF "dmabuf"
|
||||||
|
|
||||||
|
#define GST_TYPE_DMABUF_ALLOCATOR (gst_dmabuf_allocator_get_type())
|
||||||
|
#define GST_IS_DMABUF_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DMABUF_ALLOCATOR))
|
||||||
|
#define GST_IS_DMABUF_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DMABUF_ALLOCATOR))
|
||||||
|
#define GST_DMABUF_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DMABUF_ALLOCATOR, GstDmaBufAllocatorClass))
|
||||||
|
#define GST_DMABUF_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DMABUF_ALLOCATOR, GstDmaBufAllocator))
|
||||||
|
#define GST_DMABUF_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DMABUF_ALLOCATOR, GstDmaBufAllocatorClass))
|
||||||
|
#define GST_DMABUF_ALLOCATOR_CAST(obj) ((GstDmaBufAllocator *)(obj))
|
||||||
|
|
||||||
|
typedef struct _GstDmaBufAllocator GstDmaBufAllocator;
|
||||||
|
typedef struct _GstDmaBufAllocatorClass GstDmaBufAllocatorClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstDmaBufAllocator:
|
||||||
|
*
|
||||||
|
* Base class for allocators with dmabuf-backed memory
|
||||||
|
*
|
||||||
|
* Since: 1.12
|
||||||
|
*/
|
||||||
|
struct _GstDmaBufAllocator
|
||||||
|
{
|
||||||
|
GstFdAllocator parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstDmaBufAllocatorClass
|
||||||
|
{
|
||||||
|
GstFdAllocatorClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GType gst_dmabuf_allocator_get_type (void);
|
||||||
|
|
||||||
GstAllocator * gst_dmabuf_allocator_new (void);
|
GstAllocator * gst_dmabuf_allocator_new (void);
|
||||||
|
|
||||||
GstMemory * gst_dmabuf_allocator_alloc (GstAllocator * allocator, gint fd, gsize size);
|
GstMemory * gst_dmabuf_allocator_alloc (GstAllocator * allocator, gint fd, gsize size);
|
||||||
|
@ -35,5 +67,10 @@ gint gst_dmabuf_memory_get_fd (GstMemory * mem);
|
||||||
|
|
||||||
gboolean gst_is_dmabuf_memory (GstMemory * mem);
|
gboolean gst_is_dmabuf_memory (GstMemory * mem);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDmaBufAllocator, gst_object_unref)
|
||||||
|
#endif
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* __GST_DMABUF_H__ */
|
#endif /* __GST_DMABUF_H__ */
|
||||||
|
|
Loading…
Reference in a new issue