Hi,
I'm doing some tests using SDL2 (via Scheme Spheres bindings), and I'm having an issue related to multithreading. I want to generate audio procedurally, so what I need basically is access to an audio buffer that I can write on. SDL2 provides access to this buffer using a callback mechanism, which periodically invokes a provided function that is responsible for filling the buffer. This function is invoked in a separate thread of the main event loop. I implemented this callback function using c-define, but it eventually leads to a segmentation fault.
I understand that this is not possible using a single VM (based on [1]), but I have recently seen some discussion regarding multiple VMs on a single process [2]. Is this functionality available for testing? I know that for the moment it is considered alpha, but it could help for doing some preliminary tests. I intend to have the main program running on a Gambit VM, and for audio processing implement a C callback which will in turn invoke a function on a different Gambit VM (both created when the program starts, probably on a simple C initialization program). These VMs would communicate via message passing/sockets/etc.
For the moment I have the audio processing logic implemented in pure C, but I'd rather use Scheme for (almost) everything. This issue also arises in other asynchronous calls, for instance suspend/resume events on mobile platforms (Android specifically). I know that using multiple processes is an option on desktop versions, but I don't think I can create separate processes on Android.
Thank you!
Regards, Francisco
[1]: https://mercure.iro.umontreal.ca/pipermail/gambit-list/2006-June/000741.html
[2]: https://mercure.iro.umontreal.ca/pipermail/gambit-list/2014-February/007441....