Package: uvccapture / 0.5-5

0002-allocated-buffer-count.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From: Bas Wijnen <wijnen@debian.org>
Date: Sat, 19 Oct 2013 00:00:00 +0000
Subject: allocated buffer count

Use returned number of buffers instead of requested.

VIDIOC_REQBUFS stores the number of actually allocated buffers.
This patch uses this value instead of assuming it is equal to the requested number.
Debian-Bug: https://bugs.debian.org/726802
---
 v4l2uvc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/v4l2uvc.c b/v4l2uvc.c
index f534f6e..595e181 100644
--- a/v4l2uvc.c
+++ b/v4l2uvc.c
@@ -202,7 +202,7 @@ init_v4l2 (struct vdIn *vd)
     goto fatal;
   }
   /* map the buffers */
-  for (i = 0; i < NB_BUFFER; i++) {
+  for (i = 0; i < vd->rb.count; i++) {
     memset (&vd->buf, 0, sizeof (struct v4l2_buffer));
     vd->buf.index = i;
     vd->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -226,7 +226,7 @@ init_v4l2 (struct vdIn *vd)
       fprintf (stderr, "Buffer mapped at address %p.\n", vd->mem[i]);
   }
   /* Queue the buffers. */
-  for (i = 0; i < NB_BUFFER; ++i) {
+  for (i = 0; i < vd->rb.count; ++i) {
     memset (&vd->buf, 0, sizeof (struct v4l2_buffer));
     vd->buf.index = i;
     vd->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -335,7 +335,7 @@ close_v4l2 (struct vdIn *vd)
 
   /* If the memory maps are not released the device will remain opened even
      after a call to close(); */
-  for (i = 0; i < NB_BUFFER; i++) {
+  for (i = 0; i < vd->rb.count; i++) {
     munmap (vd->mem[i], vd->buf.length);
   }