I was just wondering what happens when you call freeEventData on a set of wave data that is still playing (and what best way to handle this is error condition)?
I was tracking an issue with ‘invalid handle’ error, when attempting to stop a sound. As it happens the sound data was unloaded with freeEventData, just before I called stop on the event. I thought maybe not having called EventSystem::update() meant the stop notification wasn’t coming through on the sound event, but it seems even if I call this, the sound gets no notification (from Event::setCallback) to indicate its handle has been invalidated..
Is this behaviour intended? I foresee many cases where a programmer may accidentally hold onto a sound, where the data is then unloaded – and in most cases will be confused at first as to the problem. Of course the answer is make sure all sounds are stopped before unloading them, but that doesn’t help catch/track down bugs – is there a way to test if sound data is in use before calling freeEventData? Anything that can log an error on freeEventData (complaining some data is still in use) would be great.
- Jade_Lee asked 11 years ago
Thanks Brett – so if I create an event, then hook up it’s callback
Then call freeEventData, with an extra update() thrown in (just in case required to post callback notifications) –
m_eventGroup->freeEventData(NULL); // FMOD::EventGroup
m_eventSystem->update(); // FMOD::EventSystem
I don’t seem to be getting any ‘SoundEventCallback’ notifications on the event playing (that is part of the EventGroup we unloaded) – should these be coming through? In this situation it’s a streaming sample (haven’t tested if there is a difference for instantaneous sounds).
- Jade_Lee answered 11 years ago
Please login first to submit.