[MPlayer-dev-eng] demux_tv_fill_buffer() + V4L2 webcam removal detection?

Németh Márton nm127 at freemail.hu
Tue Jul 5 22:30:53 CEST 2011


I'm faceing with the problem that mencoder seems to not detect when a V4L2 webcam
is removed during encoding.

I digged a little bit in the source code (SVN r33823) and found that the function
demux_tv_fill_buffer() from stream/tv.c calls the grab_video_frame() to fetch
a new video frame.

In case of V4L2 the grab_video_frame() can be found in stream/tvi_v4l2.c file. That
function will return zero if there was no frame available.

The frames are captured from the V4L2 video device in the thread implemented
in video_grabber() in stream/tvi_v4l2.c . This thread exits when there was some
kind of unrecoverable error, for example when the VIDIOC_QBUF ioctl() returns
-ENODEV. This signals that the device is no longer there. If this is for example
an USB webcam then this is what happens when the device is unplugged.

I have the following questions:
 - How will the stream/tvi_v4l2.c:grab_video_frame() function recognise that the
   video_grabber thread is stopped?
 - How will the stream/tv.c:demux_tv_fill_buffer() recognise that the video input
   stream is ended because the webcam was removed? According to the comment at
   demux_tv_fill_buffer() heading in this case the function shall return 0.


	Márton Németh

More information about the MPlayer-dev-eng mailing list