mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-16 00:45:07 +03:00
v4l2: Replace manual loop counters with utils::enumerate()
Use the newly introduced utils::enumerate() to replace manual loop counters. A local variable is needed, as utils::enumerate() requires an lvalue reference. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
ad38d9151b
commit
6aee488bfc
1 changed files with 5 additions and 6 deletions
|
@ -23,6 +23,7 @@
|
|||
#include <libcamera/camera_manager.h>
|
||||
|
||||
#include "libcamera/internal/log.h"
|
||||
#include "libcamera/internal/utils.h"
|
||||
|
||||
#include "v4l2_camera_file.h"
|
||||
|
||||
|
@ -81,11 +82,10 @@ int V4L2CompatManager::start()
|
|||
* For each Camera registered in the system, a V4L2CameraProxy gets
|
||||
* created here to wrap a camera device.
|
||||
*/
|
||||
unsigned int index = 0;
|
||||
for (auto &camera : cm_->cameras()) {
|
||||
auto cameras = cm_->cameras();
|
||||
for (auto [index, camera] : utils::enumerate(cameras)) {
|
||||
V4L2CameraProxy *proxy = new V4L2CameraProxy(index, camera);
|
||||
proxies_.emplace_back(proxy);
|
||||
++index;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -117,11 +117,10 @@ int V4L2CompatManager::getCameraIndex(int fd)
|
|||
if (!target)
|
||||
return -1;
|
||||
|
||||
unsigned int index = 0;
|
||||
for (auto &camera : cm_->cameras()) {
|
||||
auto cameras = cm_->cameras();
|
||||
for (auto [index, camera] : utils::enumerate(cameras)) {
|
||||
if (camera == target)
|
||||
return index;
|
||||
++index;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue