libcamera: media_device: Add functions to lock device for other processes

Add lock() and unlock() which are backed by lockf() and allow an
instance of libcamera to claim exclusive access to a media device.
These functions are the base of allowing multiple user of libcamera to
coexist in the system without stepping on each other's toes.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Niklas Söderlund
2019-04-14 02:53:35 +02:00
parent 1657291f58
commit 2e22ee4310
2 changed files with 62 additions and 1 deletions
+4
View File
@@ -30,6 +30,9 @@ public:
void release();
bool busy() const { return acquired_; }
bool lock();
void unlock();
int populate();
bool valid() const { return valid_; }
@@ -58,6 +61,7 @@ private:
int fd_;
bool valid_;
bool acquired_;
bool lockOwner_;
int open();
void close();