summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-12-10 10:46:24 +0100
committerGitHub <noreply@github.com>2022-12-10 10:46:24 +0100
commitc9ea6caac827ea00f972989318a4e92caa149291 (patch)
tree33436aab8c12dba303de503f69a6cf4dad529bd3
parent879499a0aa2ade91a03bf6fb6c8904ee636f6a9e (diff)
parent35d788cff5074475c210c8f434e4671089ae4d2f (diff)
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
-rw-r--r--doc/classes/AudioStreamRandomizer.xml6
-rw-r--r--servers/audio/audio_stream.cpp3
2 files changed, 5 insertions, 4 deletions
diff --git a/doc/classes/AudioStreamRandomizer.xml b/doc/classes/AudioStreamRandomizer.xml
index 5490770b7d..9b58d78af5 100644
--- a/doc/classes/AudioStreamRandomizer.xml
+++ b/doc/classes/AudioStreamRandomizer.xml
@@ -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>
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp
index 4b68515e18..113e728106 100644
--- a/servers/audio/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -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;
}