Fix audio clips streaming to be thread-safe when audio sources play
#786
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user