Audio Components not always Playing?

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…

Can I get some help here? This is really flawed, if you ask me…

Shouldn’t there be

  • a way to get a finished event despite failing to start the playback
  • OR a return value (bool) for the Play() function that tells you if it failed

???

Looking at the code it looks a bit flawed indeed; an easy workaround to check if a sound is active would be to call FAudioDevice::FindActiveSound() for the requested audio component.

I solved this by deriving from AudioComponent, enable bAutoDestroy on it and override OnComponentDestroyed (or something like that…), so it tells the owning actor about it’s destruction. Auto-Destruction works fine with both finished and “failed-to-start” Play()-calls, so it’s an accaptable solution. Though I’d rather not have to derive a new component type for something as simple as this.