Merge pull request #96261 from jitspoe/3.x.audio_random_pitch_crash_fix

[3.x] Fix random multithreaded crash that happens when setting the audio stream on a AudioStreamRandomPitch stream.
This commit is contained in:
lawnjelly 2024-10-16 14:07:38 +01:00 committed by GitHub
commit 147f032936
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -231,12 +231,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 (Set<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 {