Skip to content

Commit

Permalink
Fix V4l2 enumerate
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Feb 21, 2024
1 parent 6b51198 commit 9c1d428
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions libs/indibase/webcam/v4l2_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2998,21 +2998,14 @@ 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);
if (devCount > 0)
for (int i = 0; i < devCount; i++)
{
while (devCount--)
{
if (detectedDevices.size() < 10)
{
std::string s(namelist[devCount]->d_name);
s.erase(s.find_last_not_of(" \n\r\t") + 1);
detectedDevices.push_back(prefix + s);
}
free(namelist[devCount]);
}
free(namelist);
std::string s(namelist[i]->d_name);
s.erase(s.find_last_not_of(" \n\r\t") + 1);
detectedDevices.push_back(prefix + s);
free(namelist[i]);
}

free(namelist);
return detectedDevices;
};

Expand Down

0 comments on commit 9c1d428

Please sign in to comment.