meta: simplify a bit

This commit is contained in:
Wim Taymans 2011-02-27 20:54:58 +01:00
parent 362a724cfb
commit cb86bf99bc
2 changed files with 16 additions and 15 deletions

View file

@ -123,15 +123,17 @@ typedef struct
} GstMetaMemoryImpl; } GstMetaMemoryImpl;
static gpointer static gpointer
meta_memory_mmap (GstMetaMemoryImpl * meta, gsize offset, gsize * size, meta_memory_mmap (GstMetaMemory * meta, gsize offset, gsize * size,
GstMetaMapFlags flags) GstMetaMapFlags flags)
{ {
*size = meta->params.size - offset; GstMetaMemoryImpl *impl = (GstMetaMemoryImpl *) meta;
return meta->params.data + offset;
*size = impl->params.size - offset;
return impl->params.data + offset;
} }
static gboolean static gboolean
meta_memory_munmap (GstMetaMemoryImpl * meta, gpointer data, gsize size) meta_memory_munmap (GstMetaMemory * meta, gpointer data, gsize size)
{ {
return TRUE; return TRUE;
} }
@ -140,8 +142,8 @@ static gboolean
meta_memory_init (GstMetaMemoryImpl * meta, GstMetaMemoryParams * params, meta_memory_init (GstMetaMemoryImpl * meta, GstMetaMemoryParams * params,
GstBuffer * buffer) GstBuffer * buffer)
{ {
meta->memory.mmap_func = (GstMetaMapFunc) meta_memory_mmap; meta->memory.mmap_func = meta_memory_mmap;
meta->memory.munmap_func = (GstMetaUnmapFunc) meta_memory_munmap; meta->memory.munmap_func = meta_memory_munmap;
meta->params = *params; meta->params = *params;
return TRUE; return TRUE;
} }

View file

@ -147,29 +147,28 @@ const GstMetaInfo * gst_meta_get_info (const gchar * impl);
typedef struct _GstMetaMemory GstMetaMemory; typedef struct _GstMetaMemory GstMetaMemory;
const GstMetaInfo *gst_meta_memory_get_info(void);
#define GST_META_MEMORY_INFO (gst_meta_memory_get_info())
typedef enum { typedef enum {
GST_META_MAP_NONE = 0, GST_META_MAP_NONE = 0,
GST_META_MAP_READ = (1 << 0), GST_META_MAP_READ = (1 << 0),
GST_META_MAP_WRITE = (1 << 1) GST_META_MAP_WRITE = (1 << 1)
} GstMetaMapFlags; } GstMetaMapFlags;
typedef gpointer (*GstMetaMapFunc) (GstMetaMemory *meta, guint offset, guint *size,
GstMetaMapFlags flags);
typedef gboolean (*GstMetaUnmapFunc) (GstMetaMemory *meta, gpointer data, guint size);
struct _GstMetaMemory struct _GstMetaMemory
{ {
GstMeta meta; GstMeta meta;
GstMetaMapFunc mmap_func; gpointer (*mmap_func) (GstMetaMemory *meta, gsize offset, gsize *size,
GstMetaUnmapFunc munmap_func; GstMetaMapFlags flags);
gboolean (*munmap_func) (GstMetaMemory *meta, gpointer data, gsize size);
}; };
#define gst_meta_memory_map(m,o,s,f) ((m)->mmap_func(m, o, s, f)) #define gst_meta_memory_map(m,o,s,f) ((m)->mmap_func(m, o, s, f))
#define gst_meta_memory_unmap(m,d,s) ((m)->munmap_func(m, d, s)) #define gst_meta_memory_unmap(m,d,s) ((m)->munmap_func(m, d, s))
const GstMetaInfo *gst_meta_memory_get_info(void); #define gst_buffer_get_meta_memory(b) ((GstMetaMemory*)gst_buffer_get_meta((b),GST_META_MEMORY_INFO))
#define GST_META_MEMORY_INFO (gst_meta_memory_get_info())
GstMetaMemory * gst_buffer_add_meta_memory (GstBuffer *buffer, gpointer data, GstMetaMemory * gst_buffer_add_meta_memory (GstBuffer *buffer, gpointer data,
GFreeFunc free_func, GFreeFunc free_func,