[vlc-commits] v4l2c: merge I/O method initialization (no functional changes)

Rémi Denis-Courmont git at videolan.org
Tue Apr 10 22:15:09 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Apr 10 22:38:58 2012 +0300| [3432a593aae37a78828c4b01e1ab42db14a8a079] | committer: Rémi Denis-Courmont

v4l2c: merge I/O method initialization (no functional changes)

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

 modules/access/v4l2/access.c |   36 +++++++++++++-----------------------
 1 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/modules/access/v4l2/access.c b/modules/access/v4l2/access.c
index 03b64a0..2f7788d 100644
--- a/modules/access/v4l2/access.c
+++ b/modules/access/v4l2/access.c
@@ -85,10 +85,6 @@ int AccessOpen( vlc_object_t *obj )
     }
 
     sys->i_fd = fd;
-    if( sys->io == IO_METHOD_READ )
-        access->pf_read = AccessReadStream;
-    else
-        access->pf_block = AccessRead;
     access->pf_seek = NULL;
     access->pf_control = AccessControl;
     return VLC_SUCCESS;
@@ -131,16 +127,6 @@ int InitVideo (access_t *access, int fd)
         return -1;
     }
 
-    if (cap.capabilities & V4L2_CAP_STREAMING)
-        sys->io = IO_METHOD_MMAP;
-    else if (cap.capabilities & V4L2_CAP_READWRITE)
-        sys->io = IO_METHOD_READ;
-    else
-    {
-        msg_Err (access, "no supported I/O method");
-        return -1;
-    }
-
     if (SetupInput (VLC_OBJECT(access), fd))
         return -1;
 
@@ -180,13 +166,8 @@ int InitVideo (access_t *access, int fd)
     }
 
     /* Init I/O method */
-    switch (sys->io)
+    if (cap.capabilities & V4L2_CAP_STREAMING)
     {
-    case IO_METHOD_READ:
-        sys->blocksize = fmt.fmt.pix.sizeimage;
-        break;
-
-    case IO_METHOD_MMAP:
         if (InitMmap (VLC_OBJECT(access), sys, fd))
             return -1;
         for (unsigned int i = 0; i < sys->i_nbuffers; i++)
@@ -210,9 +191,18 @@ int InitVideo (access_t *access, int fd)
             msg_Err (access, "cannot start streaming: %m" );
             return -1;
         }
-        break;
-    default:
-        assert (0);
+
+        access->pf_block = AccessRead;
+    }
+    else if (cap.capabilities & V4L2_CAP_READWRITE)
+    {
+        sys->blocksize = fmt.fmt.pix.sizeimage;
+        access->pf_read = AccessReadStream;
+    }
+    else
+    {
+        msg_Err (access, "no supported I/O method");
+        return -1;
     }
     return 0;
 }



More information about the vlc-commits mailing list