Lisp HUG Maillist Archive

Callbacks from C threads into Lisp

Hello list,

Having selected LispWorks 5 for the development of my next application, I'm 
trying to use it with the PortAudio library [1] in order to do audio I/O on 
Windows XP. This means passing into the library a function pointer to a Lisp 
callback. The callback will be called from a non-Lisp library thread at sample 
rates to handle the audio data.

I've coded up one of the sample C programs in Lisp using 
fli:define-foreign-callable "stream-callback" and fli:make-pointer :symbol-name 
"stream-callback", but when I run it as an .EXE and the callback is called, I get:

   Failed to find stack-no 578 stack 1c8fe70
   Stack dump
   [16 lines of stack data]

When I run this in the IDE there are no signs of trouble, but the callback isn't 
actually called.

I can successfully call the callback myself using fli:define-foreign-function.

I have compiled PortAudio using Visual Studio 2005.

The good Dr. Weitz reports [2] that this should work in version 5; I would be 
grateful if anyone could confirm or deny that what I'm trying to do is actually 
possible before I spend much more time banging on it. The docs don't mention 
anything about "blessing" non-Lisp threads, and I know callbacks can be a tricky 
issue for some Lisp FFI implementations.

Can anyone help this FLI newbie?

Thanks,

John :^P

[1] http://www.portaudio.org
[2] http://weitz.de/lw-callbacks/
--
John Pallister
john@synchromesh.com


Updated at: 2020-12-10 08:47 UTC