[vlc-commits] v4l2: GrabVideo() cleanup
Rémi Denis-Courmont
git at videolan.org
Wed Apr 11 18:20:26 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Apr 11 19:08:40 2012 +0300| [dde47d92a2fd64d16bffda1e253c6c6c73c4885c] | committer: Rémi Denis-Courmont
v4l2: GrabVideo() cleanup
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dde47d92a2fd64d16bffda1e253c6c6c73c4885c
---
modules/access/v4l2/access.c | 2 +-
modules/access/v4l2/demux.c | 2 +-
modules/access/v4l2/v4l2.h | 2 +-
modules/access/v4l2/video.c | 14 +++++---------
4 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/modules/access/v4l2/access.c b/modules/access/v4l2/access.c
index 1ca4e9a..6a74c3f 100644
--- a/modules/access/v4l2/access.c
+++ b/modules/access/v4l2/access.c
@@ -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();
diff --git a/modules/access/v4l2/demux.c b/modules/access/v4l2/demux.c
index 8e28e22..8b82597 100644
--- a/modules/access/v4l2/demux.c
+++ b/modules/access/v4l2/demux.c
@@ -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 ();
diff --git a/modules/access/v4l2/v4l2.h b/modules/access/v4l2/v4l2.h
index 3fe47a9..c1ffd5b 100644
--- a/modules/access/v4l2/v4l2.h
+++ b/modules/access/v4l2/v4l2.h
@@ -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 *);
diff --git a/modules/access/v4l2/video.c b/modules/access/v4l2/video.c
index 8a5a740..99c81ee 100644
--- a/modules/access/v4l2/video.c
+++ b/modules/access/v4l2/video.c
@@ -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);
More information about the vlc-commits
mailing list