Skip to content

Commit

Permalink
iteration in V4L2 needs to be in reversed
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Feb 21, 2024
1 parent 9c1d428 commit 2d69250
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libs/indibase/webcam/v4l2_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2998,7 +2998,9 @@ std::map<std::string, std::string> V4L2_Base::enumerate()
std::vector<std::string> detectedDevices;
int devCount = 0;
devCount = scandir(prefix.c_str(), &namelist, video_dev_file_select, alphasort);
for (int i = 0; i < devCount; i++)
// Need to do this in reverse because some devices might have two end points
// e.g. /dev/video0 and /dev/video1 for the same device but only /dev/video0 can be used to control it.
for (int i = devCount - 1; i >= 0; i--)
{
std::string s(namelist[i]->d_name);
s.erase(s.find_last_not_of(" \n\r\t") + 1);
Expand Down

0 comments on commit 2d69250

Please sign in to comment.