[vlc-commits] v4l2: remove unneeded demux_sys_t.io

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:17:36 2012 +0300| [f1fa0918c8095783ff2b0514d535a430418877f9] | committer: Rémi Denis-Courmont

v4l2: remove unneeded demux_sys_t.io

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

 modules/access/v4l2/demux.c |   47 ++++++++++++------------------------------
 1 files changed, 14 insertions(+), 33 deletions(-)

diff --git a/modules/access/v4l2/demux.c b/modules/access/v4l2/demux.c
index 8ae76f7..a81715b 100644
--- a/modules/access/v4l2/demux.c
+++ b/modules/access/v4l2/demux.c
@@ -41,20 +41,11 @@
 
 #include "v4l2.h"
 
-/* TODO: remove this, use callbacks */
-typedef enum {
-    IO_METHOD_READ=1,
-    IO_METHOD_MMAP,
-} io_method;
-
 struct demux_sys_t
 {
     int fd;
     vlc_thread_t thread;
 
-    /* Video */
-    io_method io;
-
     struct buffer_t *bufv;
     union
     {
@@ -480,14 +471,12 @@ static int InitVideo (demux_t *demux, int fd)
             msg_Err (demux, "cannot start streaming: %m");
             return -1;
         }
-
-        sys->io = IO_METHOD_MMAP;
         entry = StreamThread;
     }
     else if (caps & V4L2_CAP_READWRITE)
     {
+        sys->bufv = NULL;
         sys->blocksize = fmt.fmt.pix.sizeimage;
-        sys->io = IO_METHOD_READ;
         entry = ReadThread;
     }
     else
@@ -511,30 +500,22 @@ void DemuxClose( vlc_object_t *obj )
     vlc_join (sys->thread, NULL);
 
     /* Stop video capture */
-    switch( sys->io )
+    if (sys->bufv != NULL)
     {
-        case IO_METHOD_READ:
-            /* Nothing to do */
-            break;
-
-        case IO_METHOD_MMAP:
+        for (uint32_t i = 0; i < sys->bufc; i++)
         {
-            /* NOTE: Some buggy drivers hang if buffers are not unmapped before
-             * streamoff */
-            for (uint32_t i = 0; i < sys->bufc; i++)
-            {
-                struct v4l2_buffer buf = {
-                    .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
-                    .memory = V4L2_MEMORY_MMAP,
-                };
-                v4l2_ioctl (fd, VIDIOC_DQBUF, &buf);
-                v4l2_munmap (sys->bufv[i].start, sys->bufv[i].length);
-            }
-            enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-            v4l2_ioctl (fd, VIDIOC_STREAMOFF, &buf_type);
-            free (sys->bufv);
-            break;
+            struct v4l2_buffer buf = {
+                .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
+                .memory = V4L2_MEMORY_MMAP,
+            };
+
+            v4l2_ioctl (fd, VIDIOC_DQBUF, &buf);
+            v4l2_munmap (sys->bufv[i].start, sys->bufv[i].length);
         }
+
+        enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+        v4l2_ioctl (fd, VIDIOC_STREAMOFF, &buf_type);
+        free (sys->bufv);
     }
 
     ControlsDeinit( obj, sys->controls );



More information about the vlc-commits mailing list