summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-24 00:59:40 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-24 22:24:11 +0200
commit4f043b05e74cf66f2a78f593eaef2772f11af33f (patch)
treea446daff4ff89c50c637d5a1ced86c23132725a0 /test
parent5b02e03199b79165086135236d8fb9b2c673aae1 (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 'test')
-rw-r--r--test/media_device/media_device_link_test.cpp2
-rw-r--r--test/pipeline/ipu3/ipu3_pipeline_test.cpp2
2 files changed, 2 insertions, 2 deletions
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<DeviceEnumerator> enumerator;
- MediaDevice *dev_;
+ shared_ptr<MediaDevice> dev_;
};
TEST_REGISTER(MediaDeviceLinkTest);
diff --git a/test/pipeline/ipu3/ipu3_pipeline_test.cpp b/test/pipeline/ipu3/ipu3_pipeline_test.cpp
index 482c1249..953f0233 100644
--- a/test/pipeline/ipu3/ipu3_pipeline_test.cpp
+++ b/test/pipeline/ipu3/ipu3_pipeline_test.cpp
@@ -65,7 +65,7 @@ int IPU3PipelineTest::init()
return TestSkip;
}
- MediaDevice *cio2 = enumerator->search(cio2_dm);
+ std::shared_ptr<MediaDevice> cio2 = enumerator->search(cio2_dm);
if (!cio2) {
cerr << "Failed to find IPU3 CIO2: test skip" << endl;
return TestSkip;