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
This commit is contained in:
parent
2efbc6bfb3
commit
58931c073d
3 changed files with 3 additions and 0 deletions
|
@ -196,6 +196,7 @@ Ref<AudioStream> AudioStreamPlayer2D::get_stream() const {
|
|||
}
|
||||
|
||||
void AudioStreamPlayer2D::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;
|
||||
}
|
||||
|
||||
|
|
|
@ -496,6 +496,7 @@ Ref<AudioStream> AudioStreamPlayer3D::get_stream() const {
|
|||
}
|
||||
|
||||
void AudioStreamPlayer3D::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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue