diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-05-01 08:24:24 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-05-01 08:24:24 +0000 |
commit | 50f852186fda7392dbbf110fb9dc8f1fae9d9258 (patch) | |
tree | 1d3f9a25765204443ad52c02845df7d45053c7a5 /libavdevice/v4l2.c | |
parent | 2d23fecd5dfbf544d8ddc0cada2e09d4ddce2a92 (diff) | |
download | ffmpeg-50f852186fda7392dbbf110fb9dc8f1fae9d9258.tar.gz |
Make device_open() store the VIDIOC_QUERYCAP ioctl errno, and in case
of failure return the stored value rather than the current errno,
which may be overwritten by a following call to close().
Originally committed as revision 23001 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavdevice/v4l2.c')
-rw-r--r-- | libavdevice/v4l2.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index c8854c05c5..ce88903c3a 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -153,7 +153,7 @@ static int device_open(AVFormatContext *ctx, uint32_t *capabilities) { struct v4l2_capability cap; int fd; - int res; + int res, err; int flags = O_RDWR; if (ctx->flags & AVFMT_FLAG_NONBLOCK) { @@ -169,18 +169,18 @@ static int device_open(AVFormatContext *ctx, uint32_t *capabilities) res = ioctl(fd, VIDIOC_QUERYCAP, &cap); // ENOIOCTLCMD definition only availble on __KERNEL__ - if (res < 0 && errno == 515) { + if (res < 0 && ((err = errno) == 515)) { av_log(ctx, AV_LOG_ERROR, "QUERYCAP not implemented, probably V4L device but not supporting V4L2\n"); close(fd); - return AVERROR(errno); + return AVERROR(515); } if (res < 0) { av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYCAP): %s\n", strerror(errno)); close(fd); - return AVERROR(errno); + return AVERROR(err); } if ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) { av_log(ctx, AV_LOG_ERROR, "Not a video capture device\n"); |