Hello!
What is the proper way to manage the lifecycle of audio events? I am integrating FMOD Studio with Cocos2D-x, and I get the following failed assertion:
When I try to clean up resources used by the event instance and audio bank.
void stopAudio(){
eventInstance.stop(); //error here
eventInstance.release(); // -- or here, when previous line is commented
bank.unload(); // -- or here
}
Initialization happens as follows, given I have an initialized FMOD System:
void startAudio(const char *bankPath, const char *eventGUID, FMOD::Studio::Bank* bank,FMOD::Studio::EventInstance* eventInstance){
//Load Bank from bankPath
pSystem.loadBank(bankPath, bank);
//GUID->ID
FMOD::Studio::ID eventID = {0};
FMOD::Studio::parseID(eventGUID, &eventID);
//Load Event Description
FMOD::Studio::EventDescription eventDescription;
pSystem.getEvent(&eventID, FMOD_STUDIO_LOAD_BEGIN_NOW, &eventDescription);
//Load Event Instance
eventDescription.createInstance(eventInstance);
//Start Playing
eventInstance.start();
/* I set some values of parameters and I succesfully hear sounds!! */
}
(start and stop audio are used in âonEnterâ and âonExitâ of a layer-node on screen)