Low level system usage in UE4


I’m using the latest version of FMOD Studio for UE4, and specifically the low-level functionality in C++.

I’m practically re-creating the user_created_sound.cpp example in a C++ class to test how everything works, and even though I can get a procedural sound playing like in the example, I’m running into problems cleaning up: When I call sound->release() my program crashes:

Exception thrown at 0x00007FFA0006E849 (ntdll.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

Does FMOD studio do the cleanup automatically for me? Should I not release the sound at all? Or is this a threading iussue?

Some more information:

  • The sound is initialized like in the example, including FMOD_CREATESTREAM.
  • I’m using FMOD in a subclass of UActorComponent, saving a pointer to the FMOD::Studio::System in BeginPlay(), and creating a FMOD::Sound just like in the user_created_sound.cpp example, except I’m not creating the low-level system but retrieving it from FMOD::Studio::System using getLowLevelSystem().
  • I noticed that calling sound->GetOpenState() returns FMOD_OPENSTATE_PLAYING during playback, and FMOD_OPENSTATE_READY during the destructor where I call sound->release, while I never explicitly stopped the sound!

Any help would be much appreciated! Thanks!

That all looks good. Since you are getting the low level system from the studio one, it will only remain valid for as long as the studio system remains valid.

As you may have noticed, studio has an enum since it has one system for the editor, and a second system created whenever you enter PIE. That second runtime system is the one you want, but it will get released when PIE finishes. Or in the launched game, it will be valid while the game is still going.

Unlike Studio which helpfully has every single resource type using a handle, some low level types are direct pointers to objects - so trying to release a sound after the system has been released will crash. Check the order of when you clean up the sound. I’m not sure exactly how you could intercept PIE finishing to make sure you release resources early - it may need some sort of delegate from the FMOD module to do nicely.

Another thing is that you normally create a channel to play the sound you have created, and you didn’t say whether that was stopped before you released the sound. However, that case is handled gracefully - it won’t cause a crash, instead the playing channel will force stop (and return invalid handle values from then on).

1 Like

Thanks for the reply! I’ve tried calling my cleanup code during runtime, and it didn’t crash now. This means I need to find some way to find out when exactly FMOD does its cleanup. Does FMOD Studio broadcast any events when it starts its cleanup?


I went through the FMOD code, there doesn’t seem to be an event or such, so I modified it to add my own! Cheers!