From 429c0e03a3cb49631638627e4097119fd26905f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 24 Jul 2025 16:27:23 +0200 Subject: [PATCH] spa: libcamera: source: do not close fd Currently the plugin does not support importing memory and uses `libcamera::FrameBufferAllocator` to allocate memory. Every file descriptor is managed by that object, so they must not be closed manually. --- spa/plugins/libcamera/libcamera-source.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/spa/plugins/libcamera/libcamera-source.cpp b/spa/plugins/libcamera/libcamera-source.cpp index c989559c3..d833d756f 100644 --- a/spa/plugins/libcamera/libcamera-source.cpp +++ b/spa/plugins/libcamera/libcamera-source.cpp @@ -50,8 +50,7 @@ namespace { #define MASK_BUFFERS 31 #define BUFFER_FLAG_OUTSTANDING (1<<0) -#define BUFFER_FLAG_ALLOCATED (1<<1) -#define BUFFER_FLAG_MAPPED (1<<2) +#define BUFFER_FLAG_MAPPED (1<<1) struct buffer { uint32_t id; @@ -358,9 +357,7 @@ int spa_libcamera_clear_buffers(struct impl *impl, struct port *port) munmap(SPA_PTROFF(b->ptr, -d[0].mapoffset, void), d[0].maxsize - d[0].mapoffset); } - if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_ALLOCATED)) { - close(d[0].fd); - } + d[0].type = SPA_ID_INVALID; } @@ -1125,7 +1122,6 @@ spa_libcamera_alloc_buffers(struct impl *impl, struct port *port, d[j].fd = bufs[i]->planes()[j].fd.get(); spa_log_debug(impl->log, "Got fd = %" PRId64 " for buffer: #%d", d[j].fd, i); d[j].data = nullptr; - SPA_FLAG_SET(b->flags, BUFFER_FLAG_ALLOCATED); } else if (port->memtype == SPA_DATA_MemPtr) { d[j].fd = -1;