From 54ae2fcf774bb8a8dc98be5288540c1a65dd39ce Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 25 Jul 2023 15:14:11 -0400 Subject: [PATCH] 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: --- subprojects/gst-plugins-good/sys/v4l2/gstv4l2allocator.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2allocator.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2allocator.c index 33a5fd2cfc..129a4198d3 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2allocator.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2allocator.c @@ -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); }