diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2020-03-11 09:56:36 +0200 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2020-04-21 10:32:33 +0300 |
commit | ac95d1a691332934fae7ea5ee3a17be35228d480 (patch) | |
tree | 864485b37c9c59fbd603be6ac4e51013f34c4fa7 /kms++util/src | |
parent | d76facb57d88f97266d0fb19850bf7e7da5d9198 (diff) |
videodevice: use exception to catch bad fd
Diffstat (limited to 'kms++util/src')
-rw-r--r-- | kms++util/src/videodevice.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/kms++util/src/videodevice.cpp b/kms++util/src/videodevice.cpp index 23f45d4..89a7286 100644 --- a/kms++util/src/videodevice.cpp +++ b/kms++util/src/videodevice.cpp @@ -248,7 +248,8 @@ VideoDevice::VideoDevice(const string& dev) VideoDevice::VideoDevice(int fd) : m_fd(fd), m_has_capture(false), m_has_output(false), m_has_m2m(false), m_capture_streamer(0), m_output_streamer(0) { - FAIL_IF(fd < 0, "Bad fd"); + if (fd < 0) + throw runtime_error("bad fd"); struct v4l2_capability cap = { }; int r = ioctl(fd, VIDIOC_QUERYCAP, &cap); @@ -370,10 +371,13 @@ vector<string> VideoDevice::get_capture_devices() if (stat(name.c_str(), &buffer) != 0) continue; - VideoDevice vid(name); + try { + VideoDevice vid(name); - if (vid.has_capture() && !vid.has_m2m()) - v.push_back(name); + if (vid.has_capture() && !vid.has_m2m()) + v.push_back(name); + } catch (...) { + } } return v; @@ -390,10 +394,13 @@ vector<string> VideoDevice::get_m2m_devices() if (stat(name.c_str(), &buffer) != 0) continue; - VideoDevice vid(name); + try { + VideoDevice vid(name); - if (vid.has_m2m()) - v.push_back(name); + if (vid.has_m2m()) + v.push_back(name); + } catch (...) { + } } return v; |