diff options
author | Chris Robinson <[email protected]> | 2020-02-17 17:30:47 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-02-17 17:30:47 -0800 |
commit | 04e5b23286063194d81af09f959124d6634e485e (patch) | |
tree | c34edff368db286c9ee305624b48cd543757bc7c /al | |
parent | d6e49b503b3e4ec6074457ac23bc1492863dff6a (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.cpp | 20 |
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) { |