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.
This commit is contained in:
Nicolas Dufresne 2014-05-05 12:38:33 -04:00 committed by Nicolas Dufresne
parent 1304c74c6a
commit dfdd1ba9d9

View file

@ -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,
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