diff options
author | Chris Robinson <[email protected]> | 2019-09-11 14:33:26 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-09-11 14:33:26 -0700 |
commit | 07e2aa3bc0c7dde66b332e400f71bfd0d9cb1c5f (patch) | |
tree | c1e63112052126556eeac599a31b7c5a2c794aa7 /al/source.cpp | |
parent | 681c78d3485357ff9fae6b98ad2c20c83c767aba (diff) |
Clean up some more implicit conversions
Diffstat (limited to 'al/source.cpp')
-rw-r--r-- | al/source.cpp | 113 |
1 files changed, 55 insertions, 58 deletions
diff --git a/al/source.cpp b/al/source.cpp index 44c46d65..d368b3f0 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -305,72 +305,69 @@ ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context) } while(refcount != device->MixCount.load(std::memory_order_relaxed)); ALdouble offset{0.0}; - if(voice) - { - const ALbufferlistitem *BufferList{Source->queue}; - const ALbuffer *BufferFmt{nullptr}; - ALboolean readFin{AL_FALSE}; - ALuint totalBufferLen{0u}; + if(!voice) return offset; - while(BufferList) - { - if(!BufferFmt) BufferFmt = BufferList->mBuffer; + const ALbufferlistitem *BufferList{Source->queue}; + const ALbuffer *BufferFmt{nullptr}; + ALboolean readFin{AL_FALSE}; + ALuint totalBufferLen{0u}; - readFin |= (BufferList == Current); - totalBufferLen += BufferList->mSampleLen; - if(!readFin) readPos += BufferList->mSampleLen; + while(BufferList) + { + if(!BufferFmt) BufferFmt = BufferList->mBuffer; - BufferList = BufferList->mNext.load(std::memory_order_relaxed); - } - assert(BufferFmt != nullptr); + readFin |= (BufferList == Current); + totalBufferLen += BufferList->mSampleLen; + if(!readFin) readPos += BufferList->mSampleLen; - if(Source->Looping) - readPos %= totalBufferLen; - else - { - /* Wrap back to 0 */ - if(readPos >= totalBufferLen) - readPos = readPosFrac = 0; - } + BufferList = BufferList->mNext.load(std::memory_order_relaxed); + } + assert(BufferFmt != nullptr); - offset = 0.0; - switch(name) - { - case AL_SEC_OFFSET: - offset = (readPos + static_cast<ALdouble>(readPosFrac)/FRACTIONONE) / BufferFmt->Frequency; - break; + if(Source->Looping) + readPos %= totalBufferLen; + else + { + /* Wrap back to 0 */ + if(readPos >= totalBufferLen) + readPos = readPosFrac = 0; + } - case AL_SAMPLE_OFFSET: - offset = readPos + static_cast<ALdouble>(readPosFrac)/FRACTIONONE; - break; + switch(name) + { + case AL_SEC_OFFSET: + offset = (readPos + static_cast<ALdouble>(readPosFrac)/FRACTIONONE) / BufferFmt->Frequency; + break; - case AL_BYTE_OFFSET: - if(BufferFmt->OriginalType == UserFmtIMA4) - { - ALsizei align = (BufferFmt->OriginalAlign-1)/2 + 4; - ALuint BlockSize = align * ChannelsFromFmt(BufferFmt->mFmtChannels); - ALuint FrameBlockSize = BufferFmt->OriginalAlign; + case AL_SAMPLE_OFFSET: + offset = readPos + static_cast<ALdouble>(readPosFrac)/FRACTIONONE; + break; - /* Round down to nearest ADPCM block */ - offset = static_cast<ALdouble>(readPos / FrameBlockSize * BlockSize); - } - else if(BufferFmt->OriginalType == UserFmtMSADPCM) - { - ALsizei align = (BufferFmt->OriginalAlign-2)/2 + 7; - ALuint BlockSize = align * ChannelsFromFmt(BufferFmt->mFmtChannels); - ALuint FrameBlockSize = BufferFmt->OriginalAlign; + case AL_BYTE_OFFSET: + if(BufferFmt->OriginalType == UserFmtIMA4) + { + ALuint FrameBlockSize{BufferFmt->OriginalAlign}; + ALuint align{(BufferFmt->OriginalAlign-1)/2 + 4}; + ALuint BlockSize{align * ChannelsFromFmt(BufferFmt->mFmtChannels)}; - /* Round down to nearest ADPCM block */ - offset = static_cast<ALdouble>(readPos / FrameBlockSize * BlockSize); - } - else - { - const ALsizei FrameSize{FrameSizeFromFmt(BufferFmt->mFmtChannels, - BufferFmt->mFmtType)}; - offset = static_cast<ALdouble>(readPos * FrameSize); - } - break; + /* Round down to nearest ADPCM block */ + offset = static_cast<ALdouble>(readPos / FrameBlockSize * BlockSize); } + else if(BufferFmt->OriginalType == UserFmtMSADPCM) + { + ALuint FrameBlockSize{BufferFmt->OriginalAlign}; + ALuint align{(FrameBlockSize-2)/2 + 7}; + ALuint BlockSize{align * ChannelsFromFmt(BufferFmt->mFmtChannels)}; + + /* Round down to nearest ADPCM block */ + offset = static_cast<ALdouble>(readPos / FrameBlockSize * BlockSize); + } + else + { + const ALuint FrameSize{FrameSizeFromFmt(BufferFmt->mFmtChannels, BufferFmt->mFmtType)}; + offset = static_cast<ALdouble>(readPos * FrameSize); + } + break; } return offset; @@ -418,13 +415,13 @@ al::optional<VoicePos> GetSampleOffset(ALsource *Source) offset = static_cast<ALuint>(Source->Offset); if(BufferFmt->OriginalType == UserFmtIMA4) { - const ALsizei align{(BufferFmt->OriginalAlign-1)/2 + 4}; + const ALuint align{(BufferFmt->OriginalAlign-1)/2 + 4}; offset /= align * ChannelsFromFmt(BufferFmt->mFmtChannels); offset *= BufferFmt->OriginalAlign; } else if(BufferFmt->OriginalType == UserFmtMSADPCM) { - const ALsizei align{(BufferFmt->OriginalAlign-2)/2 + 7}; + const ALuint align{(BufferFmt->OriginalAlign-2)/2 + 7}; offset /= align * ChannelsFromFmt(BufferFmt->mFmtChannels); offset *= BufferFmt->OriginalAlign; } |