Fix spatial audio playback when clip is set after the audio source was enabled
#1622
This commit is contained in:
@@ -265,6 +265,7 @@ void AudioSource::Cleanup()
|
||||
void AudioSource::OnClipChanged()
|
||||
{
|
||||
Stop();
|
||||
_clipChanged = true;
|
||||
}
|
||||
|
||||
void AudioSource::OnClipLoaded()
|
||||
@@ -318,6 +319,12 @@ void AudioSource::SetNonStreamingBuffer()
|
||||
|
||||
void AudioSource::PlayInternal()
|
||||
{
|
||||
if (_clipChanged && SourceIDs.HasItems())
|
||||
{
|
||||
// If clip was changed between source setup (OnEnable) and actual playback start then ensure to flush any runtime properties with the audio backend
|
||||
_clipChanged = false;
|
||||
AudioBackend::Source::SpatialSetupChanged(this);
|
||||
}
|
||||
AudioBackend::Source::Play(this);
|
||||
|
||||
_isActuallyPlayingSth = true;
|
||||
@@ -482,6 +489,7 @@ void AudioSource::OnEnable()
|
||||
{
|
||||
_prevPos = GetPosition();
|
||||
_velocity = Vector3::Zero;
|
||||
_clipChanged = false;
|
||||
|
||||
Audio::OnAddSource(this);
|
||||
GetScene()->Ticking.Update.AddTick<AudioSource, &AudioSource::Update>(this);
|
||||
|
||||
@@ -53,6 +53,7 @@ private:
|
||||
bool _loop;
|
||||
bool _playOnStart;
|
||||
bool _allowSpatialization;
|
||||
bool _clipChanged = false;
|
||||
|
||||
bool _isActuallyPlayingSth = false;
|
||||
bool _needToUpdateStreamingBuffers = false;
|
||||
|
||||
Reference in New Issue
Block a user