Coordinating concurrent users of v4l2 devices

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



Hello all,

In summary: I'm looking for a way to (at least) query if a v4l2 device
is currently in use, so that background data harvesting applications
can avoid to inadvertently change the channel during a video recording
or while the user is watching TV.


Long version: I'm the author of "nxtvepg", which is a decoder for an
EPG service which is transmitted in teletext packages inside the VBI
(in some European countries only).  These EPG services are provided by
several different networks, hence the decoder perdiodically cycles
through a number of TV frequencies.  The application is usually started
as a daemon by the boot rc scripts and running permanently in the
background.

Up to v4l1 the decoder simply was triggering all channel changes via
/dev/video (i.e. opened the video device only for the channel change
and closed it immediately after).  When a TV application was running,
the device open failed automatically and the app could patiently wait
until /dev/video was free again.  Interference with other /dev/vbi
users was not a concern, since there could be only one.

However with v4l2 this solution does not work anymore, since the video
device can be opened, and the channel changed, even when a TV app is
running.  Hence the user has to manually put the decoder into "passive"
mode when he/she starts watching TV, which is annoying.  Even worse, if
the user should schedule a TV recording while he's away and forget to
kill the nxtvepg daemon before, he'll be very unhappy afterwards.

Is it possible with the current v4l2 API to query the kind of device
users or at least the number of opens?  I suspect it's currently not
possible.


The ideal solution to this problem I would imagine is to introduce
priority levels associated with each open.  The highest priority would
be used for recordings, 2nd for interactive applications (TV viewers,
including external control apps, but also teletext decoders with
channel-change capability), and the lowest for background applications.
Default for apps which don't set their prio could be interactive
(I figure most fall into that category.)

An application could use an VIDIOC_S_USER_PRIO ioctl to set it's priority
immediately after the device open.  Then the driver could automatically
disallow any "set" operations with EPERM as long as there are users with
higher priority. Apps with priority equal to the max can change settings,
but there should be a way for an app to stay informed about such changes
(i.e. a TV app could update it's window title with the new channel name).
Additionally there could be an enumerate function that allows to query
for all device users, so that a human user can be informed why access
was denied, but also to allow additional coordination between apps with
the same priority level (outside of the scope of v4l)


But that's just an idea.  Of course it would be preferrable if the same
could be done already with the current API.  Any suggestions?
Thanks in advance.

bye
-tom





[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