$ git clone http://tcclient.ion.nu/tc_client.git
commit c8ad90d7eb198ea59bb3ea6e2f03999edc571250
Author: Alicia <...>
Date: Wed May 4 10:59:21 2016 +0200
libcamera(v4l2): if we failed to read the frame, give grey instead.
diff --git a/ChangeLog b/ChangeLog
index 52865e4..971c9f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@ tc_client-gtk: added horizontal and vertical flip as postprocessing options.
tc_client-gtk: reallocate frame when camera input size changes.
tc_client-gtk: if we failed to open the camera, just give a grey screen.
tc_client-gtk and camviewer: fixed compatibility with newer libavutil.
+libcamera(v4l2): if we failed to read the frame, give grey instead.
0.38:
Handle multi-line messages.
Added option --hexcolors to print hex color codes instead of ANSI color escape codes.
diff --git a/utilities/libcamera/camera_v4l2.c b/utilities/libcamera/camera_v4l2.c
index 8bbee7d..4ecf72d 100644
--- a/utilities/libcamera/camera_v4l2.c
+++ b/utilities/libcamera/camera_v4l2.c
@@ -1,6 +1,6 @@
/*
libcamera, a camera access abstraction library
- Copyright (C) 2015 alicia@ion.nu
+ Copyright (C) 2015-2016 alicia@ion.nu
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -50,9 +50,11 @@ char** cam_list_v4l2(char** list, unsigned int* count)
CAM* cam_open_v4l2(const char* name)
{
+ int fd=v4l2_open(&name[5], O_RDWR);
+ if(fd<0){return 0;}
CAM* cam=malloc(sizeof(CAM));
cam->type=CAMTYPE_V4L2;
- cam->fd=v4l2_open(&name[5], O_RDWR);
+ cam->fd=fd;
return cam;
}
@@ -75,7 +77,10 @@ void cam_resolution_v4l2(CAM* cam, unsigned int* width, unsigned int* height)
void cam_getframe_v4l2(CAM* cam, void* pixmap)
{
- v4l2_read(cam->fd, pixmap, cam->framesize);
+ if(v4l2_read(cam->fd, pixmap, cam->framesize)<0)
+ {
+ memset(pixmap, 0x7f, cam->framesize);
+ }
}
void cam_close_v4l2(CAM* cam)