I made a custom actor to play sounds and then get destroyed when it’s finished.
I add SoundActor::DestroyAfterFinished() to AudioComponent->OnAudioFinished
But it doesn’t ALWAYS get called. Some actors just stay forever.
I am doing the exact same thing with particles without any problems, so my guess is that audio components don’t start playing when there are too many active sources already. The question would be: how can I tell. AudioComponent::Play() doesn’t return a bool.
I tried using AudioComponent::IsPlaying() to verify if it actually started playing right after initialising it, but without success (always true, it seems).
edit:
After reading the source a little, I found that sounds can really fail to start. There’s a function UAudioComponent::PlaybackCompleted(bool bFailedToStart). It also shows that the finished-event doesn’t get broadcast in that case. What I don’t know is WHEN this function gets called (after play() ? Or after one or more ticks?) and what I’m supposed to do in order to find out wether it failed or not…