summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcamera/internal/pipeline_handler.h4
-rw-r--r--src/libcamera/pipeline_handler.cpp10
2 files changed, 14 insertions, 0 deletions
diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h
index fc6d476b..b473eb70 100644
--- a/include/libcamera/internal/pipeline_handler.h
+++ b/include/libcamera/internal/pipeline_handler.h
@@ -14,6 +14,7 @@
#include <vector>
#include <libcamera/base/object.h>
+#include <libcamera/base/thread.h>
#include <libcamera/controls.h>
#include <libcamera/stream.h>
@@ -73,6 +74,8 @@ protected:
CameraManager *manager_;
private:
+ void unlockLocked();
+
void mediaDeviceDisconnected(MediaDevice *media);
virtual void disconnect();
@@ -81,6 +84,7 @@ private:
const char *name_;
+ Mutex lock_;
bool lockOwner_;
friend class PipelineHandlerFactory;
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index 3d61311c..2d2bb940 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -10,6 +10,7 @@
#include <sys/sysmacros.h>
#include <libcamera/base/log.h>
+#include <libcamera/base/thread.h>
#include <libcamera/base/utils.h>
#include <libcamera/camera.h>
@@ -150,6 +151,8 @@ MediaDevice *PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator,
*/
bool PipelineHandler::lock()
{
+ MutexLocker locker(lock_);
+
/* Do not allow nested locking in the same libcamera instance. */
if (lockOwner_)
return false;
@@ -178,6 +181,13 @@ bool PipelineHandler::lock()
*/
void PipelineHandler::unlock()
{
+ MutexLocker locker(lock_);
+
+ unlockLocked();
+}
+
+void PipelineHandler::unlockLocked()
+{
if (lockOwner_)
return;