]> git.sesse.net Git - ffmpeg/commitdiff
lavd/v4l2: return meaningful error code from device_init()
authorStefano Sabatini <stefasab@gmail.com>
Tue, 15 Jan 2013 11:01:06 +0000 (12:01 +0100)
committerStefano Sabatini <stefasab@gmail.com>
Tue, 15 Jan 2013 20:48:36 +0000 (21:48 +0100)
In particular, propagate errno value in case of device init failure.

libavdevice/v4l2.c

index 87c041a407acd857894bc8036fc4f5563ef3ac3f..60ab924445600c14af4a61387763db09ecd117c5 100644 (file)
@@ -228,7 +228,8 @@ static int device_init(AVFormatContext *ctx, int *width, int *height,
     pix->pixelformat = pix_fmt;
     pix->field = V4L2_FIELD_ANY;
 
-    res = v4l2_ioctl(fd, VIDIOC_S_FMT, &fmt);
+    if (v4l2_ioctl(fd, VIDIOC_S_FMT, &fmt) < 0)
+        res = AVERROR(errno);
 
     if ((*width != fmt.fmt.pix.width) || (*height != fmt.fmt.pix.height)) {
         av_log(ctx, AV_LOG_INFO,
@@ -243,7 +244,7 @@ static int device_init(AVFormatContext *ctx, int *width, int *height,
                "The V4L2 driver changed the pixel format "
                "from 0x%08X to 0x%08X\n",
                pix_fmt, fmt.fmt.pix.pixelformat);
-        res = -1;
+        res = AVERROR(EINVAL);
     }
 
     if (fmt.fmt.pix.field == V4L2_FIELD_INTERLACED) {