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

Stefano Sabatini stefasab at gmail.com
Fri Jul 20 12:01:53 CEST 2012


On date Friday 2012-07-20 10:58:41 +0200, Nicolas George encoded:
> 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

Looks correct according to my interpretation of:
http://linuxtv.org/downloads/v4l-dvb-apis/libv4l.html

|int v4l2_fd_open(int fd, int v4l2_flags) - opens an already opened fd
|for further use through v4l2lib and possibly modify libv4l2's default
|behavior through the v4l2_flags argument.

Since the fd was opened through v4l2_open() then there is no point
into using this function.

Thanks.
-- 
FFmpeg = Fundamental and Fundamentalist Mastodontic Problematic Encoding/decoding God


More information about the ffmpeg-devel mailing list