diff --git a/picamera2/allocators/dmaallocator.py b/picamera2/allocators/dmaallocator.py index da672d02..65c585d0 100644 --- a/picamera2/allocators/dmaallocator.py +++ b/picamera2/allocators/dmaallocator.py @@ -95,6 +95,8 @@ def close(self): os.close(fd) self.frame_buffers = {} self.open_fds = [] + if self.dmaHeap is not None: + self.dmaHeap.close() def __del__(self): self.close() diff --git a/picamera2/allocators/persistent_allocator.py b/picamera2/allocators/persistent_allocator.py index 106118a4..b2dc216f 100644 --- a/picamera2/allocators/persistent_allocator.py +++ b/picamera2/allocators/persistent_allocator.py @@ -47,6 +47,7 @@ def deallocate(self, buffer_key=None): buffer_key = self.buffer_key tmp = super().__new__(DmaAllocator) + tmp.dmaHeap = None (tmp.open_fds, tmp.libcamera_fds, tmp.frame_buffers, tmp.mapped_buffers, tmp.mapped_buffers_used) = self.buffer_dict[buffer_key] diff --git a/picamera2/dma_heap.py b/picamera2/dma_heap.py index 3b7e1a12..3ee7380e 100644 --- a/picamera2/dma_heap.py +++ b/picamera2/dma_heap.py @@ -107,3 +107,6 @@ def alloc(self, name, size) -> UniqueFD: return UniqueFD() return allocFd + + def close(self): + os.close(self.__dmaHeapHandle.get())