From 4f043b05e74cf66f2a78f593eaef2772f11af33f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 24 Jan 2019 00:59:40 +0200 Subject: libcamera: device_enumerator: Reference-count MediaDevice instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Niklas Söderlund --- test/media_device/media_device_link_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/media_device') diff --git a/test/media_device/media_device_link_test.cpp b/test/media_device/media_device_link_test.cpp index ac5b632f..58a55cdf 100644 --- a/test/media_device/media_device_link_test.cpp +++ b/test/media_device/media_device_link_test.cpp @@ -240,7 +240,7 @@ class MediaDeviceLinkTest : public Test private: unique_ptr enumerator; - MediaDevice *dev_; + shared_ptr dev_; }; TEST_REGISTER(MediaDeviceLinkTest); -- cgit v1.2.1