Message ID | 20190414013506.10515-11-niklas.soderlund@ragnatech.se |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Niklas, Thank you for the patch. On Sun, Apr 14, 2019 at 03:35:05AM +0200, Niklas Söderlund wrote: > Add lock() and unlock() which backed by the MediaDevice implementation > can will lock all media devices claimed by a pipeline handler instance. > > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > src/libcamera/include/pipeline_handler.h | 3 +++ > src/libcamera/pipeline_handler.cpp | 18 ++++++++++++++++++ > 2 files changed, 21 insertions(+) > > diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h > index d995a7e56d90f706..0e79b05035cc2abb 100644 > --- a/src/libcamera/include/pipeline_handler.h > +++ b/src/libcamera/include/pipeline_handler.h > @@ -56,6 +56,9 @@ public: > std::shared_ptr<MediaDevice> tryAcquire(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 7f4035c008f95f91..317b680214d91071 100644 > --- a/src/libcamera/pipeline_handler.cpp > +++ b/src/libcamera/pipeline_handler.cpp > @@ -170,6 +170,24 @@ out: > return media; > } > > +bool PipelineHandler::lock() Documentation too please :-) > +{ > + for (std::shared_ptr<MediaDevice> media : mediaDevices_) { > + if (!media->lock()) { > + unlock(); > + return false; > + } > + } > + > + return true; > +} > + > +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
diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index d995a7e56d90f706..0e79b05035cc2abb 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -56,6 +56,9 @@ public: std::shared_ptr<MediaDevice> tryAcquire(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 7f4035c008f95f91..317b680214d91071 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -170,6 +170,24 @@ out: return media; } +bool PipelineHandler::lock() +{ + for (std::shared_ptr<MediaDevice> media : mediaDevices_) { + if (!media->lock()) { + unlock(); + return false; + } + } + + return true; +} + +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
Add lock() and unlock() which backed by the MediaDevice implementation can will lock all media devices claimed by a pipeline handler instance. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> --- src/libcamera/include/pipeline_handler.h | 3 +++ src/libcamera/pipeline_handler.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+)