From e0097c18b82d5da37248c4823fde48b6e0002cdd Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 3 Oct 2020 16:17:34 -0700 Subject: Simplify some DSound capture math --- alc/backends/dsound.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'alc/backends/dsound.cpp') 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(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(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)) -- cgit v1.2.3