From be3b2cf08faefaeecf2f721eee71fe91468139ab Mon Sep 17 00:00:00 2001 From: jitspoe Date: Wed, 28 Aug 2024 23:46:57 -0400 Subject: [PATCH] Fix random multithreaded crash that happens when setting the audio stream on a AudioStreamRandomPitch stream. --- servers/audio/audio_stream.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index a4c7d8ab1..4c07312e9 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -232,12 +232,14 @@ AudioStreamPlaybackMicrophone::AudioStreamPlaybackMicrophone() { //////////////////////////////// void AudioStreamRandomPitch::set_audio_stream(const Ref &p_audio_stream) { + AudioServer::get_singleton()->lock(); audio_stream = p_audio_stream; if (audio_stream.is_valid()) { for (RBSet::Element *E = playbacks.front(); E; E = E->next()) { E->get()->playback = audio_stream->instance_playback(); } } + AudioServer::get_singleton()->unlock(); } Ref AudioStreamRandomPitch::get_audio_stream() const {