Fix random multithreaded crash that happens when setting the audio stream on a AudioStreamRandomPitch stream.

This commit is contained in:
jitspoe 2024-08-28 23:46:57 -04:00 committed by Relintai
parent e42a091db4
commit be3b2cf08f

View File

@ -232,12 +232,14 @@ AudioStreamPlaybackMicrophone::AudioStreamPlaybackMicrophone() {
////////////////////////////////
void AudioStreamRandomPitch::set_audio_stream(const Ref<AudioStream> &p_audio_stream) {
AudioServer::get_singleton()->lock();
audio_stream = p_audio_stream;
if (audio_stream.is_valid()) {
for (RBSet<AudioStreamPlaybackRandomPitch *>::Element *E = playbacks.front(); E; E = E->next()) {
E->get()->playback = audio_stream->instance_playback();
}
}
AudioServer::get_singleton()->unlock();
}
Ref<AudioStream> AudioStreamRandomPitch::get_audio_stream() const {