From a3fb0b3d0aec6477c205e7300dd19e54fee20d54 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Aug 2024 17:43:24 +0200 Subject: libcamera: pipeline_handler: Fix unlocking media devices too early PipelineHandler::acquire() only locks the media devices when the first camera is acquired. If a second camera of a pipeline is acquired only useCount_ is increased and nothing else is done. When releasing cameras PipelineHandler::release() should only unlock the media devices when the last camera is released. But the old code unlocked on every release(). Fix PipelineHandler::release() to only release the media devices when the last camera is released. Signed-off-by: Hans de Goede Reviewed-by: Harvey Yang Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline_handler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 5a6de685..a20cd27d 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -205,7 +205,8 @@ void PipelineHandler::release(Camera *camera) ASSERT(useCount_); - unlockMediaDevices(); + if (useCount_ == 1) + unlockMediaDevices(); releaseDevice(camera); -- cgit v1.2.1