Merge pull request #6313 from amannababanana:master

This commit is contained in:
Alexander Alekhin 2016-03-25 11:31:17 +00:00
commit 05384f05cc
2 changed files with 19 additions and 10 deletions

View File

@ -1113,7 +1113,7 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
default: default:
/* display the error and stop processing */ /* display the error and stop processing */
perror ("VIDIOC_DQBUF"); perror ("VIDIOC_DQBUF");
return 1; return -1;
} }
} }
@ -1141,7 +1141,7 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
return 1; return 1;
} }
static void mainloop_v4l2(CvCaptureCAM_V4L* capture) { static int mainloop_v4l2(CvCaptureCAM_V4L* capture) {
unsigned int count; unsigned int count;
count = 1; count = 1;
@ -1175,10 +1175,14 @@ static void mainloop_v4l2(CvCaptureCAM_V4L* capture) {
break; break;
} }
if (read_frame_v4l2 (capture)) int returnCode=read_frame_v4l2(capture);
break; if (returnCode == -1)
return -1;
if (returnCode == 1)
return 0;
} }
} }
return 0;
} }
static int icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) { static int icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) {
@ -1246,7 +1250,7 @@ static int icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) {
if (capture->is_v4l2_device == 1) if (capture->is_v4l2_device == 1)
{ {
mainloop_v4l2(capture); if(mainloop_v4l2(capture) == -1) return 0;
} else } else
{ {

View File

@ -830,7 +830,7 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
default: default:
/* display the error and stop processing */ /* display the error and stop processing */
perror ("VIDIOC_DQBUF"); perror ("VIDIOC_DQBUF");
return 1; return -1;
} }
} }
@ -852,7 +852,7 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
return 1; return 1;
} }
static void mainloop_v4l2(CvCaptureCAM_V4L* capture) { static int mainloop_v4l2(CvCaptureCAM_V4L* capture) {
unsigned int count; unsigned int count;
count = 1; count = 1;
@ -886,10 +886,14 @@ static void mainloop_v4l2(CvCaptureCAM_V4L* capture) {
break; break;
} }
if (read_frame_v4l2 (capture)) int returnCode = read_frame_v4l2 (capture);
if(returnCode == -1)
return -1;
if(returnCode == 1)
break; break;
} }
} }
return 0;
} }
static bool icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) { static bool icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) {
@ -931,14 +935,15 @@ static bool icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) {
#if defined(V4L_ABORT_BADJPEG) #if defined(V4L_ABORT_BADJPEG)
// skip first frame. it is often bad -- this is unnotied in traditional apps, // skip first frame. it is often bad -- this is unnotied in traditional apps,
// but could be fatal if bad jpeg is enabled // but could be fatal if bad jpeg is enabled
mainloop_v4l2(capture); if(mainloop_v4l2(capture) == -1)
return false;
#endif #endif
/* preparation is ok */ /* preparation is ok */
capture->FirstCapture = 0; capture->FirstCapture = 0;
} }
mainloop_v4l2(capture); if(mainloop_v4l2(capture) == -1) return false;
return true; return true;
} }