[MPlayer-dev-eng] [PATCH] fix for v4l1 driver

Trent Piepho xyzzy at speakeasy.org
Sun Apr 29 12:38:13 CEST 2007


On Sun, 29 Apr 2007, Vladimir Voroshilov wrote:
> 2007/4/28, Trent Piepho <xyzzy at speakeasy.org>:
>
> >@@ -798,6 +770,53 @@
> >     if (ioctl(priv->video_fd, VIDIOCSPICT, &priv->picture) == -1)
> >     {
> > 	mp_msg(MSGT_TV, MSGL_ERR, "ioctl set picture failed: %s\n", strerror(errno));
> >+	mp_msg(MSGT_TV, MSGL_ERR, "The 'outfmt' of '%s' is likely not
> supported by your card\n",
> >+	       vo_format_name(priv->format));
> >+	return 0;
>
> Why don't you change existing message?
> Other parts looks ok for for me at quick-look.

It seemed like the existing message was still relevant, since it says what
ioctl failed and the error code.

>
> In another cosmetics patch you also change comment in disabled block of
> code.
> Can i know the reason for it ?

I thought it was a call to VIDIOSCAPTURE instead of VIDIOCCAPTURE, but it's
not so I've taken that change out.

I see you pulled the typo fix out of my patch and put in already, so I won't
include that again in my patch.
-------------- next part --------------
--- stream/tvi_v4l.c	2007-04-29 02:53:02.000000000 -0700
+++ stream/tvi_v4l.c.fixed	2007-04-29 03:27:14.000000000 -0700
@@ -597,35 +597,6 @@
         goto err;
     }
 
-    if ( !tv_param_mjpeg )
-    {
-        /* map grab buffer */
-        if (ioctl(priv->video_fd, VIDIOCGMBUF, &priv->mbuf) == -1)
-        {
-            mp_msg(MSGT_TV, MSGL_ERR, "ioctl get mbuf failed: %s\n", strerror(errno));
-            goto err;
-        }
-
-        mp_msg(MSGT_TV, MSGL_V, "mbuf: size=%d, frames=%d\n",
-            priv->mbuf.size, priv->mbuf.frames);
-        priv->mmap = mmap(0, priv->mbuf.size, PROT_READ|PROT_WRITE,
-                          MAP_SHARED, priv->video_fd, 0);
-        if (priv->mmap == (unsigned char *)-1)
-        {
-            mp_msg(MSGT_TV, MSGL_ERR, "Unable to map memory for buffers: %s\n", strerror(errno));
-            goto err;
-        }
-        mp_msg(MSGT_TV, MSGL_DBG2, "our buffer: %p\n", priv->mmap);
-
-        /* num of buffers */
-        priv->nbuf = priv->mbuf.frames;
-
-        /* video buffers */
-        priv->buf = calloc(priv->nbuf, sizeof(struct video_mmap));
-        if (!priv->buf)
-            goto malloc_failed;
-        memset(priv->buf, 0, priv->nbuf * sizeof(struct video_mmap));
-    }
 
     /* init v4l audio even when we don't capture */
     init_v4l_audio(priv);
@@ -770,6 +741,7 @@
 {
     int i;
     int bytes_per_sample;
+    struct video_window win;
 
     if (ioctl(priv->video_fd, VIDIOCGPICT, &priv->picture) == -1)
     {
@@ -796,6 +768,50 @@
     if (ioctl(priv->video_fd, VIDIOCSPICT, &priv->picture) == -1)
     {
         mp_msg(MSGT_TV, MSGL_ERR, "ioctl set picture failed: %s\n", strerror(errno));
+        mp_msg(MSGT_TV, MSGL_ERR, "The 'outfmt' of '%s' is likely not supported by your card\n",
+               vo_format_name(priv->format));
+        return 0;
+    }
+
+    /* Set capture size */
+    win.x = 0;
+    win.y = 0;
+    win.width = priv->width;
+    win.height = priv->height;
+    win.chromakey = -1;
+    win.flags = 0;
+    win.clipcount = 0;
+    if (ioctl(priv->video_fd, VIDIOCSWIN, &win) == -1)
+        mp_msg(MSGT_TV, MSGL_ERR, "ioctl set window failed: %s\n", strerror(errno));
+
+    if ( !tv_param_mjpeg )
+    {
+        /* map grab buffer */
+        if (ioctl(priv->video_fd, VIDIOCGMBUF, &priv->mbuf) == -1)
+        {
+            mp_msg(MSGT_TV, MSGL_ERR, "ioctl get mbuf failed: %s\n", strerror(errno));
+            return 0;
+        }
+
+        mp_msg(MSGT_TV, MSGL_V, "mbuf: size=%d, frames=%d\n",
+            priv->mbuf.size, priv->mbuf.frames);
+        priv->mmap = mmap(0, priv->mbuf.size, PROT_READ|PROT_WRITE,
+                          MAP_SHARED, priv->video_fd, 0);
+        if (priv->mmap == (unsigned char *)-1)
+        {
+            mp_msg(MSGT_TV, MSGL_ERR, "Unable to map memory for buffers: %s\n", strerror(errno));
+            return 0;
+        }
+        mp_msg(MSGT_TV, MSGL_DBG2, "our buffer: %p\n", priv->mmap);
+
+        /* num of buffers */
+        priv->nbuf = priv->mbuf.frames;
+
+        /* video buffers */
+        priv->buf = calloc(priv->nbuf, sizeof(struct video_mmap));
+        if (!priv->buf)
+            return 0;
+        memset(priv->buf, 0, priv->nbuf * sizeof(struct video_mmap));
     }
 
     if ( !tv_param_mjpeg )
@@ -827,20 +843,6 @@
 #endif
 
 #if 0
-    {
-        struct video_window win;
-
-        win.x = 0;
-        win.y = 0;
-        win.width = priv->width;
-        win.height = priv->height;
-        win.chromakey = -1;
-        win.flags = 0;
-        //win.clipcount = 0;
-
-        ioctl(priv->video_fd, VIDIOCSWIN, &win);
-    }
-
     // initialize video capture
     if (ioctl(priv->video_fd, VIDIOCCAPTURE, &one) == -1)
     {


More information about the MPlayer-dev-eng mailing list