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

Giorgio Vazzana mywing81 at gmail.com
Sat Jan 26 13:45:03 CET 2013


2013/1/26 Stefano Sabatini <stefasab at gmail.com>:
>> > v4l2_ioctl(s->fd, VIDIOC_S_INPUT, &input.index);
>> > ret = AVERROR(errno);
>> > if (ret < 0) {
>> > ...
>> > }
>>
>> Hmm, this way we are not checking if the ioctl fails or not (if it
>> does not then errno is undefined)... maybe you meant:
>>
>> input.index = s->channel;
>> if (v4l2_ioctl(s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
>>     ret = errno;
>>     av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMINPUT): %s\n", strerror(errno));
>>     return AVERROR(ret);
>> }
>
> yes (I assumed ioctl was setting errno = 0 in case of success)

Ok, fixed.

>> > BTW strerror() is not thread safe and we should rather use
>> > av_err2str(), but this is an unrelated issue.
>> >
>> > Note: or you can keep the current error reporting logic in order to
>> > minimize the diff (keeping the first v4l2_ioctl(ENUMINPUT) as is) and
>> > we will fix it later.
>>
>
>> I'd say let's change as little as possible to minimize the diff and
>> fix it later.
>
> +1
>
>> > Also: given that you're doing ENUMINPUT and S_INPUT in
>> > v4l2_read_header(), isn't this ioclt(ENUMINPUT) redundant here?
>>
>> Because we need input.std: if it is 0 then the device does not support
>> any standard. We can save that value inside the struct video_data if
>> you agree, and call ioclt(ENUMINPUT) only once.
>
> Whatever you think it's simpler.

New patch attached.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-v4l2-Select-input-immediately-after-opening-the-devi.patch
Type: application/octet-stream
Size: 3515 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130126/d4b51126/attachment.obj>


More information about the ffmpeg-devel mailing list