I need to free the data of a specific event after this event has stopped playing. I’m using freeEventData().
Ideally, I would set up a callback (FMOD_EVENT_CALLBACK) and free the event there.
But according to the manual, I shouldn’t call freeEventData() from within a callback.
Is there an other recommended way to do this? Other than manually polling the state of the event with getState?
- satowai asked 6 years ago
It’s not super difficult to set up some autoclean up code that will free events outside the callback. Here is an example:
[b:3poihtpv]inside some class where the EventSystem* is [/b:3poihtpv]
[code:3poihtpv]typedef std::list<FMOD::Event*> EventList;
[b:3poihtpv]inside main loop[/b:3poihtpv]
[code:3poihtpv]for(EventList::iterator itr = finishedEvents.begin(); itr != finishedEvents.end(); ++itr)
FMOD_RESULT result = FMOD_OK;
FMOD::Event* current = itr;
FMOD::EventGroup parentGroup = NULL;
ERRCHECK( result = event->getParentGroup(&parentGroup) );
ERRCHECK( result = parentGroup->freeEventData(event, false) );
- Guest answered 6 years ago
Is there a good way to do this with polling? My code maintains a list of all active events (not just the ones that are finished) and I’m already updating the list once per frame, so it would be cleaner and easier to check for finished events during this update than it would be to use the callbacks. I have found that if an event’s FMOD_EVENT_STATE is exactly equal to FMOD_EVENT_STATE_READY (i.e. FMOD_EVENT_STATE_READY is the only true flag) then the event is probably done. But it seems like this this isn’t an intended interpretation of the state flags, and hence I ask if there isn’t a more reliable way to check for finished events via polling.
- cronec answered 6 years ago
Please login first to submit.