aboutsummaryrefslogtreecommitdiffstats
path: root/al/source.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-02-24 21:40:54 -0800
committerChris Robinson <[email protected]>2020-02-24 21:40:54 -0800
commitfd0ed9f33fe552c7a3ba0c049c1369a31b056c47 (patch)
tree028d24ff0b90b67c0fbd4a9e338bb2d0b3d7c942 /al/source.cpp
parent52d86ad51f5425f995597df746fed7a28c8b55af (diff)
Improve searching for the next voice when playing multiple sources
Instead of searching from the beginning of the voice list for each source, just continue searching from the last source's voice.
Diffstat (limited to 'al/source.cpp')
-rw-r--r--al/source.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/al/source.cpp b/al/source.cpp
index 229a6d66..aa850e5e 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -2712,6 +2712,8 @@ START_API_FUNC
voicelist = context->getVoicesSpan();
}
+ auto voiceiter = voicelist.begin();
+ ALuint vidx{0};
VoiceChange *tail{}, *cur{};
for(ALsource *source : srchandles)
{
@@ -2777,10 +2779,10 @@ START_API_FUNC
break;
}
- /* Look for an unused voice to play this source with. */
- ALuint vidx{0};
- for(ALvoice *v : voicelist)
+ /* Find the next unused voice to play this source with. */
+ for(;voiceiter != voicelist.end();++voiceiter,++vidx)
{
+ ALvoice *v{*voiceiter};
if(v->mPlayState.load(std::memory_order_acquire) == ALvoice::Stopped
&& v->mSourceID.load(std::memory_order_relaxed) == 0u
&& v->mPendingStop.load(std::memory_order_relaxed) == false)
@@ -2788,7 +2790,6 @@ START_API_FUNC
voice = v;
break;
}
- ++vidx;
};
/* A source that's not playing or paused has any offset applied when it