[FFmpeg-devel] [PATCH] v4l2: remove call to v4l2_fd_open.

Clément Bœsch ubitux at gmail.com
Fri Jul 20 21:07:49 CEST 2012


On Fri, Jul 20, 2012 at 10:58:41AM +0200, Nicolas George wrote:
> v4l2_fd_open is already called at the end of v4l2_open;
> calling a second time leaks structures inside libv4l2.
> 
> Fix trac ticket #1560.
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavdevice/v4l2.c |   13 -------------
>  1 file changed, 13 deletions(-)
> 
> diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
> index 4829b1b..2808e13 100644
> --- a/libavdevice/v4l2.c
> +++ b/libavdevice/v4l2.c
> @@ -156,9 +156,6 @@ static int device_open(AVFormatContext *ctx)
>  {
>      struct v4l2_capability cap;
>      int fd;
> -#if CONFIG_LIBV4L2
> -    int fd_libv4l;
> -#endif
>      int res, err;
>      int flags = O_RDWR;
>  
> @@ -175,16 +172,6 @@ static int device_open(AVFormatContext *ctx)
>  
>          return AVERROR(err);
>      }
> -#if CONFIG_LIBV4L2
> -    fd_libv4l = v4l2_fd_open(fd, 0);
> -    if (fd < 0) {
> -        err = AVERROR(errno);
> -        av_log(ctx, AV_LOG_ERROR, "Cannot open video device with libv4l neither %s : %s\n",
> -               ctx->filename, strerror(errno));
> -        return err;
> -    }
> -    fd = fd_libv4l;
> -#endif
>  

Ah sorry about that. The original idea was to open ctx->filename with
open() all the time (with and without libv4l2), and then re-use that fd
with v4l2_fd_open if the user wanted to use libv4l2. Of course this makes
sense only if it is possible to select the use of libv4l2 at runtime (but
I was lazy). And the code is wrong at the moment anyway.

Patch is OK, confirmed with my creepy webcam that it still works. Another
fix would be to just change v4l2_open into a open call, but do as you
please.

Thanks,

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120720/5077e558/attachment.asc>


More information about the ffmpeg-devel mailing list