[Audio] Prevent crash in interactive playback

This commit is contained in:
A Thousand Ships 2024-04-10 12:28:02 +02:00
parent 0918fd2a21
commit be652f160d
No known key found for this signature in database
GPG Key ID: 2033189A662F8BD7
2 changed files with 5 additions and 3 deletions

View File

@ -976,6 +976,8 @@ void AudioStreamPlaybackInteractive::switch_to_clip_by_name(const StringName &p_
return;
}
ERR_FAIL_COND_MSG(stream.is_null(), "Attempted to switch while not playing back any stream.");
for (int i = 0; i < stream->get_clip_count(); i++) {
if (stream->get_clip_name(i) == p_name) {
switch_request = i;

View File

@ -42,11 +42,11 @@
void initialize_interactive_music_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
GDREGISTER_CLASS(AudioStreamPlaylist);
GDREGISTER_VIRTUAL_CLASS(AudioStreamPlaybackPlaylist);
GDREGISTER_ABSTRACT_CLASS(AudioStreamPlaybackPlaylist);
GDREGISTER_CLASS(AudioStreamInteractive);
GDREGISTER_VIRTUAL_CLASS(AudioStreamPlaybackInteractive);
GDREGISTER_ABSTRACT_CLASS(AudioStreamPlaybackInteractive);
GDREGISTER_CLASS(AudioStreamSynchronized);
GDREGISTER_VIRTUAL_CLASS(AudioStreamPlaybackSynchronized);
GDREGISTER_ABSTRACT_CLASS(AudioStreamPlaybackSynchronized);
}
#ifdef TOOLS_ENABLED
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {