summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/include/pipeline_handler.h3
-rw-r--r--src/libcamera/pipeline_handler.cpp36
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