From 04e5b23286063194d81af09f959124d6634e485e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 17 Feb 2020 17:30:47 -0800 Subject: 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. --- al/source.cpp | 20 ++++++-------------- 1 file 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) { -- cgit v1.2.3