[FFmpeg-cvslog] v4l2: rewrite code iterating the supported standards

Stefano Sabatini git at videolan.org
Mon May 30 09:46:44 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Sat May 28 21:14:06 2011 +0200| [7533a727f9efed2d0eb6c8b452ff9e35214f5c8e] | committer: Stefano Sabatini

v4l2: rewrite code iterating the supported standards

Simplify/clarify the code logic and error reporting.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7533a727f9efed2d0eb6c8b452ff9e35214f5c8e
---

 libavdevice/v4l2.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index d1bf572..605b7b7 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -437,7 +437,7 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap)
     struct v4l2_standard standard = {0};
     struct v4l2_streamparm streamparm = {0};
     struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe;
-    int i;
+    int i, ret;
 
     streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 
@@ -474,15 +474,13 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap)
         /* set tv standard */
         for (i = 0;; i++) {
             standard.index = i;
-            if (ioctl(s->fd, VIDIOC_ENUMSTD, &standard) < 0) {
-                av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set standard(%s) failed\n",
-                       s->standard);
-                return AVERROR(EIO);
-            }
-
-            if (!strcasecmp(standard.name, s->standard)) {
+            ret = ioctl(s->fd, VIDIOC_ENUMSTD, &standard);
+            if (ret < 0 || !strcasecmp(standard.name, s->standard))
                 break;
-            }
+        }
+        if (ret < 0) {
+            av_log(s1, AV_LOG_ERROR, "Unknown standard '%s'\n", s->standard);
+            return ret;
         }
 
         av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s, id: %"PRIu64"\n",



More information about the ffmpeg-cvslog mailing list