v4l2: allocator: Don't close foreign dmabuf

Imported dmabuf are not being duped, so they should never be closed. Instead,
we ensure their live time by having strong reference on their original
buffer. This should fix potential flickering due to dmabuf being closed
too early.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5217>
This commit is contained in:
Nicolas Dufresne 2023-07-25 15:14:11 -04:00 committed by Tim-Philipp Müller
parent df9482f39b
commit 426bf399d4

View file

@ -357,7 +357,6 @@ gst_v4l2_allocator_release (GstV4l2Allocator * allocator, GstV4l2Memory * mem)
switch (allocator->memory) {
case V4L2_MEMORY_DMABUF:
close (mem->dmafd);
mem->dmafd = -1;
break;
case V4L2_MEMORY_USERPTR:
@ -396,8 +395,7 @@ gst_v4l2_allocator_free (GstAllocator * gallocator, GstMemory * gmem)
obj->munmap (mem->data, group->planes[mem->plane].length);
}
/* This apply for both mmap with expbuf, and dmabuf imported memory */
if (mem->dmafd >= 0)
if (allocator->memory == V4L2_MEMORY_MMAP && mem->dmafd >= 0)
close (mem->dmafd);
}