From 31bb25ae8d6dc669dddabf47d18c517ce9070578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Tue, 5 Feb 2019 13:42:14 +0100 Subject: libcamera: camera: Add helper to check for exclusive access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some operations on the camera requires the application to have exclusive access to the camera. To help check for this in these operations add a helper. Signed-off-by: Niklas Söderlund Signed-off-by: Jacopo Mondi Signed-off-by: Kieran Bingham Signed-off-by: Laurent Pinchart --- src/libcamera/camera.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index e8dab6f0..62291d2c 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -240,6 +240,23 @@ Camera::streamConfiguration(std::vector &streams) * \retval -EINVAL The configuration is not valid */ int Camera::configureStreams(std::map &config) +{ + int ret; + + ret = exclusiveAccess(); + if (ret) + return ret; + + if (!config.size()) { + LOG(Camera, Error) + << "Can't configure streams without a configuration"; + return -EINVAL; + } + + return pipe_->configureStreams(this, config); +} + +int Camera::exclusiveAccess() { if (disconnected_) return -ENODEV; @@ -247,10 +264,7 @@ int Camera::configureStreams(std::map &config) if (!acquired_) return -EACCES; - if (!config.size()) - return -EINVAL; - - return pipe_->configureStreams(this, config); + return 0; } } /* namespace libcamera */ -- cgit v1.2.1