diff --git a/daemon/src/video/video_v4l2.cpp b/daemon/src/video/video_v4l2.cpp index 62c04eb829f04ecd1a0fc74580f77ba75b59f6a6..b0daf86fe08fee4305fcd7c3983d19c6b97fe797 100644 --- a/daemon/src/video/video_v4l2.cpp +++ b/daemon/src/video/video_v4l2.cpp @@ -29,6 +29,7 @@ */ #include <string> +#include <cassert> #include <algorithm> #include <vector> #include <climits> @@ -366,6 +367,7 @@ VideoV4l2Device::getChannel(const string &name) const if (item.name == name) return item; + assert(not channels_.empty()); return channels_.back(); } diff --git a/daemon/src/video/video_v4l2_list.cpp b/daemon/src/video/video_v4l2_list.cpp index 3dd59aa1595d8a416813f71bbc60f04292e7df5d..430a55997ddae418ce358773a56e4c3a4bf61efd 100644 --- a/daemon/src/video/video_v4l2_list.cpp +++ b/daemon/src/video/video_v4l2_list.cpp @@ -213,14 +213,34 @@ VideoV4l2ListThread::~VideoV4l2ListThread() void VideoV4l2ListThread::updateDefault() { + if (devices_.empty()) { + ERROR("No devices"); + return; + } + const std::string &name = devices_.back().name; auto controls = Manager::instance().getVideoControls(); 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); - 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); const auto rateList(controls->getDeviceRateList(name, channel, size)); + // compare by integer value const auto highest = std::max_element(rateList.begin(), rateList.end(), [] (const std::string &l, const std::string &r) {