Fix audio clips streaming to be thread-safe when audio sources play

#786
This commit is contained in:
Wojtek Figat
2022-10-29 18:57:57 +02:00
parent 6379171fa6
commit 57e812d336
4 changed files with 10 additions and 5 deletions

View File

@@ -132,7 +132,7 @@ void AudioSource::Play()
Clip->RequestStreamingUpdate();
// If we are looping and streaming also update streaming buffers
if(_loop)
if (_loop)
RequestStreamingBuffersUpdate();
}
}
@@ -372,6 +372,7 @@ void AudioSource::Update()
if (!UseStreaming() || SourceIDs.IsEmpty())
return;
auto clip = Clip.Get();
clip->Locker.Lock();
// Handle streaming buffers queue submit (ensure that clip has loaded the first chunk with audio data)
if (_needToUpdateStreamingBuffers && clip->Buffers[_streamingFirstChunk] != AUDIO_BUFFER_ID_INVALID)
@@ -441,6 +442,8 @@ void AudioSource::Update()
clip->RequestStreamingUpdate();
}
}
clip->Locker.Unlock();
}
void AudioSource::OnEnable()