AFAIK, older FMOD Ex wasn’t thread-safe.
It’s very nice that we don’t have to think too much about thread-safe design with FMOD Studio anymore.
But I wonder if too many FMOD function calls in very a short time will disturb FMOD system threads (due to locks).
I mean, I have a worker thread that keeps calling FMOD_System_Update() in a loop.
That thread also calls many other FMOD functions.
Firstly, it traces every sound object created by the main thread by calling FMOD_Channel_IsPlaying().
If it returns false, the object will be removed after FMOD_Channel_RemoveDSP() is called.
Otherwise, FMOD_Channel_SetVolume() may be called to simulate fade-out, or FMOD_Channel_Stop() may be called if there’s a stop request from the main thread.
And the main thread calls FMOD_System_PlaySound() when there’s input from a user, MIDI file, etc.
I simplified things here, so there are actually more FMOD function calls in both threads.
Because too many sound objects can be created by the main thread and the worker thread keeps running with almost zero sleep time (for responsiveness), I think FMOD threads may be impacted.
Should I add a little longer sleep time to the worker thread?
(The worker thread’s priority is lower than FMOD’s.)