|Subject:||Re: [fluid-dev] Bug when calling SDL functions from sequencer callback|
|Date:||Mon, 19 Nov 2018 14:34:44 +0800|
|I’m guessing that you’re hooking up Synth::seq_callback via fluid_sequencer_register_client or similar.|
It seems like a bad idea to be attempting GUI operations from such a callback, as GUI APIs generally expect to be driven by a single thread. A quick search suggests that SDL’s convention is that only the thread which creates the main windows is allowed to access it.
Probably fluidsynth has its own separate thread to drive the midi sequencer resulting in this rule being violated, which could have many unpredictable consequences.
I don’t know if there are other conventions governing what sort of functions are “allowed” to be called from a fluidsynth callback, but my instinct here would be that you shouldn’t be doing anything that might block for i/o or to allocate memory or any other operation which might hold up the midi thread.
The usual workaround is to have the callback post an event to be handled by some other thread. The details of how to accomplish that vary from platform to platform; for windows PostMessage is a fairly simple way to get an event to the thread responsible for the GUI. SDL might provide something more portable?
On 19 Nov 2018, at 13:32, Paul Cohn <address@hidden> wrote:
|[Prev in Thread]||Current Thread||[Next in Thread]|