[libcamera-devel] [PATCH v2 03/13] libcamera: camera_manager: Return a copy of the vector from cameras()

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Jan 22 21:57:13 CET 2020


Making CameraManager::cameras() thread-safe requires returning a copy of
the cameras vector instead of a reference. This is also required for
hot-plugging support and is thus desirable.

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 include/libcamera/camera_manager.h | 2 +-
 src/libcamera/camera_manager.cpp   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h
index 068afd58762f..079f848aec79 100644
--- a/include/libcamera/camera_manager.h
+++ b/include/libcamera/camera_manager.h
@@ -30,7 +30,7 @@ public:
 	int start();
 	void stop();
 
-	const std::vector<std::shared_ptr<Camera>> &cameras() const;
+	std::vector<std::shared_ptr<Camera>> cameras() const;
 	std::shared_ptr<Camera> get(const std::string &name);
 	std::shared_ptr<Camera> get(dev_t devnum);
 
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index e0a07ec557d3..5fc1bba974c6 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -244,7 +244,7 @@ void CameraManager::stop()
  *
  * \return List of all available cameras
  */
-const std::vector<std::shared_ptr<Camera>> &CameraManager::cameras() const
+std::vector<std::shared_ptr<Camera>> CameraManager::cameras() const
 {
 	return p_->cameras_;
 }
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list