Basic mmap question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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































[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux