I would like to ask if Sound will be released automatically after playing. I set up a callback after playing to play another sound under certain circumstances. In the callback function, I released the previous Sound, but it will crash on iOS. In other cases, it will crash. It doesn’t seem to be possible on the platform.
The code snippet is as follows
channel->setCallback([](FMOD_CHANNELCONTROL *channelcontrol,FMOD_CHANNELCONTROL_TYPE controltype,FMOD_CHANNELCONTROL_CALLBACK_TYPE callbacktype,void *commanddata1,void *commanddata2) -> FMOD_RESULT {
if(FMOD_CHANNELCONTROL_CALLBACK_END==callbacktype)
{
FMOD::Channel *cc = (FMOD::Channel*)channelcontrol;
// The following release will crash on ios
FMOD::Sound *s = nullptr;
if(FMOD_OK==ERRCHECK(cc->getCurrentSound(&s)) && s)
{
s->release();
}
}
return FMOD_OK;
});