Blame SOURCES/0001-fix-v4l2_munmap.patch

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