I've switched from the v4l plugin to v4l2 and ran into a few problems with my saa7134 card (AverMedia DVD EZMaker). The attached patch seems to fix them:
- Set the close-on-exec flag so the video file descriptor is not inherited (and kept busy) by child processes.
- zero v4l2_buffers before queueing them. Sometimes the flags member was non-zero, and the saa7134 driver didn't like it.
- SetVideoFormat() was querying all supported TV standards from the driver, then searching them all for a match with its internal code, then just passing the original internal code to VIDIOC_S_STD. I've changed it to skip the search, since it had no effect.
The search was causing problems for me because the TV standard #defines in videodev2.h are bitmasks, and in newer kernels they've turned on more bits to allow for new substandards. If the plugin is compiled with an older kernel, the bitmasks no longer match exactly -- the new bitmask is a superset of the old one.
When you pass a bitmap to S_STD, the driver searches all its supported standards for the closest match, so it's not necessary to query them all first.
- Remove a PTRACE from the case where VIDIOC_ENUMINPUT fails, because it is expected to fail on the last iteration of the loop.
- Implement GetFrameSizeLimits().
- Tune per-frame PTRACEs down to level 8.
- Restart VIDIOC_DQBUF once if it returns with EINTR. This allows for attaching strace, debuggers, etc. without losing the video device.