diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cd1bfb98..e7324ced9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -608,6 +608,12 @@ if((NOT HAVE_LIBCRYPTO) AND (NOT HAVE_LIBGNUTLS)) "ZoneMinder requires crypto or gnutls but none were found on your system") endif((NOT HAVE_LIBCRYPTO) AND (NOT HAVE_LIBGNUTLS)) +include(FindV4L2) +if(V4L2_FOUND) + list(APPEND ZM_BIN_LIBS "${V4L2_LIBRARY}") + set(optlibsfound "${optlibsfound} v4l2") +endif(V4L2_FOUND) + # Check for V4L header files and enable ZM_HAS_V4L, ZM_HAS_V4L1, ZM_HAS_V4L2 accordingly # Setting to zeros first is required because ZM uses #define for these set(ZM_HAS_V4L 0) diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 554ddcd46..90bde1673 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -32,6 +32,8 @@ #include #include +#include + /* Workaround for GNU/kFreeBSD */ #if defined(__FreeBSD_kernel__) #ifndef ENODATA @@ -46,8 +48,8 @@ static int vidioctl( int fd, int request, void *arg ) int result = -1; do { - result = ioctl( fd, request, arg ); - } while ( result == -1 && errno == EINTR ); + result = v4l2_ioctl( fd, request, arg ); + } while ( result == -1 && ( ( errno == EINTR ) || (errno == EAGAIN)) ); return( result ); } @@ -824,7 +826,7 @@ void LocalCamera::Initialise() v4l2_data.reqbufs.count = 1; } } else { - v4l2_data.reqbufs.count = 8; + v4l2_data.reqbufs.count = 2; } Debug( 3, "Request buffers count is %d", v4l2_data.reqbufs.count ); @@ -868,9 +870,9 @@ void LocalCamera::Initialise() Fatal( "Unable to query video buffer: %s", strerror(errno) ); v4l2_data.buffers[i].length = vid_buf.length; - v4l2_data.buffers[i].start = mmap( NULL, vid_buf.length, PROT_READ|PROT_WRITE, MAP_SHARED, vid_fd, vid_buf.m.offset ); + v4l2_data.buffers[i].start = v4l2_mmap( NULL, vid_buf.length, PROT_READ|PROT_WRITE, MAP_SHARED, vid_fd, vid_buf.m.offset ); - if ( v4l2_data.buffers[i].start == MAP_FAILED ) + if ( MAP_FAILED == v4l2_data.buffers[i].start ) Fatal( "Can't map video buffer %d (%d bytes) to memory: %s(%d)", i, vid_buf.length, strerror(errno), errno ); #if HAVE_LIBSWSCALE