summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2020-03-11 09:56:36 +0200
committerTomi Valkeinen <tomi.valkeinen@ti.com>2020-04-21 10:32:33 +0300
commitac95d1a691332934fae7ea5ee3a17be35228d480 (patch)
tree864485b37c9c59fbd603be6ac4e51013f34c4fa7
parentd76facb57d88f97266d0fb19850bf7e7da5d9198 (diff)
videodevice: use exception to catch bad fd
-rw-r--r--kms++util/src/videodevice.cpp21
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;