[vlc-commits] v4l2: map buffers before queueing them
Rémi Denis-Courmont
git at videolan.org
Thu Apr 12 22:46:05 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Apr 12 23:45:22 2012 +0300| [241199ffc415a607eeb6ace946733d67b4425bb8] | committer: Rémi Denis-Courmont
v4l2: map buffers before queueing them
Not sure if this is a driver bug or a limitation.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=241199ffc415a607eeb6ace946733d67b4425bb8
---
modules/access/v4l2/video.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/modules/access/v4l2/video.c b/modules/access/v4l2/video.c
index e85d68c..b0f4f8a 100644
--- a/modules/access/v4l2/video.c
+++ b/modules/access/v4l2/video.c
@@ -587,8 +587,8 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n)
if (unlikely(bufv == NULL))
return NULL;
- uint32_t bufc;
- for (bufc = 0; bufc < req.count; bufc++)
+ uint32_t bufc = 0;
+ while (bufc < req.count)
{
struct v4l2_buffer buf = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
@@ -601,11 +601,6 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n)
msg_Err (obj, "cannot query buffer %"PRIu32": %m", bufc);
goto error;
}
- if (v4l2_ioctl (fd, VIDIOC_QBUF, &buf) < 0)
- {
- msg_Err (obj, "cannot queue buffer %"PRIu32": %m", bufc);
- goto error;
- }
bufv[bufc].start = v4l2_mmap (NULL, buf.length, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, buf.m.offset);
@@ -615,6 +610,14 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n)
goto error;
}
bufv[bufc].length = buf.length;
+ bufc++;
+
+ /* Some drivers refuse to queue buffers before they are mapped. Bug? */
+ if (v4l2_ioctl (fd, VIDIOC_QBUF, &buf) < 0)
+ {
+ msg_Err (obj, "cannot queue buffer %"PRIu32": %m", bufc);
+ goto error;
+ }
}
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
More information about the vlc-commits
mailing list