Commit dfdd1ba9 authored by Nicolas Dufresne's avatar Nicolas Dufresne Committed by Nicolas Dufresne

v4l2allocator: Reset imported buffer size with expected size

This ensure that the buffer pool won't always discard buffer with these
memory when they are released.
parent 1304c74c
...@@ -560,17 +560,33 @@ gst_v4l2_allocator_reset_size (GstV4l2Allocator * allocator, ...@@ -560,17 +560,33 @@ gst_v4l2_allocator_reset_size (GstV4l2Allocator * allocator,
GstV4l2MemoryGroup * group) GstV4l2MemoryGroup * group)
{ {
gsize size; gsize size;
gboolean imported = FALSE;
switch (allocator->memory) {
case V4L2_MEMORY_USERPTR:
case V4L2_MEMORY_DMABUF:
imported = TRUE;
break;
}
if (V4L2_TYPE_IS_MULTIPLANAR (allocator->type)) { if (V4L2_TYPE_IS_MULTIPLANAR (allocator->type)) {
gint i; gint i;
for (i = 0; i < group->n_mem; i++) { for (i = 0; i < group->n_mem; i++) {
size = allocator->format.fmt.pix_mp.plane_fmt[i].sizeimage; size = allocator->format.fmt.pix_mp.plane_fmt[i].sizeimage;
if (imported)
group->mem[i]->maxsize = size;
gst_memory_resize (group->mem[i], 0, size); gst_memory_resize (group->mem[i], 0, size);
} }
} else { } else {
size = allocator->format.fmt.pix.sizeimage; size = allocator->format.fmt.pix.sizeimage;
if (imported)
group->mem[0]->maxsize = size;
gst_memory_resize (group->mem[0], 0, size); gst_memory_resize (group->mem[0], 0, size);
} }
} }
...@@ -1356,12 +1372,13 @@ gst_v4l2_allocator_reset_group (GstV4l2Allocator * allocator, ...@@ -1356,12 +1372,13 @@ gst_v4l2_allocator_reset_group (GstV4l2Allocator * allocator,
gst_v4l2_allocator_clear_dmabufin (allocator, group); gst_v4l2_allocator_clear_dmabufin (allocator, group);
break; break;
case V4L2_MEMORY_MMAP: case V4L2_MEMORY_MMAP:
gst_v4l2_allocator_reset_size (allocator, group);
break; break;
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
} }
gst_v4l2_allocator_reset_size (allocator, group);
} }
gsize gsize
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment