libcamera: media_device: Open and close media device inside populate()

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 <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Niklas Söderlund 2019-04-13 23:58:31 +02:00
parent 12053cf8e6
commit 5868d73e77
5 changed files with 12 additions and 29 deletions

View file

@ -124,10 +124,6 @@ int MediaDevicePrintTest::testMediaDevice(const string deviceNode)
dev.close();
ret = dev.open();
if (ret)
return ret;
ret = dev.populate();
if (ret)
return ret;
@ -135,8 +131,6 @@ int MediaDevicePrintTest::testMediaDevice(const string deviceNode)
/* Print out the media graph. */
printMediaGraph(dev, cerr);
dev.close();
return 0;
}