diff options
author | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2019-04-14 02:58:28 +0200 |
---|---|---|
committer | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2019-05-17 20:35:33 +0200 |
commit | d07975950caded00edd9ba240f5737f10ae828a7 (patch) | |
tree | 725739b4919da17fd7ce3f0201738f7506d113d5 /src/libcamera | |
parent | d6a88607479937a9941f1ea2c82a7e5c66b20647 (diff) |
libcamera: pipeline_handler: Add functions to lock a whole pipeline
Add lock() and unlock() which are backed by the MediaDevice
implementation and lock all media devices claimed by a pipeline handler
instance.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera')
-rw-r--r-- | src/libcamera/include/pipeline_handler.h | 3 | ||||
-rw-r--r-- | src/libcamera/pipeline_handler.cpp | 36 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 8e6a136d..9f5fe3d6 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -57,6 +57,9 @@ public: MediaDevice *acquireMediaDevice(DeviceEnumerator *enumerator, const DeviceMatch &dm); + bool lock(); + void unlock(); + virtual CameraConfiguration streamConfiguration(Camera *camera, const std::vector<StreamUsage> &usages) = 0; virtual int configureStreams(Camera *camera, const CameraConfiguration &config) = 0; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index c92ee782..1eeaf4bb 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -182,6 +182,42 @@ MediaDevice *PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator, } /** + * \brief Lock all media devices acquired by the pipeline + * + * This method shall not be called from pipeline handler implementation, as the + * Camera class handles locking directly. + * + * \return True if the devices could be locked, false otherwise + * \sa unlock() + * \sa MediaDevice::lock() + */ +bool PipelineHandler::lock() +{ + for (std::shared_ptr<MediaDevice> &media : mediaDevices_) { + if (!media->lock()) { + unlock(); + return false; + } + } + + return true; +} + +/** + * \brief Unlock all media devices acquired by the pipeline + * + * This method shall not be called from pipeline handler implementation, as the + * Camera class handles locking directly. + * + * \sa lock() + */ +void PipelineHandler::unlock() +{ + for (std::shared_ptr<MediaDevice> &media : mediaDevices_) + media->unlock(); +} + +/** * \fn PipelineHandler::streamConfiguration() * \brief Retrieve a group of stream configurations for a specified camera * \param[in] camera The camera to fetch default configuration from |