From a4c4719a19e8d3ec8a713bd648c069a0283299fb Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 11 Oct 2020 11:40:37 +0200 Subject: [PATCH] IDirectSoundBuffer_SetBufferData: Stop the sound before waiting for it to end --- src/core/hle/DSOUND/DirectSound/DirectSoundBuffer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/hle/DSOUND/DirectSound/DirectSoundBuffer.cpp b/src/core/hle/DSOUND/DirectSound/DirectSoundBuffer.cpp index f8a375c77..2bad568d3 100644 --- a/src/core/hle/DSOUND/DirectSound/DirectSoundBuffer.cpp +++ b/src/core/hle/DSOUND/DirectSound/DirectSoundBuffer.cpp @@ -756,9 +756,11 @@ xbox::hresult_xt WINAPI xbox::EMUPATCH(IDirectSoundBuffer_SetBufferData) HRESULT hRet = DSERR_OUTOFMEMORY; DWORD dwStatus; - // force wait until buffer is stop playing. + // stop and force wait until the buffer has stopped playing. + pThis->EmuDirectSoundBuffer8->Stop(); pThis->EmuDirectSoundBuffer8->GetStatus(&dwStatus); - while ((dwStatus & DSBSTATUS_PLAYING) > 0) { + while ((dwStatus & DSBSTATUS_PLAYING) != 0) { + // TODO: Add a timeout, like on xbox SwitchToThread(); pThis->EmuDirectSoundBuffer8->GetStatus(&dwStatus); }