Merge pull request #8292 from RandomShaper/spatial-audio-play-on-free-2.1
Make spatial AudioServers prefer inactive voices (2.1)
This commit is contained in:
commit
6ff1436fde
|
@ -398,9 +398,18 @@ SpatialSoundServer::SourceVoiceID SpatialSoundServerSW::source_play_sample(RID p
|
||||||
int to_play = 0;
|
int to_play = 0;
|
||||||
|
|
||||||
if (p_voice == SOURCE_NEXT_VOICE) {
|
if (p_voice == SOURCE_NEXT_VOICE) {
|
||||||
to_play = source->last_voice + 1;
|
const int num_voices = source->voices.size();
|
||||||
if (to_play >= source->voices.size())
|
bool free_found = false;
|
||||||
to_play = 0;
|
for (int i = 0; i < num_voices; i++) {
|
||||||
|
const int candidate = (source->last_voice + 1 + i) % num_voices;
|
||||||
|
if (!source->voices[candidate].active && !source->voices[candidate].restart) {
|
||||||
|
free_found = true;
|
||||||
|
to_play = candidate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!free_found)
|
||||||
|
to_play = (source->last_voice + 1) % num_voices;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
to_play = p_voice;
|
to_play = p_voice;
|
||||||
|
|
|
@ -395,9 +395,18 @@ SpatialSound2DServer::SourceVoiceID SpatialSound2DServerSW::source_play_sample(R
|
||||||
int to_play = 0;
|
int to_play = 0;
|
||||||
|
|
||||||
if (p_voice == SOURCE_NEXT_VOICE) {
|
if (p_voice == SOURCE_NEXT_VOICE) {
|
||||||
to_play = source->last_voice + 1;
|
const int num_voices = source->voices.size();
|
||||||
if (to_play >= source->voices.size())
|
bool free_found = false;
|
||||||
to_play = 0;
|
for (int i = 0; i < num_voices; i++) {
|
||||||
|
const int candidate = (source->last_voice + 1 + i) % num_voices;
|
||||||
|
if (!source->voices[candidate].active && !source->voices[candidate].restart) {
|
||||||
|
free_found = true;
|
||||||
|
to_play = candidate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!free_found)
|
||||||
|
to_play = (source->last_voice + 1) % num_voices;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
to_play = p_voice;
|
to_play = p_voice;
|
||||||
|
|
Loading…
Reference in New Issue