Merge pull request #1984 from CookiePLMonster/fix-setbufferdata-deadlock

IDirectSoundBuffer_SetBufferData: Stop the sound before waiting for finish
This commit is contained in:
RadWolfie 2020-10-11 06:12:51 -05:00 committed by GitHub
commit 1887f3ac29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -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);
}