From 5868d73e77916812d60cb60ee3cade785f6492f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Sat, 13 Apr 2019 23:58:31 +0200 Subject: libcamera: media_device: Open and close media device inside populate() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the need for the caller to open and close the media device when populating the MediaDevice. This is done as an effort to make the usage of the MediaDevice less error prone and the interface stricter. The rework also revealed and fixes a potential memory leak in MediaDevice::populate() where resources would not be deleted if the second MEDIA_IOC_G_TOPOLOGY would fail. Signed-off-by: Niklas Söderlund Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- test/v4l2_subdevice/v4l2_subdevice_test.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'test/v4l2_subdevice/v4l2_subdevice_test.cpp') diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.cpp b/test/v4l2_subdevice/v4l2_subdevice_test.cpp index 5810ef3c..562a638c 100644 --- a/test/v4l2_subdevice/v4l2_subdevice_test.cpp +++ b/test/v4l2_subdevice/v4l2_subdevice_test.cpp @@ -45,13 +45,6 @@ int V4L2SubdeviceTest::init() return TestSkip; } - int ret = media_->open(); - if (ret) { - cerr << "Unable to open media device: " << media_->deviceNode() - << ": " << strerror(ret) << endl; - return TestSkip; - } - MediaEntity *videoEntity = media_->getEntityByName("Scaler"); if (!videoEntity) { cerr << "Unable to find media entity 'Scaler'" << endl; @@ -59,8 +52,7 @@ int V4L2SubdeviceTest::init() } scaler_ = new V4L2Subdevice(videoEntity); - ret = scaler_->open(); - if (ret) { + if (scaler_->open()) { cerr << "Unable to open video subdevice " << scaler_->entity()->deviceNode() << endl; return TestSkip; -- cgit v1.2.1