[yavta PATCH] Return proper error code if STREAMON fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix the bug causing success to be returned even if VIDIOC_STREAMON
failed. Also check returned error from VIDIOC_STREAMOFF.

Signed-off-by: Tuukka Toivonen <tuukka.toivonen@xxxxxxxxx>
---
 yavta.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/yavta.c b/yavta.c
index b627725..3ad1c97 100644
--- a/yavta.c
+++ b/yavta.c
@@ -1623,7 +1623,7 @@ static int video_do_capture(struct device *dev, 
unsigned int nframes,
 	unsigned int i;
 	double bps;
 	double fps;
-	int ret;
+	int ret, ret2;
 
 	/* Start streaming. */
 	ret = video_enable(dev, 1);
@@ -1708,7 +1708,9 @@ static int video_do_capture(struct device *dev, 
unsigned int nframes,
 	}
 
 	/* Stop streaming. */
-	video_enable(dev, 0);
+	ret = video_enable(dev, 0);
+	if (ret < 0)
+		goto done;
 
 	if (nframes == 0) {
 		printf("No frames captured.\n");
@@ -1732,7 +1734,11 @@ static int video_do_capture(struct device *dev, 
unsigned int nframes,
 		i, ts.tv_sec, ts.tv_nsec/1000, fps, bps);
 
 done:
-	return video_free_buffers(dev);
+	ret2 = video_free_buffers(dev);
+	if (ret >= 0)
+		ret = ret2;
+
+	return ret;
 }
 
 #define V4L_BUFFERS_DEFAULT	8
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux