From 095c8402f7070ad1d37045e05aec5d2af188d0b1 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sat, 28 Oct 2017 17:03:48 -0500 Subject: [PATCH] Get Status First, Stop Buffer, Then CurrentPosition Re-arrange order where it should had been in the first place to have seamless audio transfer. --- src/CxbxKrnl/EmuDSoundInline.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/CxbxKrnl/EmuDSoundInline.hpp b/src/CxbxKrnl/EmuDSoundInline.hpp index 056934ff4..03b60ae87 100644 --- a/src/CxbxKrnl/EmuDSoundInline.hpp +++ b/src/CxbxKrnl/EmuDSoundInline.hpp @@ -465,7 +465,7 @@ inline void DSoundBufferReplace( DWORD PlayFlags, LPDIRECTSOUND3DBUFFER8 &pDS3DBuffer) { - DWORD refCount, dwPlayCursor, dwWriteCursor, dwStatus; + DWORD refCount, dwPlayCursor, dwStatus; LPDIRECTSOUNDBUFFER8 pDSBufferNew = nullptr; LPDIRECTSOUND3DBUFFER8 pDS3DBufferNew = nullptr; @@ -481,20 +481,20 @@ inline void DSoundBufferReplace( if (pDS3DBuffer != nullptr) { pDS3DBuffer->Release(); } - - HRESULT hRet = pDSBuffer->GetCurrentPosition(&dwPlayCursor, &dwWriteCursor); + HRESULT hRet = pDSBuffer->GetStatus(&dwStatus); if (hRet != DS_OK) { - CxbxKrnlCleanup("Unable to retrieve current position for resize reallocation!"); - } - hRet = pDSBuffer->GetStatus(&dwStatus); - - if (hRet != DS_OK) { - CxbxKrnlCleanup("Unable to retrieve current status for resize reallocation!"); + CxbxKrnlCleanup("Unable to retrieve current status for replace DS buffer!"); } pDSBuffer->Stop(); + hRet = pDSBuffer->GetCurrentPosition(&dwPlayCursor, nullptr); + + if (hRet != DS_OK) { + CxbxKrnlCleanup("Unable to retrieve current position for replace DS buffer!"); + } + // TODO: Untested if transfer buffer to new audio buffer is necessary. PVOID pLockPtr1Old, pLockPtr1New; DWORD dwLockBytes1Old, dwLockBytes1New;