diff options
author | Chris Robinson <[email protected]> | 2020-10-03 16:17:34 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-10-03 16:17:34 -0700 |
commit | e0097c18b82d5da37248c4823fde48b6e0002cdd (patch) | |
tree | c26889d51c678ba0b170989f3264989e7e42fc4e /alc | |
parent | b5eccf424b9f9ed0e6b927d75e646bdff6d00c98 (diff) |
Simplify some DSound capture math
Diffstat (limited to 'alc')
-rw-r--r-- | alc/backends/dsound.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp index 1c0b371c..683b3b7b 100644 --- a/alc/backends/dsound.cpp +++ b/alc/backends/dsound.cpp @@ -746,9 +746,9 @@ ALCuint DSoundCapture::availableSamples() if(!mDevice->Connected.load(std::memory_order_acquire)) return static_cast<ALCuint>(mRing->readSpace()); - ALuint FrameSize{mDevice->frameSizeFromFmt()}; - DWORD BufferBytes{mBufferBytes}; - DWORD LastCursor{mCursor}; + const ALuint FrameSize{mDevice->frameSizeFromFmt()}; + const DWORD BufferBytes{mBufferBytes}; + const DWORD LastCursor{mCursor}; DWORD ReadCursor{}; void *ReadPtr1{}, *ReadPtr2{}; @@ -756,7 +756,7 @@ ALCuint DSoundCapture::availableSamples() HRESULT hr{mDSCbuffer->GetCurrentPosition(nullptr, &ReadCursor)}; if(SUCCEEDED(hr)) { - DWORD NumBytes{(ReadCursor-LastCursor + BufferBytes) % BufferBytes}; + const DWORD NumBytes{(BufferBytes+ReadCursor-LastCursor) % BufferBytes}; if(!NumBytes) return static_cast<ALCubyte>(mRing->readSpace()); hr = mDSCbuffer->Lock(LastCursor, NumBytes, &ReadPtr1, &ReadCnt1, &ReadPtr2, &ReadCnt2, 0); } @@ -766,7 +766,7 @@ ALCuint DSoundCapture::availableSamples() if(ReadPtr2 != nullptr && ReadCnt2 > 0) mRing->write(ReadPtr2, ReadCnt2/FrameSize); hr = mDSCbuffer->Unlock(ReadPtr1, ReadCnt1, ReadPtr2, ReadCnt2); - mCursor = (LastCursor+ReadCnt1+ReadCnt2) % BufferBytes; + mCursor = ReadCursor; } if(FAILED(hr)) |