getSoundInfo / createSound on main thread? Or no

I wrote a small wrapper around FMOD for Unity to help me load dialogue among other things.

Here’s the main function for loading dialogue using programmer instruments.

I was wondering if what I’m doing there on the main thread is OK, or if that is better relegated to the FMODNativeCallback handler I wrote.

I don’t know if CreateSound or GetSoundInfo happen synchronously or not so I wanted to figure out if those need to move to the callback handler.

Hi,

Thank you for sharing the information.

If you’re using FMOD_NONBLOCKING with System::createSound, it’s fine on the main thread since the load happens asynchronously.

Studio::System::getSoundInfo is synchronous but usually lightweight, so it’s also okay unless you’re calling it frequently.

That said, moving both to the FMOD_STUDIO_EVENT_CALLBACK_CREATE_PROGRAMMER_SOUND callback is the safest approach for performance and thread safety.

Hope this helps, let me know if you have questions.

@li_fmod Thanks so much for the explanation.

But it seems like, if you use NONBLOCKING, then it’s not possible to produce a loaded FMOD.Sound to set in FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES.

If you wait until the NONBLOCKING callback fires, then it’s already too late to set the PROGRAMMER_SOUND_PROPERTIES.sound value because it’s expected to be set synchronously in the FMOD.Studio.EVENT_CALLBACK callback.

So, it seems like you actually MUST load the Sound on the main thread (using coroutines or Tasks).

Am I missing something?