fix: don't log errors while reconnecting

This commit is contained in:
2026-05-16 17:12:40 +02:00
parent 9969230cd9
commit 7cce5babc2
5 changed files with 38 additions and 15 deletions
+8 -4
View File
@@ -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;