[asterisk-dev] Simple chan_jack.so where jack_read and jack_write are never called...

Russell Bryant russell at digium.com
Wed Oct 7 09:55:00 CDT 2009

Fabien COMTE wrote:
> I try to write a very simple chan_jack.so (no resample, jack must run at
> 8000 Hz...)

Before you spend too much time on this, I would suggest looking at
chan_console, which uses libportaudio.  IIRC, libportaudio supports JACK.

> The problem is that my functions jack_read and jack_write are never called
> during a call. Does anyone have an idea ?
> I probably get the same problem like in post "Ways of invoking channel read
> function". I don't know how to set readdev fd...

Your read function will get called based on poll() on channel fds saying
that there is input available.  As discussed in the thread that you
replied to, you can use ast_queue_frame(), which will use the alert pipe
on the channel to wake up the channel thread and process the frame.  If
you use this method, read() will not actually get used.

Writing a jack channel driver is not entirely straight forward because
Asterisk audio processing is read()/write() driven, while JACK audio
processing is callback driven.  You would need to do the same type of
thing that app_jack does to deal with translating between the two.

In app_jack, ringbuffers are used to buffer audio between the JACK
callbacks and the read/write calls needed for the Asterisk channel.
Specifically, I used the lock free ringbuffer API that is provided by JACK.

With all of that said, if you want to write a JACK channel driver for
your own use, there is certainly nothing wrong with that, and I don't
mind providing pointers.  However, for code going back into Asterisk, I
would be much more interested in seeing what we could do to improve
chan_console to do whatever you need it to do, instead of having yet
another console channel driver.


Russell Bryant
Digium, Inc. | Engineering Manager, Open Source Software
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org

More information about the asterisk-dev mailing list