On Thu, Jan 15, 2009 at 10:01 AM, Luke Crook <luke@...> wrote:
> I'm trying to write a sound mixer in Lisp for lispbuilder-sdl. The low level
> sound functionality is handled by the SDL.dll library using frequent callbacks
> into Lisp to fill the audio buffer.
> I'm experiencing lock-ups in this callback function (using CFFI). If the
> callback function is empty everything works. The lock-ups seem to start in the
> traversal of the list of samples during the callback.
> At a low level, the Lisp image loads the SDL library and opens the audio
> device. The SDL library then starts a new thread to handle the audio
> processing. It is this new thread that calls back into the Lisp image.
> Is there anything special that needs to be done to 'bless' this new foreign
> thread? Could these crashes be because I am not using a multithreaded version
> of SBCL/win32?
There is no multithreaded version of SBCL on Windows yet.
Calling from a non-lisp thread into lisp is certainly not expected to
work: no way to "bless" threads like these exists currently.
One way to work around this issue would be a write a C function that
puts the buffer in a global C variable, and waits (this would be the
audio callback, that is.) Your main loop in Lisp then fills the buffer
when needed, and notifies the waiting thread.