Bro_Audio
Bro_Audio copied to clipboard
[Bug] Using IAudioPlayer.SetScheduledStartTime() or IAudioPlayer.SetDelay() doesn't fully setup the player before playing
When using IAudioPlayer.SetScheduledStartTime() or IAudioPlayer.SetDelay() you're not guaranteed to fully setup or trigger everything that a normal play would, since AudioSource.PlayScheduled() runs on the DSP thread and can start playing music before the frame's Update cycle runs.
Missing things:
- Trigger any MusicPlayer decorators
- Assign an
outputAudioMixerGroup(AudioTrack) - Trigger
SetPlayPosition()for trimmed audio - Trigger OnStart() callbacks, or an initial OnUpdate()
- Whatever else happens AFTER
yield return WaitForScheduledStartTime();inPlayControl()
This is most apparent when playing a very short sound clip set to trigger between frames, with all output mixer groups muted. The sound can still be heard and has a null output mixer group.
Workaround for now:
BroAudio.Play(sound).OnStart(p => p.SetScheduledStartTime(dspTime))
Since this causes all the normal setup to be done before triggering PlayScheduled.