@@ -27,12 +27,17 @@ public:
void disconnect();
+ int acquire();
+ void release();
+
private:
explicit Camera(const std::string &name, class PipelineHandler *pipe);
~Camera();
std::string name_;
class PipelineHandler *pipe_;
+
+ bool acquired_;
};
} /* namespace libcamera */
@@ -103,7 +103,7 @@ void Camera::disconnect()
}
Camera::Camera(const std::string &name, class PipelineHandler *pipe)
- : name_(name), pipe_(pipe)
+ : name_(name), pipe_(pipe), acquired_(false)
{
}
@@ -111,4 +111,37 @@ Camera::~Camera()
{
}
+/**
+ * \brief Acquire the camera device for exclusive access
+ *
+ * After opening the device with open(), exclusive access must be obtained
+ * before performing operations that change the device state. This function is
+ * not blocking, if the device has already been acquired (by the same or another
+ * process) the -EBUSY error code is returned.
+ *
+ * Once exclusive access isn't needed anymore, the device should be released
+ * with a call to the release() function.
+ *
+ * \return 0 on success or a negative error code on error.
+ */
+int Camera::acquire()
+{
+ if (acquired_)
+ return -EBUSY;
+
+ acquired_ = true;
+ return 0;
+}
+
+/**
+ * \brief Release exclusive access to the camera device
+ *
+ * Releasing the camera device allows other users to acquire exclusive access
+ * with the acquire() function.
+ */
+void Camera::release()
+{
+ acquired_ = false;
+}
+
} /* namespace libcamera */