Skip to content

Commit 9fac660

Browse files
committed
fix: replace exit with runtime error
1 parent 59a8df7 commit 9fac660

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/common/v4l2_utils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <errno.h>
55
#include <fcntl.h>
6+
#include <stdexcept>
67
#include <string.h>
78
#include <sys/ioctl.h>
89
#include <sys/mman.h>
@@ -37,7 +38,7 @@ int V4L2Util::OpenDevice(const char *file) {
3738
int fd = open(file, O_RDWR);
3839
if (fd < 0) {
3940
ERROR_PRINT("v4l2 open(%s): %s", file, strerror(errno));
40-
exit(-1);
41+
throw std::runtime_error("failed to open v4l2 device");
4142
}
4243
DEBUG_PRINT("Open file %s fd(%d) success!", file, fd);
4344
return fd;
@@ -170,7 +171,7 @@ bool V4L2Util::SetFormat(int fd, V4L2BufferGroup *gbuffer, int width, int height
170171
if (fmt.fmt.pix_mp.width != width || fmt.fmt.pix_mp.height != height) {
171172
ERROR_PRINT("fd(%d) input size (%dx%d) doesn't match driver's output size (%dx%d): %s", fd,
172173
width, height, fmt.fmt.pix_mp.width, fmt.fmt.pix_mp.height, strerror(EINVAL));
173-
exit(0);
174+
throw std::runtime_error("the frame size doesn't match");
174175
}
175176

176177
return true;

0 commit comments

Comments
 (0)