@@ -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;
@@ -181,6 +181,42 @@ MediaDevice *PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator,
return media.get();
}
+/**
+ * \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