About the VIDIOC_DQBUF

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

 



Dear all ~~

I have met a issue when I used the mmap method for previewing . I just
used the standard code as spec to get the image data :
status_t CameraHardwareProwave::V4l2Camera::v4l2CaptureMainloop()
{
	LOG_FUNCTION_NAME
	int rt  ;
	unsigned int i ;
	fd_set fds ;
	struct timeval tv ;
	struct v4l2_buffer buf ;

	for(;;){
		FD_ZERO(&fds) ;
		FD_SET(v4l2Fd, &fds) ;
		//now the time is long ,just for debug
		tv.tv_sec = 2 ;
		tv.tv_usec = 0 ;

		rt = select(v4l2Fd + 1, &fds, NULL, NULL, &tv) ;
		LOGD("The value of select return : %d\n", rt) ;
		
		/********** for debug
		if(V4L2_NOERROR != v4l2ReadFrame()){
			LOGE("READ ERROR") ;
		}
                ***********/
		
		if(-1 == rt){
			LOGE("there is something wrong in select function(select)") ;
			//no defined error manage
			return V4L2_IOCTL_ERROR ;
		}
		if(0 == rt){
			LOGE("wait for data timeout in select") ;
			return V4L2_TIMEOUT ;
		}

		memset(&buf, 0, sizeof(buf)) ;
		buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE ;
		buf.memory = V4L2_MEMORY_MMAP ;
		if(-1 == ioctl(v4l2Fd, VIDIOC_DQBUF, &buf)){
		    LOGE("there is something wrong in dequeue buffer(VIDIOC_DQBUF)") ;
			return V4L2_IOCTL_ERROR ;
		}
		
		assert(i < n_buf) ;
		LOGE("buf.index  0buf.length = %d %d \n", buf.index , buf.length) ;
        memcpy((mCameraProwave->getPreviewHeap())->base(),
v4l2Buffer[buf.index].start, buf.length) ;
		if(-1 == ioctl(v4l2Fd, VIDIOC_QBUF, &buf)){
		    LOGE("there is something wrong in enqueue buffer(VIDIOC_QBUF)") ;
			return V4L2_IOCTL_ERROR ;
		}
		//break ;   //i don't know whether the break is needed ;
		 
	}
	return V4L2_NOERROR ;
}

when executed the VIDIOC_DQBUF IOCTL,the return value was right, but the
value of buf.length would always  be zero. Then I used the read()
function to read raw data in the file handle for debug, and I can get
the raw data. Anybody have met this issue before ? Who can give me some
advices or tell me what is wrong , thanks a lot ~

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux