Blame SOURCES/0001-fix-v4l2_munmap.patch

0dd771
From 4cd9255f0a8a9e15d81561f00f02d275b5095f70 Mon Sep 17 00:00:00 2001
0dd771
From: Oleksij Rempel (Alexey Fisher) <bug-track@fisher-privat.net>
0dd771
Date: Thu, 01 Mar 2012 13:15:29 +0000
0dd771
Subject: v4l2src: fix v4l2_munmap() for compressed formats
0dd771
0dd771
Make sure we always call munmap() with the same size we called mmap()
0dd771
with before.
0dd771
0dd771
Current v4l2src uses the same structure for VIDIOC_QUERYBUF, VIDIOC_QBUF
0dd771
and v4l2_munmap calls. The problem is that the video buffer size (length)
0dd771
may vary for compressed or emulated bufs. VIDIOC_QBUF will change it if
0dd771
we pass the pointer of a v4l2_buffer. This is why we should avoid using
0dd771
same variable for mmap and video buffers.
0dd771
0dd771
https://bugzilla.gnome.org/show_bug.cgi?id=671126
0dd771
---
0dd771
(limited to 'sys/v4l2')
0dd771
0dd771
diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
0dd771
index b81c6a4..51419ff 100644
0dd771
--- a/sys/v4l2/gstv4l2bufferpool.c
0dd771
+++ b/sys/v4l2/gstv4l2bufferpool.c
0dd771
@@ -106,9 +106,9 @@ gst_v4l2_buffer_finalize (GstV4l2Buffer * buffer)
0dd771
   if (!resuscitated) {
0dd771
     GST_LOG_OBJECT (pool->v4l2elem,
0dd771
         "buffer %p (data %p, len %u) not recovered, unmapping",
0dd771
-        buffer, GST_BUFFER_DATA (buffer), buffer->vbuffer.length);
0dd771
+        buffer, GST_BUFFER_DATA (buffer), buffer->mmap_length);
0dd771
     gst_mini_object_unref (GST_MINI_OBJECT (pool));
0dd771
-    v4l2_munmap ((void *) GST_BUFFER_DATA (buffer), buffer->vbuffer.length);
0dd771
+    v4l2_munmap ((void *) GST_BUFFER_DATA (buffer), buffer->mmap_length);
0dd771
 
0dd771
     GST_MINI_OBJECT_CLASS (v4l2buffer_parent_class)->finalize (GST_MINI_OBJECT
0dd771
         (buffer));
0dd771
@@ -183,6 +183,7 @@ gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index, GstCaps * caps)
0dd771
   GST_LOG_OBJECT (pool->v4l2elem, "  length:    %u", ret->vbuffer.length);
0dd771
   GST_LOG_OBJECT (pool->v4l2elem, "  input:     %u", ret->vbuffer.input);
0dd771
 
0dd771
+  ret->mmap_length = ret->vbuffer.length;
0dd771
   data = (guint8 *) v4l2_mmap (0, ret->vbuffer.length,
0dd771
       PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd,
0dd771
       ret->vbuffer.m.offset);
0dd771
diff --git a/sys/v4l2/gstv4l2bufferpool.h b/sys/v4l2/gstv4l2bufferpool.h
0dd771
index caad9ac..36ea323 100644
0dd771
--- a/sys/v4l2/gstv4l2bufferpool.h
0dd771
+++ b/sys/v4l2/gstv4l2bufferpool.h
0dd771
@@ -70,6 +70,9 @@ struct _GstV4l2Buffer {
0dd771
   GstBuffer   buffer;
0dd771
 
0dd771
   struct v4l2_buffer vbuffer;
0dd771
+  /* warning: the size of mmap buffer and
0dd771
+   * the actual frame-buffer can be different. */
0dd771
+  size_t mmap_length;
0dd771
 
0dd771
   /* FIXME: have GstV4l2Src* instead, as this has GstV4l2BufferPool* */
0dd771
   /* FIXME: do we really want to fix this if GstV4l2Buffer/Pool is shared
0dd771
--
0dd771
cgit v0.9.0.2-2-gbebe