GstMemory * gst_droid_media_buffer_allocator_alloc (GstAllocator * allocator, DroidMediaBufferQueue * queue, DroidMediaBufferCallbacks * cb) { GstDroidMediaBufferMemory *mem; DroidMediaBufferInfo info; DroidMediaBuffer *buffer; int format_index; if (!GST_IS_DROID_MEDIA_BUFFER_ALLOCATOR (allocator)) { GST_WARNING_OBJECT (allocator, "allocator is not the correct allocator for droidmediabuffer"); return NULL; } buffer = droid_media_buffer_queue_acquire_buffer (queue, cb); if (!buffer) { GST_ERROR_OBJECT (allocator, "failed to acquire media buffer"); return NULL; } droid_media_buffer_get_info (buffer, &info); format_index = gst_droid_media_buffer_index_of_hal_format (info.format); mem = gst_droid_media_buffer_allocator_alloc_from_buffer (allocator, buffer, format_index, info.width, info.height, info.stride); GST_DEBUG_OBJECT (allocator, "alloc %p", mem); return GST_MEMORY_CAST (mem); }
GstMemory * gst_droid_media_buffer_allocator_alloc (GstAllocator * allocator, DroidMediaBufferQueue * queue, DroidMediaBufferCallbacks * cb) { GstDroidMediaBufferMemory *mem; DroidMediaBuffer *buffer; gsize size; if (!GST_IS_DROID_MEDIA_BUFFER_ALLOCATOR (allocator)) { GST_WARNING_OBJECT (allocator, "allocator is not the correct allocator for droidmediabuffer"); return NULL; } mem = g_slice_new0 (GstDroidMediaBufferMemory); buffer = droid_media_buffer_queue_acquire_buffer (queue, cb); if (!buffer) { GST_ERROR_OBJECT (allocator, "failed to acquire media buffer"); g_slice_free (GstDroidMediaBufferMemory, mem); return NULL; } mem->buffer = buffer; /* This is not the correct size of the underlying buffer but there is no way to get that */ size = sizeof (buffer); gst_memory_init (GST_MEMORY_CAST (mem), GST_MEMORY_FLAG_NO_SHARE | GST_MEMORY_FLAG_NOT_MAPPABLE, allocator, NULL, size, 0, 0, size); GST_DEBUG_OBJECT (allocator, "alloc %p", mem); return GST_MEMORY_CAST (mem); }