aboutsummaryrefslogtreecommitdiffstats
path: root/libavdevice/v4l2.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2013-01-15 12:01:06 +0100
committerStefano Sabatini <stefasab@gmail.com>2013-01-15 21:48:36 +0100
commitaa359d3808e3cf935dabcee15e248261539ecd61 (patch)
tree143262310bcef6ef2ea1c9f17fc01c546542dff3 /libavdevice/v4l2.c
parentfce165027fd8c9224e4163d22207584db2ac47b3 (diff)
downloadffmpeg-aa359d3808e3cf935dabcee15e248261539ecd61.tar.gz
lavd/v4l2: return meaningful error code from device_init()
In particular, propagate errno value in case of device init failure.
Diffstat (limited to 'libavdevice/v4l2.c')
-rw-r--r--libavdevice/v4l2.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 87c041a407..60ab924445 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -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) {