mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 07:19:45 +03:00
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:
parent
12053cf8e6
commit
5868d73e77
5 changed files with 12 additions and 29 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue