I have a basic mmap question I hope I can get some help with.

I haven't been able to find a clear example of using it with a camera, so
please excuse my ignorance.

My code pretty much works, but there are some performance issues.


This is how I initialize the mmap

   ioctl(camera_fd, VIDIOCGMBUF, &vid_mbuf);
   grab_size = grab_buf.width * grab_buf.height * 3;

   picture = mmap(0, grab_size, PROT_READ | PROT_WRITE, MAP_SHARED,
camera_fd, 0);



-- This should make it so I am sharing a 1 frame buffer with the camera (an
OV511)


To read it, I do

        grab_buf.frame = 0;

        if (pthread_mutex_lock(&camera_mem_mutex))
                pthread_exit(NULL);

        if (ioctl(camera_fd, VIDIOCMCAPTURE, &grab_buf) == -1)
        {
                pthread_mutex_unlock(&camera_mem_mutex);
                perror("ioctl VIDIOCMCAPTURE");
                return 0;
        }

        if (ioctl(camera_fd, VIDIOCSYNC, &grab_buf.frame) == -1)
        {
                pthread_mutex_unlock(&camera_mem_mutex);
                perror("ioctl VIDIOCSYNC");
        return 0;
        }

        pthread_mutex_unlock(&camera_mem_mutex);



-- Here (inside a thread) I am "safely" waiting for frame 0 to "sync" -
which I assume means get filled from the camera.


Sometimes I get stuck waiting for VIDIOSYNC.

Is this the correct order of operation?  Can I set the camera up to use
multiple frames effectively?  Is is worth it?


-- Devin





























_______________________________________________
Video4linux-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/video4linux-list

Reply via email to