[vlc-commits] V4L2: merge two switches

Rémi Denis-Courmont git at videolan.org
Sun Sep 4 14:57:19 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Sep  4 15:42:02 2011 +0300| [89779c4a8296ef97bee7917f2d231a0d1d55d2f4] | committer: Rémi Denis-Courmont

V4L2: merge two switches

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

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

diff --git a/modules/access/v4l2/video.c b/modules/access/v4l2/video.c
index 8a29cef..ea01a8f 100644
--- a/modules/access/v4l2/video.c
+++ b/modules/access/v4l2/video.c
@@ -1931,7 +1931,7 @@ static int OpenVideoDev( vlc_object_t *p_obj, const char *path,
 #endif
 
 
-    /* Init IO method */
+    /* Init I/O method */
     switch( p_sys->io )
     {
     case IO_METHOD_READ:
@@ -1942,55 +1942,6 @@ static int OpenVideoDev( vlc_object_t *p_obj, const char *path,
     case IO_METHOD_MMAP:
         if( InitMmap( p_obj, p_sys, i_fd ) )
             goto error;
-        break;
-
-    case IO_METHOD_USERPTR:
-        if( InitUserP( p_obj, p_sys, i_fd, fmt.fmt.pix.sizeimage ) )
-            goto error;
-        break;
-    }
-
-    if( b_demux )
-    {
-        int ar = 4 * VOUT_ASPECT_FACTOR / 3;
-        char *str = var_InheritString( p_obj, CFG_PREFIX"aspect-ratio" );
-        if( likely(str != NULL) )
-        {
-            const char *delim = strchr( str, ':' );
-            if( delim )
-                ar = atoi( str ) * VOUT_ASPECT_FACTOR / atoi( delim + 1 );
-            free( str );
-        }
-
-        /* Add */
-        es_fmt.video.i_width  = width;
-        es_fmt.video.i_height = height;
-
-        /* Get aspect-ratio */
-        es_fmt.video.i_sar_num = ar * es_fmt.video.i_height;
-        es_fmt.video.i_sar_den = VOUT_ASPECT_FACTOR * es_fmt.video.i_width;
-
-        /* Framerate */
-        es_fmt.video.i_frame_rate = lround(f_fps * 1000000.);
-        es_fmt.video.i_frame_rate_base = 1000000;
-
-        demux_t *p_demux = (demux_t *) p_obj;
-        msg_Dbg( p_demux, "added new video es %4.4s %dx%d",
-            (char*)&es_fmt.i_codec, es_fmt.video.i_width, es_fmt.video.i_height );
-        msg_Dbg( p_obj, " frame rate: %f", f_fps );
-
-        p_sys->p_es = es_out_Add( p_demux->out, &es_fmt );
-    }
-
-    /* Start Capture */
-
-    switch( p_sys->io )
-    {
-    case IO_METHOD_READ:
-        /* Nothing to do */
-        break;
-
-    case IO_METHOD_MMAP:
         for (unsigned int i = 0; i < p_sys->i_nbuffers; ++i)
         {
             struct v4l2_buffer buf;
@@ -2013,10 +1964,11 @@ static int OpenVideoDev( vlc_object_t *p_obj, const char *path,
             msg_Err( p_obj, "VIDIOC_STREAMON failed" );
             goto error;
         }
-
         break;
 
     case IO_METHOD_USERPTR:
+        if( InitUserP( p_obj, p_sys, i_fd, fmt.fmt.pix.sizeimage ) )
+            goto error;
         for( unsigned int i = 0; i < p_sys->i_nbuffers; ++i )
         {
             struct v4l2_buffer buf;
@@ -2045,6 +1997,38 @@ static int OpenVideoDev( vlc_object_t *p_obj, const char *path,
     }
 
     free( codecs );
+
+    if( b_demux )
+    {
+        int ar = 4 * VOUT_ASPECT_FACTOR / 3;
+        char *str = var_InheritString( p_obj, CFG_PREFIX"aspect-ratio" );
+        if( likely(str != NULL) )
+        {
+            const char *delim = strchr( str, ':' );
+            if( delim )
+                ar = atoi( str ) * VOUT_ASPECT_FACTOR / atoi( delim + 1 );
+            free( str );
+        }
+
+        /* Add */
+        es_fmt.video.i_width  = width;
+        es_fmt.video.i_height = height;
+
+        /* Get aspect-ratio */
+        es_fmt.video.i_sar_num = ar * es_fmt.video.i_height;
+        es_fmt.video.i_sar_den = VOUT_ASPECT_FACTOR * es_fmt.video.i_width;
+
+        /* Framerate */
+        es_fmt.video.i_frame_rate = lround(f_fps * 1000000.);
+        es_fmt.video.i_frame_rate_base = 1000000;
+
+        demux_t *p_demux = (demux_t *) p_obj;
+        msg_Dbg( p_demux, "added new video es %4.4s %dx%d",
+            (char*)&es_fmt.i_codec, es_fmt.video.i_width, es_fmt.video.i_height );
+        msg_Dbg( p_obj, " frame rate: %f", f_fps );
+
+        p_sys->p_es = es_out_Add( p_demux->out, &es_fmt );
+    }
     return i_fd;
 
 error:



More information about the vlc-commits mailing list