[libav-devel] [PATCH 5/7] v4l2: refactor device_open

Derek Buitenhuis derek.buitenhuis at gmail.com
Thu Dec 29 19:02:34 CET 2011


On 29/12/2011 11:29 AM, Luca Barbato wrote:
> Check capabilities directly in the function, further simplify the code.
> ---
>   libavdevice/v4l2.c |   70 +++++++++++++++++++++++++--------------------------
>   1 files changed, 34 insertions(+), 36 deletions(-)

[...]

>      if (res < 0) {
> +        err = errno;
>          av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYCAP): %s\n",
> -                 strerror(errno));
> -        close(fd);
> +           strerror(err));

Nit: This doesn't look indented right.

> -    *capabilities = cap.capabilities;
> +    if (!(cap.capabilities & V4L2_CAP_STREAMING)) {
> +        av_log(ctx, AV_LOG_ERROR,
> +               "The device does not support the streaming I/O method.\n");
> +        err = AVERROR(ENOSYS);
> +    }

Shouldn't error be set to ENOSYS, not AVERROR(ENOSYS), and shouldnt
this have a goto fail; ?

> +    if ((res = mmap_init(s1)) ||
> +        (res = mmap_start(s1)) < 0) {
>          close(s->fd);
>          goto out;
>      }

I am not exactly sure how this works at a glace... as in
what res will end up as.

- Derek


More information about the libav-devel mailing list