Merge pull request #69831 from Calinou/audio-random-no-repeats-remove-warning

Remove warning when playing random no-repeat sound with only 1 sound in pool
This commit is contained in:
Rémi Verschelde 2022-12-10 10:46:24 +01:00 committed by GitHub
commit c9ea6caac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -78,13 +78,13 @@
</members>
<constants>
<constant name="PLAYBACK_RANDOM_NO_REPEATS" value="0" enum="PlaybackMode">
Pick a stream at random according to the probability weights chosen for each stream, but avoid playing the same stream twice in a row whenever possible.
Pick a stream at random according to the probability weights chosen for each stream, but avoid playing the same stream twice in a row whenever possible. If only 1 sound is present in the pool, the same sound will always play, effectively allowing repeats to occur.
</constant>
<constant name="PLAYBACK_RANDOM" value="1" enum="PlaybackMode">
Pick a stream at random according to the probability weights chosen for each stream.
Pick a stream at random according to the probability weights chosen for each stream. If only 1 sound is present in the pool, the same sound will always play.
</constant>
<constant name="PLAYBACK_SEQUENTIAL" value="2" enum="PlaybackMode">
Play streams in the order they appear in the stream pool.
Play streams in the order they appear in the stream pool. If only 1 sound is present in the pool, the same sound will always play.
</constant>
</constants>
</class>

View File

@ -555,8 +555,9 @@ Ref<AudioStreamPlayback> AudioStreamRandomizer::instance_playback_no_repeats() {
}
}
if (local_pool.is_empty()) {
// There is only one sound to choose from.
// Always play a random sound while allowing repeats (which always plays the same sound).
playback = instance_playback_random();
WARN_PRINT("Playback stream pool is too small to prevent repeats.");
return playback;
}