aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-02-17 17:30:47 -0800
committerChris Robinson <[email protected]>2020-02-17 17:30:47 -0800
commit04e5b23286063194d81af09f959124d6634e485e (patch)
treec34edff368db286c9ee305624b48cd543757bc7c /al
parentd6e49b503b3e4ec6074457ac23bc1492863dff6a (diff)
Don't bother looping the calculated source offset
The offset shouldn't be in a non-wrapped state when playing, and when not playing it's always 0 anyway.
Diffstat (limited to 'al')
-rw-r--r--al/source.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/al/source.cpp b/al/source.cpp
index 047551bf..07a9d9e0 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -309,29 +309,21 @@ ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context)
const ALbufferlistitem *BufferList{Source->queue};
const ALbuffer *BufferFmt{nullptr};
- ALuint totalBufferLen{0u};
- bool readFin{false};
-
while(BufferList)
{
if(!BufferFmt) BufferFmt = BufferList->mBuffer;
+ if(BufferList == Current) break;
- readFin |= (BufferList == Current);
- totalBufferLen += BufferList->mSampleLen;
- if(!readFin) readPos += BufferList->mSampleLen;
+ readPos += BufferList->mSampleLen;
BufferList = BufferList->mNext.load(std::memory_order_relaxed);
}
- assert(BufferFmt != nullptr);
-
- if(Source->Looping)
- readPos %= totalBufferLen;
- else
+ while(BufferList && !BufferFmt)
{
- /* Wrap back to 0 */
- if(readPos >= totalBufferLen)
- readPos = readPosFrac = 0;
+ BufferFmt = BufferList->mBuffer;
+ BufferList = BufferList->mNext.load(std::memory_order_relaxed);
}
+ assert(BufferFmt != nullptr);
switch(name)
{