diff options
author | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2019-02-05 13:42:14 +0100 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-02-06 07:41:51 +0200 |
commit | 31bb25ae8d6dc669dddabf47d18c517ce9070578 (patch) | |
tree | 8927e71cf2d2f40a9a57c847ab97e03747495ea3 | |
parent | 5239f6e656d77bdbc66a93714b5a0b31a879c0cc (diff) |
libcamera: camera: Add helper to check for exclusive access
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 <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | include/libcamera/camera.h | 1 | ||||
-rw-r--r-- | src/libcamera/camera.cpp | 22 |
2 files changed, 19 insertions, 4 deletions
diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index bbe2696e..36bf1cbb 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -50,6 +50,7 @@ private: friend class PipelineHandler; void disconnect(); + int exclusiveAccess(); std::shared_ptr<PipelineHandler> pipe_; std::string name_; 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 @@ -241,16 +241,30 @@ Camera::streamConfiguration(std::vector<Stream *> &streams) */ int Camera::configureStreams(std::map<Stream *, StreamConfiguration> &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; if (!acquired_) return -EACCES; - if (!config.size()) - return -EINVAL; - - return pipe_->configureStreams(this, config); + return 0; } } /* namespace libcamera */ |