diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-08-30 01:20:10 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-11-19 22:38:44 +0200 |
commit | a01007b102749caa08c1197f8ee3e1c4ed1cc530 (patch) | |
tree | c612280e2d636d0bc76484f27829c1e582eff284 /include/libcamera/internal/pipeline_handler.h | |
parent | f6a5d675b1cfd1ee9cb9358526e1f84b821b9e07 (diff) |
libcamera: Allow concurrent use of cameras from same pipeline handler
libcamera implements a pipeline handler locking mechanism based on
advisory locks on media devices, to prevent concurrent access to cameras
from the same pipeline handler from different processes (this only works
between multiple libcamera instances, as other processes won't use
advisory locks on media devices).
A side effect of the implementation prevents multiple cameras created by
the same pipeline handler from being used concurrently. Fix this by
turning the PipelineHandler lock() and unlock() functions into acquire()
and release(), with a use count to replace the boolean lock flag. The
Camera class is updated accordingly.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'include/libcamera/internal/pipeline_handler.h')
-rw-r--r-- | include/libcamera/internal/pipeline_handler.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index b473eb70..17e5c892 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -44,8 +44,8 @@ public: MediaDevice *acquireMediaDevice(DeviceEnumerator *enumerator, const DeviceMatch &dm); - bool lock(); - void unlock(); + bool acquire(); + void release(); virtual CameraConfiguration *generateConfiguration(Camera *camera, const StreamRoles &roles) = 0; @@ -74,7 +74,7 @@ protected: CameraManager *manager_; private: - void unlockLocked(); + void unlockMediaDevices(); void mediaDeviceDisconnected(MediaDevice *media); virtual void disconnect(); @@ -85,7 +85,7 @@ private: const char *name_; Mutex lock_; - bool lockOwner_; + unsigned int useCount_; friend class PipelineHandlerFactory; }; |