From: Kalyanov D. <kal...@gm...> - 2012-05-03 10:48:45
|
0On Thu, 2012-05-03 at 12:35 +0200, Robert Bebop wrote: > Hi all, > > Is it actually possible to callback from C with SBCL. According to the > manual it's tricky but the CFFI manual claims that it's possible on some > platforms with SBCL. > > I am a musician and enjoy messing around with audio DSP. I currently use > SBCL on a GNU/Linux platform and have written a C wrapper for the JACK > audio server. I am getting pretty good real-time performance with the > current blocking method I am using (about 10 -15 ms latency) but it > should improve if I can get the server to callback into LISP. > > I have written the FFI interface using SBCL's interface but if CFFI > works I will recode to use it. > > Another question I have is whether there could be some unpleasant side > effects of having a real-time thread callback into LISP. > > Thanks, > > Robert. It is possible to call back from C to SBCL (with either SBCL's FFI or with CFFI). The big caveat is that callback invocation has to happen on a Lisp thread (an initial Lisp thread or thread created with sb-thread:create-thread). As far as I know, many audio APIs invoke callbacks in their own threads which conflicts with the requirement of invoking callback in Lisp thread. If JACK does that, one option is to have callback written in C that notifies waiting Lisp thread (for example, via a condition variable) and marshalls the data between Lisp and JACK. |