First chance exception on FMOD Studio Init

Hey guys,
Windows 7 64-bit, FMOD Studio version 1.1.5 32-bit with Logs

Init code:

result = mFMODStudioSystem.initialize(32, FMOD_STUDIO_INIT_LIVEUPDATE, FMOD_INIT_NORMAL, NULL);	

Initializes successfully.

However, I get first-chance exceptions:

First-chance exception at 0x7765C41F (KernelBase.dll) in XXXXXX.exe: 0x406D1388 (parameters: 0x00001000, 0x0559D801, 0x00002A64, 0x00000000).

with stack trace at:

	KernelBase.dll!7765c41f()	Unknown
 	[Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]	
>	fmodL.dll!SetThreadName(unsigned long dwThreadID, const char * szThreadName) Line 47	C++
 	fmodL.dll!FMOD_OS_Thread_Create(const char * name, unsigned int (void *) * func, void * param, FMOD_THREAD_PRIORITY priority, void * stack, int stacksize, void * * handle) Line 438	C++
 	fmodL.dll!FMOD::Thread::initThread(const char * name, void (void *) * func, void * userdata, FMOD::FMOD_THREAD_TYPE type, FMOD_THREAD_PRIORITY priority, void * stack, int stacksize, bool usesemaphore, int sleepperiod, FMOD::SystemI * system) Line 209	C++
 	fmodL.dll!FMOD::SystemI::init(int maxchannels, unsigned int flags, void * extradriverdata) Line 6081	C++
 	fmodL.dll!FMOD::System::init(int maxchannels, unsigned int flags, void * extradriverdata) Line 548	C++
 	fmodstudioL.dll!FMOD::RuntimeAPI::Manager::init(int maxchannels, unsigned int studioFlags, unsigned int flags, void * extradriverdata) Line 206	C++
 	fmodstudioL.dll!FMOD::Studio::System::initialize(int maxchannels, unsigned int studioFlags, unsigned int flags, void * extradriverdata) Line 2231	C++

That causes significant slow down during the initialization stage in our app.

Threads of concern, are
The thread ‘FMOD (WASAPI) feeder thread’ (0x28e4) has exited with code 0 (0x0).
The thread ‘FMOD mixer thread’ (0x498) has exited with code 0 (0x0).

How would we fix that?
Thanks!
Best regards,
Pavel

Exception 0x406D1388 is a special exception that the debugger catches for setting thread names, we’ve not heard of this causing a significant slowdown for users before.

Is the cause of the slowdown that your IDE is catching the exception? If this is the case you should configure the IDE to ignore it as the exception is handled internally.
Also note that we only set thread names in the logging version of FMOD, using the release libs will not execute this code.

Hey Mathew,
Thanks for a prompt response!

No, it is not. I’ve removed halt on exceptions.
It takes around 5 seconds to fully initialize one system. We have multi-system setup, so it takes significant time.

Below are logs from fmod init which took 3 seconds:

FMOD: SystemI::init                  : FMOD Studio Version: 00010105 (44257)
FMOD: SystemI::init                  : maxchannels = 100, flags = 00010000, extradriverdata = 00000000
FMOD: SystemI::close                 : 
FMOD: SystemI::close                 : Stop all sounds
FMOD: SystemI::close                 : Remove miscllaneous DSP stuff.
FMOD: SystemI::close                 : done.

FMOD: SystemI::init                  : Set up software engine
FMOD: OutputWASAPI::enumerate        : Enumerating...
FMOD: OutputWASAPI::enumerate        : Initialise COM library.
FMOD: OutputWASAPI::enumerate        : Found Driver: "Digital Audio (S/PDIF) (High Definition Audio Device)".
FMOD: OutputWASAPI::enumerate        : Found Driver: "Speakers (High Definition Audio Device)".
FMOD: OutputWASAPI::enumerate        : Found Driver: "Microphone (High Definition Audio Device)".
FMOD: OutputWASAPI::enumerate        : Done.
FMOD: OutputWASAPI::init             : Initialising...
FMOD: OutputWASAPI::init             : Forcing output channels to match Windows mix format: 2 channel(s)
FMOD: OutputWASAPI::init             : Done.
FMOD: SpeakerLevelsPool::alloc       :   8224 bytes (0FA7B0B0)
FMOD: SpeakerLevelsPool::alloc       :   8224 bytes (0FA7D0E0)
FMOD: SpeakerLevelsPool::alloc       :   8224 bytes (0FA7F110)
FMOD: SpeakerLevelsPool::alloc       :   8224 bytes (0FA81140)
FMOD: SpeakerLevelsPool::alloc       :   8224 bytes (0FA83170)
FMOD: SpeakerLevelsPool::alloc       :   8224 bytes (0FA851A0)
FMOD: SpeakerLevelsPool::alloc       :   8224 bytes (0FA871D0)
FMOD: SpeakerLevelsPool::alloc       :   8224 bytes (0FA89200)
FMOD: Thread::initThread             : Initializing FMOD (WASAPI) feeder thread.  priority 0
FMOD: Thread::initThread             : - Stacksize 0.  Stack pointer 00000000 : usesemaphore = 0 : sleeptime = 0
FMOD: Thread::callback               : * FMOD (WASAPI) feeder thread started
FMOD: Thread::initThread             : done.
FMOD: OutputWASAPI::feederUpdate     : WASAPI feeder thread set to 'Audio' characteristic
FMOD: Thread::initThread             : Initializing FMOD mixer thread.  priority 2
FMOD: Thread::initThread             : - Stacksize 49152.  Stack pointer 00000000 : usesemaphore = 1 : sleeptime = 0
FMOD: Thread::callback               : * FMOD mixer thread started
FMOD: Thread::initThread             : done.
FMOD: SystemI::init                  : Set up emulated output
FMOD: SystemI::init                  : create the channel pool
FMOD: SystemI::init                  : Set up streamer
FMOD: Thread::initThread             : Initializing FMOD stream thread.  priority 2
FMOD: Thread::initThread             : - Stacksize 49152.  Stack pointer 00000000 : usesemaphore = 0 : sleeptime = 10
FMOD: Thread::callback               : * FMOD stream thread started
FMOD: Thread::initThread             : done.
FMOD: Profile::init                  : Profiler listening on port: 9264
FMOD: SystemI::init                  : done

FMOD: Thread::callback               : * FMOD (WASAPI) feeder thread finished
FMOD: Thread::close                  : FMOD (WASAPI) feeder thread thread destroyed
FMOD: Thread::callback               : * FMOD mixer thread finished
FMOD: Thread::close                  : FMOD mixer thread thread destroyed
FMOD: OutputWASAPI::close            : Closing...
FMOD: OutputWASAPI::close            : Done.
FMOD: OutputWASAPI::enumerate        : Enumerating...
FMOD: OutputWASAPI::enumerate        : Initialise COM library.
FMOD: OutputWASAPI::enumerate        : Found Driver: "Digital Audio (S/PDIF) (High Definition Audio Device)".
FMOD: OutputWASAPI::enumerate        : Found Driver: "Speakers (High Definition Audio Device)".
FMOD: OutputWASAPI::enumerate        : Found Driver: "Microphone (High Definition Audio Device)".
FMOD: OutputWASAPI::enumerate        : Done.
FMOD: OutputWASAPI::init             : Initialising...
FMOD: OutputWASAPI::init             : Forcing output channels to match Windows mix format: 2 channel(s)
FMOD: OutputWASAPI::init             : Done.
FMOD: Thread::initThread             : Initializing FMOD (WASAPI) feeder thread.  priority 0
FMOD: Thread::initThread             : - Stacksize 0.  Stack pointer 00000000 : usesemaphore = 0 : sleeptime = 0
FMOD: Thread::callback               : * FMOD (WASAPI) feeder thread started
FMOD: Thread::initThread             : done.
FMOD: OutputWASAPI::feederUpdate     : WASAPI feeder thread set to 'Audio' characteristic
FMOD: Thread::initThread             : Initializing FMOD mixer thread.  priority 2
FMOD: Thread::initThread             : - Stacksize 49152.  Stack pointer 00000000 : usesemaphore = 1 : sleeptime = 0
FMOD: Thread::callback               : * FMOD mixer thread started
FMOD: Thread::initThread             : done.

Can you initialize all the systems at once?

You could try:

FMOD::System* pSytstems[max_systems];
// ...

// System_Create must happen on the main thread.
for(int i=0; i<max_sytems; i++)
{
  FMOD::System_Create(&pSystems[i];
}

//Initialize all FMOD Systems at once.  This uses the ppl from Microsoft, available in VS2010 and higher.
Concurrency::parallel_for(0, max_systems, [&](int system)
{
  pSystems[system]->init(...)
});

I did this on a rig with 16 FMOD System objects once and it works great.

Hope that helps!

Is it perhaps just the logging that is slowing things down? Can you try FMOD_Debug_SetLevel(FMOD_DEBUG_LEVEL_NONE) or test using the release libs?