Commit aebc5d37 authored by André Almeida's avatar André Almeida

Incapsulate dequeue buffer

parent fbb6b74f
......@@ -143,8 +143,19 @@ void v4l2_qbuf(int fd, struct context ctx, int i, struct v4l2_plane *planes, str
}
void v4l2_dqbuf(int fd, struct context ctx){
/* dequeue the first avalible buffer and return it index */
int v4l2_dqbuf(int fd, struct context ctx, 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;
xioctl(fd, VIDIOC_DQBUF, buf);
return buf->index;
}
int main(int argc, char **argv)
......@@ -270,14 +281,8 @@ int main(int argc, char **argv)
}
/* dequeue buffer */
CLEAR(buf);
CLEAR(planes);
buf.type = ctx.buf_type;
buf.memory = ctx.mem_type;
buf.m.planes = planes;
buf.length = ctx.num_planes;
xioctl(fd, VIDIOC_DQBUF, &buf);
int index = v4l2_dqbuf(fd, ctx, planes, &buf);
/* write each plane in the file */
for(j = 0; j < ctx.num_planes; j++){
#ifdef DBG_PRINT
......
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