Skip to content
Snippets Groups Projects
Commit aaf6a2ab authored by Tristan Matthews's avatar Tristan Matthews
Browse files

video: don't assume that v4l lists are populated

Refs #45484
parent 327ed566
Branches
No related tags found
No related merge requests found
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
*/ */
#include <string> #include <string>
#include <cassert>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <climits> #include <climits>
...@@ -366,6 +367,7 @@ VideoV4l2Device::getChannel(const string &name) const ...@@ -366,6 +367,7 @@ VideoV4l2Device::getChannel(const string &name) const
if (item.name == name) if (item.name == name)
return item; return item;
assert(not channels_.empty());
return channels_.back(); return channels_.back();
} }
......
...@@ -213,14 +213,34 @@ VideoV4l2ListThread::~VideoV4l2ListThread() ...@@ -213,14 +213,34 @@ VideoV4l2ListThread::~VideoV4l2ListThread()
void VideoV4l2ListThread::updateDefault() void VideoV4l2ListThread::updateDefault()
{ {
if (devices_.empty()) {
ERROR("No devices");
return;
}
const std::string &name = devices_.back().name; const std::string &name = devices_.back().name;
auto controls = Manager::instance().getVideoControls(); auto controls = Manager::instance().getVideoControls();
controls->setActiveDevice(name); controls->setActiveDevice(name);
const auto channel = devices_.back().getChannelList()[0];
const auto channelList = devices_.back().getChannelList();
if (channelList.empty()) {
ERROR("No channel list present");
return;
}
const auto channel = channelList[0];
controls->setActiveDeviceChannel(channel); controls->setActiveDeviceChannel(channel);
const auto size = devices_.back().getChannel(name).getSizeList()[0];
const auto sizeList = devices_.back().getChannel(name).getSizeList();
if (sizeList.empty()) {
ERROR("No size list present");
return;
}
const auto size = sizeList[0];
controls->setActiveDeviceSize(size); controls->setActiveDeviceSize(size);
const auto rateList(controls->getDeviceRateList(name, channel, size)); const auto rateList(controls->getDeviceRateList(name, channel, size));
// compare by integer value // compare by integer value
const auto highest = std::max_element(rateList.begin(), rateList.end(), [] const auto highest = std::max_element(rateList.begin(), rateList.end(), []
(const std::string &l, const std::string &r) { (const std::string &l, const std::string &r) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment