[FFmpeg-cvslog] r23001 - trunk/libavdevice/v4l2.c

stefano subversion
Sat May 1 10:24:25 CEST 2010


Author: stefano
Date: Sat May  1 10:24:24 2010
New Revision: 23001

Log:
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().

Modified:
   trunk/libavdevice/v4l2.c

Modified: trunk/libavdevice/v4l2.c
==============================================================================
--- trunk/libavdevice/v4l2.c	Sat May  1 01:32:42 2010	(r23000)
+++ trunk/libavdevice/v4l2.c	Sat May  1 10:24:24 2010	(r23001)
@@ -153,7 +153,7 @@ static int device_open(AVFormatContext *
 {
     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 *
 
     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");



More information about the ffmpeg-cvslog mailing list