aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2010-08-02 08:50:56 (GMT)
committerHans Verkuil <hverkuil@xs4all.nl>2010-08-02 08:50:56 (GMT)
commit8c538528143608fbe6b736b11b165d4d8f1fadee (patch)
tree88120813428691184577491b44dea2c2516bfbf1
parent9c1095e49e6b24b231c9671f409944a73a9c4851 (diff)
qv4l2: use req.count for userptr capture as well.
For some reason req.count was ignored when capturing in userptr mode. Instead it was hardcoded to 4. The clean up is also improved to work around the broken videobuf REQBUFS handling. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
-rw-r--r--utils/qv4l2/qv4l2.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp
index 835c00c..82fd691 100644
--- a/utils/qv4l2/qv4l2.cpp
+++ b/utils/qv4l2/qv4l2.cpp
@@ -239,7 +239,7 @@ bool ApplicationWindow::startCapture(unsigned buffer_size)
break;
}
- if (req.count < 2) {
+ if (req.count < 3) {
error("Too few buffers");
reqbufs_mmap_cap(req);
break;
@@ -288,25 +288,25 @@ bool ApplicationWindow::startCapture(unsigned buffer_size)
return true;
case methodUser:
- if (!reqbufs_user_cap(req, 4)) {
+ if (!reqbufs_user_cap(req, 3)) {
error("Cannot capture");
break;
}
- if (req.count < 4) {
+ if (req.count < 3) {
error("Too few buffers");
reqbufs_user_cap(req);
break;
}
- m_buffers = (buffer *)calloc(4, sizeof(*m_buffers));
+ m_buffers = (buffer *)calloc(req.count, sizeof(*m_buffers));
if (!m_buffers) {
error("Out of memory");
break;
}
- for (m_nbuffers = 0; m_nbuffers < 4; ++m_nbuffers) {
+ for (m_nbuffers = 0; m_nbuffers < req.count; ++m_nbuffers) {
m_buffers[m_nbuffers].length = buffer_size;
m_buffers[m_nbuffers].start = malloc(buffer_size);
@@ -354,16 +354,18 @@ void ApplicationWindow::stopCapture()
if (-1 == munmap(m_buffers[i].start, m_buffers[i].length))
perror("munmap");
// Free all buffers.
+ reqbufs_mmap_cap(reqbufs, 1); // videobuf workaround
reqbufs_mmap_cap(reqbufs, 0);
break;
case methodUser:
if (!streamoff_cap())
perror("VIDIOC_STREAMOFF");
- for (i = 0; i < m_nbuffers; ++i)
- free(m_buffers[i].start);
// Free all buffers.
+ reqbufs_user_cap(reqbufs, 1); // videobuf workaround
reqbufs_user_cap(reqbufs, 0);
+ for (i = 0; i < m_nbuffers; ++i)
+ free(m_buffers[i].start);
break;
}
free(m_buffers);

Privacy Policy