0001-fix-v4l2_munmap.patch 2.5 KB

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