[FFmpeg-devel] [PATCH] v4l2: Select input immediately after opening the device

Giorgio Vazzana mywing81 at gmail.com
Fri Jan 25 13:12:51 CET 2013


2013/1/25 Stefano Sabatini <stefasab at gmail.com>:
> On date Thursday 2013-01-24 16:58:59 +0100, Giorgio Vazzana encoded:
>> -    /* set tv video input */
>> +    /* enum tv video input */
>>      input.index = s->channel;
>>      if (v4l2_ioctl(s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
>>          av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl enum input failed:\n");
>>          return AVERROR(EIO);
>>      }
>
> maybe use:
>         av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMINPUT): %s\n", strerror(errno)
>
> like in the other places for consistency. Also you should return
> AVERROR(errno) in order to provide more info to the user.

Fixed.

>> @@ -801,6 +793,21 @@ static int v4l2_read_header(AVFormatContext *s1)
>>      if (s->fd < 0)
>>          return s->fd;
>>
>> +    /* set tv video input */
>> +    av_log(s1, AV_LOG_DEBUG, "Selecting V4L2 input_id: %d\n", s->channel);
>> +    if (v4l2_ioctl(s->fd, VIDIOC_S_INPUT, &s->channel) < 0) {
>> +        av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set input failed\n");
>> +        return AVERROR(EIO);
>> +    }
>
> same: unrelated but returning AVERROR(errno) is favored

Changed.

>> +    input.index = s->channel;
>> +    if (v4l2_ioctl(s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
>> +        av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl enum input failed\n");
>> +        return AVERROR(EIO);
>> +    }
>
> ditto about return error code

Ok, done.

>> +    av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set input_id: %d, input: %s\n",
>> +            s->channel, input.name);
>> +
>
> Nit: all this "V4L2 driver" stuff is redundant and a bit annoying,
> especially in DEBUG log messages, I suggest something along the line:
> input_channel:%d input_name:%s

Changed. There are other places where "V4L2 driver" is used in the log
messages and/or AVERROR(errno) is not returned, I suggest we fix them
all later with another patch.

Thanks for the review, new patch attached.

Giorgio Vazzana
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-v4l2-Select-input-immediately-after-opening-the-devi.patch
Type: application/octet-stream
Size: 2854 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130125/0fe27eab/attachment.obj>


More information about the ffmpeg-devel mailing list