static FMOD.RESULT FmodEventCallback(FMOD.Studio.EVENT_CALLBACK_TYPE type, IntPtr instancePtr, IntPtr parameterPtr)
{
switch (type)
{
case FMOD.Studio.EVENT_CALLBACK_TYPE.SOUND_PLAYED:
{
FMOD.Studio.EventInstance instance = new FMOD.Studio.EventInstance(instancePtr);
if (!instance.isValid())
break;
var result = instance.getPlaybackState(out var state);
if (result == FMOD.RESULT.OK && state == FMOD.Studio.PLAYBACK_STATE.PLAYING)
{
instance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
}
break;
}
}
}
In a specific situation where there were dozens of sound instances are playing, a looping music event was stopped externally, but some of the sounds would not stop no matter what. So, I tried checking in the callback and forcefully calling stop.
However, when using it this way, if stop is called twice, Unity forcefully crashes every time without any warning.
Please look into this.
The code shown above was just a simplified example.
In the actual implementation, there are additional triggers involved.
I’ve already tried safely ensuring that stop is called only once,
but the music can still be heard in some cases.
So when I try to forcefully call stop one more time,
Unity crashes immediately without fail.
Please investigate this issue.
case FMOD.Studio.EVENT_CALLBACK_TYPE.SOUND_PLAYED:
{
FMOD.Studio.EventInstance instance = new FMOD.Studio.EventInstance(instancePtr);
if (!instance.isValid() || !fmodMap.ContainsKey(instance))
break;
if (!fmodMap[instance].loop &&
!fmodMap[instance].isPlaying &&
fmodMap[instance].IsStopTriggered(instance))
{
var result = instance.getPlaybackState(out var state);
if (result == FMOD.RESULT.OK && state == FMOD.Studio.PLAYBACK_STATE.PLAYING)
{
instance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE/* AllowFadeout ? FMOD.Studio.STOP_MODE.ALLOWFADEOUT : FMOD.Studio.STOP_MODE.IMMEDIATE*/);
fmodMap[instance].SetStopTrigger(instance, false);
}
}
break;
}
The music is still audible, and when I check the state, it is
state == FMOD.Studio.PLAYBACK_STATE.PLAYING.
If I then try to call stop, Unity crashes immediately.
Why does calling stop more than once cause Unity to shut down?
Please review the internal FMOD code to ensure that repeated stop calls during playback do not crash Unity.
If a sound is still playing, the stop function should safely handle the call and exit gracefully, not crash the application.
A crash like this proves that the FMOD core is entering an invalid or unstable state.
state == FMOD.Studio.PLAYBACK_STATE.PLAYING
If there is a safer and more reliable function to forcefully stop a sound, please let me know.
I have confirmed through multiple state checks that the instance is in the SOUND_PLAYED state, yet when I call stop, Unity crashes.
Despite verifying that all status functions indicate it is clearly in the PLAYING state, calling stop still causes Unity to terminate.
If there’s a lower-level or more robust method to guarantee a sound is stopped without causing instability, I would appreciate it if you could point it out.




