Commit 625e3a72 authored by André Almeida's avatar André Almeida

Incapsulate require buffers

parent 5ae7decd
......@@ -97,7 +97,18 @@ void v4l2_s_fmt(int fd, struct context ctx){
}
void v4l2_reqbuf(int fd, struct context ctx){
struct v4l2_requestbuffers req;
CLEAR(req);
req.count = ctx.num_buffers;
req.type = ctx.buf_type;
req.memory = ctx.mem_type;
xioctl(fd, VIDIOC_REQBUFS, &req);
if (req.count < ctx.num_buffers){
printf("Warning: couldn't allocate all requested buffers");
ctx.num_buffers = req.count;
}
}
void v4l2_querybuf(int fd, struct context ctx){
......@@ -154,16 +165,7 @@ int main(int argc, char **argv)
v4l2_s_fmt(fd, ctx);
/* Requiring buffers */
CLEAR(req);
req.count = ctx.num_buffers;
req.type = ctx.buf_type;
req.memory = ctx.mem_type;
xioctl(fd, VIDIOC_REQBUFS, &req);
if (req.count < ctx.num_buffers){
printf("Warning: couldn't allocate all requested buffers");
ctx.num_buffers = req.count;
}
v4l2_reqbuf(fd, ctx);
/* Buffer memory allocation */
buffers = calloc(ctx.num_planes * ctx.num_buffers, sizeof(*buffers));
......
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