fix: don't log errors while reconnecting
This commit is contained in:
+8
-4
@@ -70,14 +70,17 @@ static void ioctl_error(VideoCapture *video_capture, const char *operation,
|
||||
video_capture->error = true;
|
||||
}
|
||||
|
||||
static void open_device(VideoCapture *video_capture, const char *name) {
|
||||
static void open_device(VideoCapture *video_capture, const char *name,
|
||||
bool log_error) {
|
||||
strlcpy(video_capture->name, name, STR_LEN);
|
||||
video_capture->error = false;
|
||||
video_capture->fd = -1;
|
||||
|
||||
video_capture->fd = open(name, O_RDWR | O_NONBLOCK);
|
||||
if (video_capture->fd == -1) {
|
||||
log_warn("(%s) Cannot open device", name);
|
||||
if (log_error) {
|
||||
log_warn("(%s) Cannot open device", name);
|
||||
}
|
||||
video_capture->error = true;
|
||||
}
|
||||
}
|
||||
@@ -305,8 +308,9 @@ static unsigned int read_video(VideoCapture *video_capture) {
|
||||
}
|
||||
|
||||
void video_init(VideoCapture *video_capture, const char *name,
|
||||
unsigned int preferred_height, unsigned int buffer_count) {
|
||||
open_device(video_capture, name);
|
||||
unsigned int preferred_height, unsigned int buffer_count,
|
||||
bool log_error) {
|
||||
open_device(video_capture, name, log_error);
|
||||
|
||||
if (video_capture->error) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user