Commit dde47d92 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

v4l2: GrabVideo() cleanup

parent 7dc94047
......@@ -231,7 +231,7 @@ static block_t *AccessRead( access_t *access )
if( poll( &fd, 1, 500 ) <= 0 )
return NULL;
block_t *block = GrabVideo( VLC_OBJECT(access), sys );
block_t *block = GrabVideo (VLC_OBJECT(access), sys->i_fd, sys->bufv);
if( block != NULL )
{
block->i_pts = block->i_dts = mdate();
......
......@@ -537,7 +537,7 @@ static void *StreamThread (void *data)
}
int canc = vlc_savecancel ();
block_t *block = GrabVideo (VLC_OBJECT(demux), sys);
block_t *block = GrabVideo (VLC_OBJECT(demux), fd, sys->bufv);
if (block != NULL)
{
block->i_pts = block->i_dts = mdate ();
......
......@@ -111,7 +111,7 @@ int SetupFormat (vlc_object_t *, int, uint32_t,
#define SetupFormat(o,fd,fcc,fmt,p) \
SetupFormat(VLC_OBJECT(o),fd,fcc,fmt,p)
struct buffer_t *InitMmap (vlc_object_t *, int, uint32_t *);
block_t* GrabVideo(vlc_object_t *, demux_sys_t *);
block_t* GrabVideo (vlc_object_t *, int, const struct buffer_t *);
/* demux.c */
int DemuxOpen(vlc_object_t *);
......
......@@ -978,7 +978,8 @@ int SetupFormat (vlc_object_t *obj, int fd, uint32_t fourcc,
/*****************************************************************************
* GrabVideo: Grab a video frame
*****************************************************************************/
block_t* GrabVideo (vlc_object_t *demux, demux_sys_t *sys)
block_t *GrabVideo (vlc_object_t *demux, int fd,
const struct buffer_t *restrict bufv)
{
struct v4l2_buffer buf = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
......@@ -986,7 +987,7 @@ block_t* GrabVideo (vlc_object_t *demux, demux_sys_t *sys)
};
/* Wait for next frame */
if (v4l2_ioctl (sys->i_fd, VIDIOC_DQBUF, &buf) < 0)
if (v4l2_ioctl (fd, VIDIOC_DQBUF, &buf) < 0)
{
switch (errno)
{
......@@ -1001,19 +1002,14 @@ block_t* GrabVideo (vlc_object_t *demux, demux_sys_t *sys)
}
}
if (buf.index >= sys->bufc) {
msg_Err (demux, "Failed capturing new frame as i>=nbuffers");
return NULL;
}
/* Copy frame */
block_t *block = block_Alloc (buf.bytesused);
if (unlikely(block == NULL))
return NULL;
memcpy (block->p_buffer, sys->bufv[buf.index].start, buf.bytesused);
memcpy (block->p_buffer, bufv[buf.index].start, buf.bytesused);
/* Unlock */
if (v4l2_ioctl (sys->i_fd, VIDIOC_QBUF, &buf) < 0)
if (v4l2_ioctl (fd, VIDIOC_QBUF, &buf) < 0)
{
msg_Err (demux, "queue error: %m");
block_Release (block);
......
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