[vlc-commits] v4l2: remove useless switch(), cosmetic, no functional changes

Rémi Denis-Courmont git at videolan.org
Wed Apr 4 21:41:56 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Apr  4 22:31:25 2012 +0300| [630c2645938293309c7735e1cc5ebca8b8100170] | committer: Rémi Denis-Courmont

v4l2: remove useless switch(), cosmetic, no functional changes

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=630c2645938293309c7735e1cc5ebca8b8100170
---

 modules/access/v4l2/video.c |   60 ++++++++++++++++++-------------------------
 1 files changed, 25 insertions(+), 35 deletions(-)

diff --git a/modules/access/v4l2/video.c b/modules/access/v4l2/video.c
index 67fce2d..5ae4b40 100644
--- a/modules/access/v4l2/video.c
+++ b/modules/access/v4l2/video.c
@@ -763,57 +763,47 @@ int SetupInput (vlc_object_t *obj, int fd)
 /*****************************************************************************
  * GrabVideo: Grab a video frame
  *****************************************************************************/
-block_t* GrabVideo( vlc_object_t *p_demux, demux_sys_t *p_sys )
+block_t* GrabVideo (vlc_object_t *demux, demux_sys_t *sys)
 {
-    block_t *p_block;
-    struct v4l2_buffer buf;
+    struct v4l2_buffer buf = {
+        .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
+        .memory = V4L2_MEMORY_MMAP,
+    };
 
-    /* Grab Video Frame */
-    switch( p_sys->io )
+    /* Wait for next frame */
+    if (v4l2_ioctl (sys->i_fd, VIDIOC_DQBUF, &buf) < 0)
     {
-    case IO_METHOD_MMAP:
-        memset( &buf, 0, sizeof(buf) );
-        buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-        buf.memory = V4L2_MEMORY_MMAP;
-
-        /* Wait for next frame */
-        if (v4l2_ioctl( p_sys->i_fd, VIDIOC_DQBUF, &buf ) < 0 )
+        switch (errno)
         {
-            switch( errno )
-            {
             case EAGAIN:
                 return NULL;
             case EIO:
                 /* Could ignore EIO, see spec. */
                 /* fall through */
             default:
-                msg_Err( p_demux, "Failed to wait (VIDIOC_DQBUF)" );
+                msg_Err (demux, "dequeue error: %m");
                 return NULL;
-               }
-        }
-
-        if( buf.index >= p_sys->i_nbuffers ) {
-            msg_Err( p_demux, "Failed capturing new frame as i>=nbuffers" );
-            return NULL;
         }
+    }
 
-        p_block = ProcessVideoFrame( p_demux, p_sys->p_buffers[buf.index].start, buf.bytesused );
-        if( !p_block )
-            return NULL;
+    if (buf.index >= sys->i_nbuffers) {
+        msg_Err (demux, "Failed capturing new frame as i>=nbuffers");
+        return NULL;
+    }
 
-        /* Unlock */
-        if( v4l2_ioctl( p_sys->i_fd, VIDIOC_QBUF, &buf ) < 0 )
-        {
-            msg_Err( p_demux, "Failed to unlock (VIDIOC_QBUF)" );
-            block_Release( p_block );
-            return NULL;
-        }
+    block_t *block = ProcessVideoFrame(demux, sys->p_buffers[buf.index].start,
+                                       buf.bytesused);
+    if (block == NULL)
+        return NULL;
 
-        break;
-    default:
-        assert(0);
+    /* Unlock */
+    if (v4l2_ioctl (sys->i_fd, VIDIOC_QBUF, &buf) < 0)
+    {
+        msg_Err (demux, "queue error: %m");
+        block_Release (block);
+        return NULL;
     }
-    return p_block;
+    return block;
 }
 
 /*****************************************************************************



More information about the vlc-commits mailing list