We have some looping sounds that we play via PostEventAtLocation. It doesn't appear that the audio engine automatically stops these events on destruction. When the event is destroyed, the streaming handle is freed, resulting in the sound data being freed from underneath the decoder thread, often resulting in a crash in the vorbis decoder. I added this function to automatically stop playback when it's about to be destroyed, and it does not appear to crash anymore.
void UAkAudioEvent::BeginDestroy()
{
if (auto* audioDevice = FAkAudioDevice::Get())
{
audioDevice->StopEventID(audioDevice->GetIDFromString(GetName()));
}
Super::BeginDestroy();
}
I'm new to wwise, but it seems correct to me. Your thoughts?