Commit 49c6c629 authored by André Almeida's avatar André Almeida

Incapsulate enqueue buffers

parent 625e3a72
......@@ -115,7 +115,18 @@ void v4l2_querybuf(int fd, struct context ctx){
}
void v4l2_qbuf(int fd, struct context ctx){
/* enqueue buffer of index i */
void v4l2_qbuf(int fd, struct context ctx, int i, struct v4l2_plane *planes, struct v4l2_buffer *buf){
CLEAR(*buf);
CLEAR(*planes);
buf->type = ctx.buf_type;
buf->memory = ctx.mem_type;
buf->m.planes = planes;
buf->length = ctx.num_planes;
buf->index = i;
xioctl(fd, VIDIOC_QBUF, buf);
}
......@@ -211,16 +222,8 @@ int main(int argc, char **argv)
#endif
/* enqueue the buffers */
for (i = 0; i < ctx.num_buffers; i++) {
CLEAR(buf);
CLEAR(planes);
buf.type = ctx.buf_type;
buf.memory = ctx.mem_type;
buf.m.planes = planes;
buf.length = ctx.num_planes;
buf.index = i;
xioctl(fd, VIDIOC_QBUF, &buf);
}
for (i = 0; i < ctx.num_buffers; i++)
v4l2_qbuf(fd, ctx, i, planes, &buf);
/* start the streaming */
type = ctx.buf_type;
......@@ -276,8 +279,8 @@ int main(int argc, char **argv)
buf.m.planes[j].bytesused, 1, fout);
}
/* reinsert the buffer on queue */
xioctl(fd, VIDIOC_QBUF, &buf);
/* reinsert the buffer on queue and close the file */
v4l2_qbuf(fd, ctx, i, planes, &buf);
fclose(fout);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment