diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-01-24 00:59:40 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-01-24 22:24:11 +0200 |
commit | 4f043b05e74cf66f2a78f593eaef2772f11af33f (patch) | |
tree | a446daff4ff89c50c637d5a1ced86c23132725a0 /src/libcamera/include | |
parent | 5b02e03199b79165086135236d8fb9b2c673aae1 (diff) |
libcamera: device_enumerator: Reference-count MediaDevice instances
The MediaDevice class will be the entry point to hot-unplug, as it
corresponds to the kernel devices that will report device removal
events. The class will signal media device disconnection to pipeline
handlers, which will clean up resources as a result.
This can't be performed synchronously as references may exist to the
related Camera objects in applications. The MediaDevice object thus
needs to be reference-counted in order to support unplugging, as
otherwise pipeline handlers would be required to drop all the references
to the media device they have borrowed synchronously with the
disconnection signal handler, which would be very error prone (if even
possible at all in a sane way).
Handle MedieDevice instances with std::shared_ptr<> to support this.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/include')
-rw-r--r-- | src/libcamera/include/device_enumerator.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h index 40c7750b..3f87a625 100644 --- a/src/libcamera/include/device_enumerator.h +++ b/src/libcamera/include/device_enumerator.h @@ -42,13 +42,13 @@ public: virtual int init() = 0; virtual int enumerate() = 0; - MediaDevice *search(const DeviceMatch &dm); + std::shared_ptr<MediaDevice> search(const DeviceMatch &dm); protected: int addDevice(const std::string &deviceNode); private: - std::vector<MediaDevice *> devices_; + std::vector<std::shared_ptr<MediaDevice>> devices_; virtual std::string lookupDeviceNode(int major, int minor) = 0; }; |