diff options
author | aaronp64 <aaronp.code@gmail.com> | 2024-04-18 11:28:57 -0400 |
---|---|---|
committer | aaronp64 <aaronp.code@gmail.com> | 2024-04-18 11:28:57 -0400 |
commit | 58931c073dd26b52dc2d5182166a145cb221ad20 (patch) | |
tree | e48342323041b78c64995043bd563aaee0870a5d /scene/audio | |
parent | 2efbc6bfb3b4f49a6bc75b3d367cfe81eeddbf3a (diff) | |
download | redot-engine-58931c073dd26b52dc2d5182166a145cb221ad20.tar.gz |
Check for NaN in set_volume_db functions
Added check in AudioStreamPlayer, AudioStreamPlayer2D, and AudioStreamPlayer3D set_volume_db functions to prevent setting volume to NaN, and give an error. Using NaN for volume and playing the AudioStreamPlayer could prevent all audio from playing, even from other AudioStreamPlayers.
Fixes #88133
Diffstat (limited to 'scene/audio')
-rw-r--r-- | scene/audio/audio_stream_player.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index dadcfab69f..0c2bd64e84 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -59,6 +59,7 @@ Ref<AudioStream> AudioStreamPlayer::get_stream() const { } void AudioStreamPlayer::set_volume_db(float p_volume) { + ERR_FAIL_COND_MSG(Math::is_nan(p_volume), "Volume can't be set to NaN."); internal->volume_db = p_volume; Vector<AudioFrame> volume_vector = _get_volume_vector(); |