Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > b10490245063b25104ad1d93e768d6a1 > files > 14

v4l-utils-0.8.8-2.fc16.src.rpm

From 8fcfbbc58a0b6a0eeb31c02493e164f82236a8e6 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 9 Jul 2012 13:23:41 +0200
Subject: [PATCH 14/14] libv4l2: dqbuf: Don't requeue buffers which we are
 returning to the app

We retry dqbuf when we get a short frame or a decode error, but if the retries
are exhausted and the frame is short we will return the (short) buffer to the
caller, since returning a short frame is better then not returning anything
at all.

This means that we must not re-queue it then! Also see:
https://bugzilla.redhat.com/show_bug.cgi?id=838279

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 lib/libv4l2/libv4l2.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c
index a8f17ed..070ac0d 100644
--- a/lib/libv4l2/libv4l2.c
+++ b/lib/libv4l2/libv4l2.c
@@ -317,7 +317,13 @@ static int v4l2_dequeue_and_convert(int index, struct v4l2_buffer *buf,
 				V4L2_LOG_ERR("converting / decoding frame data: %s",
 						v4lconvert_get_error_message(devices[index].convert));
 
-			v4l2_queue_read_buffer(index, buf->index);
+			/*
+			 * If this is the last try, and the frame is short
+			 * we will return the (short) buffer to the caller,
+			 * so we must not re-queue it then!
+			 */
+			if (!(tries == 1 && errno == EPIPE))
+				v4l2_queue_read_buffer(index, buf->index);
 			errno = saved_err;
 		}
 		tries--;
-- 
1.7.10.4