[asterisk-dev] how to generate periodic wakeup signals for a channel driver ?

Russell Bryant russell at digium.com
Mon Sep 17 15:48:43 CDT 2007


Luigi Rizzo wrote:
> gspca probably relies on some kind of mmap+ioctl feature for
> synchronization, because mmap is the favourite Video4Linux API.

In that case, you could have the background thread using the synchronization
method they provide and calling ast_queue_frame() to pass the data to the
channel when appropriate.  You can do that instead of using an fd to signal
another thread to call the channel's read() callback.

> As for the x11 grabber, it is a software thing that fetches parts
> of your X display, so in principle you could select() on the file
> descriptor connecting to your X server, but there is so much
> traffic there that in practice i doubt it would be efficient
> or compact.

In this case, I can't think of any better idea than your original idea of a
background thread that wakes up periodically to check for new data.  I'm not
sure if using a scheduler context from sched.h is really necessary.  I would
probably use a pthread_cond_t and the ast_cond_timedwait() function to sleep
with the option of waking it up early from another thread.

-- 
Russell Bryant
Software Engineer
Digium, Inc.



More information about the asterisk-dev mailing list