(v4l2/driver) capture lock and buffer handling?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi all,

another question about v4l2/drivers. v4l2 is supposed to allow multiple
apps to open the same device, which is a good thing(tm). The docs
(either the ones at thedirks.org/v4l2 or Gerd's docs - I forgot) say
that you should lock the capturing to one open() session per device
(logical - you can only capture once, normally).

Now the problem is, when should I start and end this locked capturing
part of the session, and what about the buffers per open() session? The
BTTV (0.8) driver seems to have buffers per open() session (rather than
one set of buffers per device) - so the buffers are in the bttv_fh
struct and not in the bttv struct. These buffers are allocated during
VIDIOC_REQBUFS time, however, there's no call to end the buffer use - so
when should I free this memory in the driver? during munmap()
(videobuf.c seems to free something at munmap time)?

Then, when should I place the lock on the capturing process so other
open() session on the same device can't interfere with this capturing
process? During STREAM_ON? Or when the first buffer is queued? (And
connected, when should I release this lock? When the last buffer is
synced on? Or during STREAM_OFF?). And if it's during
STREAM_ON/STREAM_OFF, how would I deal with this in v4l1, which doesn't
have the STREAM_ON/STREAM_OFF ioctl calls?

The problem is that the driver currently simply creates the buffers on
device open() time and frees them at close(). The first one to close()
the driver kills the buffers, so closing xawtv while capturing would
probably crash the machine. *yikes*. I'm looking for a somewhat more
acceptable solution. ;-).

Thanks,

Ronald

-- 
-   .-.
-   /V\    | Ronald Bultje <rbultje@xxxxxxxxxxxxxxxxxxx>
-  // \\   | Running: Linux 2.4.18-XFS and OpenBSD 3.0
- /(   )\  | http://ronald.bitfreak.net/
-  ^^-^^





[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux