summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline_handler.cpp
diff options
context:
space:
mode:
authorUmang Jain <email@uajain.com>2020-06-16 19:45:37 +0000
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-06-17 00:27:54 +0300
commite9b47217b44cd775498e3fd676be50217d73ad41 (patch)
tree700d6cd04a8c79ab1255849e67a2b750769fecd2 /src/libcamera/pipeline_handler.cpp
parentdd21ededd0fe9dede5942b0b68c45d43f1d671bd (diff)
libcamera: camera_manager: Introduce signals when a camera is added or removed
Emit 'cameraAdded' and 'cameraRemoved' from CameraManager to enable hotplug and hot-unplug support in application like QCam. To avoid use-after-free race between the CameraManager and the application, emit the 'cameraRemoved' with the shared_ptr version of <Camera *>. This requires to change the function signature of CameraManager::removeCamera() API. Also, until now, CameraManager::Private::addCamera() transfers the entire ownership of camera shared_ptr to CameraManager using std::move(). This patch changes the signature of Private::addCamera to accept pass-by-value camera parameter. It is done to make it clear from the caller point of view that the pointer within the caller will still be valid after this function returns. With this change in, we can emit the camera pointer via 'cameraAdded' signal without hitting a segfault. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/pipeline_handler.cpp')
-rw-r--r--src/libcamera/pipeline_handler.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index 38c85779..14dfba0b 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -579,7 +579,7 @@ void PipelineHandler::disconnect()
continue;
camera->disconnect();
- manager_->removeCamera(camera.get());
+ manager_->removeCamera(camera);
}
}