custom memory allocate and free function

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

custom memory allocate and free function

ChrisLiuv
Hi,

In my platform it has its own memory allocate and free function, similar to malloc() and free(), it allocates a physical continuous memory and could be used by gpu.

Currently I use the default allocator as below:

    buffers_out[i] = gst_buffer_new ();
    memory = gst_allocator_alloc (NULL, bufsize, NULL);
    gst_buffer_insert_memory (buffers_out[i], -1, memory);

It looks not trivial to modify.
Is there an example to demonstrate how to custom an allocator?
I searched on google but seems not that easy.
Thanks a lot.
Reply | Threaded
Open this post in threaded view
|

Re: custom memory allocate and free function

ChrisLiuv
I found that the

GST_API
GstBuffer * gst_buffer_new_wrapped_full    (GstMemoryFlags flags, gpointer data, gsize maxsize,
                                            gsize offset, gsize size, gpointer user_data,
                                            GDestroyNotify notify);

could do what I want.

My memory allocate function gives both virtual address and physical address,
using the virtual address to do my task works normally,
now the problem is how to set the physical address for downstream element usage?

The first argument flags could be set as GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS, but I'm wondering how could downstream element get physical address?

Thanks a lot.