Ignore:
Timestamp:
02/19/20 10:18:36 (2 years ago)
Author:
Sanahuja Guillaume
Message:

modifs v4l2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/V4LCamera.cpp

    r348 r349  
    3131#include <VisionFilter.h>
    3232
    33 #define DEFAULT_V4L_BUFFERS 4
    34 
    3533using std::string;
    3634using namespace flair::core;
     
    6563  }
    6664 
    67   /* This is just a technicality, but all buffers must be filled up before any
    68   staggered SYNC is applied.  SO, filler up. (see V4L HowTo) */
    6965
    7066  allocBuffers();
     
    151147  if(-1 == xioctl (device, VIDIOC_S_FMT, &form)) {
    152148    Thread::Err("Could not set specifics of capture window.\n");
    153     return -1;
    154   }
    155 
    156   /* Get window info again, to get the real value */
    157   if(-1 == xioctl (device, VIDIOC_G_FMT, &form)) {
    158     Thread::Err("Could not obtain specifics of capture window.\n");
    159149    return -1;
    160150  }
     
    320310
    321311int V4LCamera::AllocBuffers(void) {
    322   struct v4l2_requestbuffers requestbuffers;
    323   memset(&requestbuffers, 0, sizeof (v4l2_requestbuffers));
    324 
    325   unsigned int buffer_number = DEFAULT_V4L_BUFFERS;
    326 
    327   try_again:
    328 
    329   requestbuffers.count = buffer_number;
    330   requestbuffers.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    331   requestbuffers.memory = V4L2_MEMORY_USERPTR;
    332 
    333   if (xioctl (device, VIDIOC_REQBUFS, &requestbuffers)==-1) {
     312  struct v4l2_requestbuffers req;
     313  memset(&req, 0, sizeof (v4l2_requestbuffers));
     314  nbBuffers=DEFAULT_V4L_BUFFERS;
     315
     316  req.count = nbBuffers;
     317  req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
     318  req.memory = V4L2_MEMORY_USERPTR;
     319
     320  if (xioctl (device, VIDIOC_REQBUFS, &req)==-1) {
    334321    if (errno==EINVAL) {
    335322      Thread::Err("VIDIOC_REQBUFS user memory not supported\n");
     
    340327  }
    341328
    342   nbBuffers=DEFAULT_V4L_BUFFERS;
    343329  for (int i=0; i<nbBuffers; i++) {
    344330    buffers[i] =AllocFunction(output->GetDataType().GetSize());
     
    517503        memset(&buf, 0, sizeof (v4l2_buffer));
    518504        buf.type        = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    519         buf.memory      = V4L2_MEMORY_USERPTR;//V4L2_MEMORY_MMAP;
     505        buf.memory      = V4L2_MEMORY_USERPTR;
    520506        buf.index       = (unsigned long)index;
    521507        buf.m.userptr=(unsigned long)(buffers[index]);
Note: See TracChangeset for help on using the changeset viewer.