diff --git a/src/core/hle/DSOUND/DirectSound/DSStream_PacketManager.cpp b/src/core/hle/DSOUND/DirectSound/DSStream_PacketManager.cpp index 92ba741b9..ad065d6c0 100644 --- a/src/core/hle/DSOUND/DirectSound/DSStream_PacketManager.cpp +++ b/src/core/hle/DSOUND/DirectSound/DSStream_PacketManager.cpp @@ -299,10 +299,21 @@ bool DSStream_Packet_Process( return 1; } +void DSStream_Packet_FlushEx_Reset( + XTL::X_CDirectSoundStream* pThis + ) +{ + // Remove flags only (This is the only place it will remove other than FlushEx perform set/remove the flags.) + pThis->EmuFlags &= ~(DSE_FLAG_FLUSH_ASYNC | DSE_FLAG_ENVELOPE | DSE_FLAG_ENVELOPE2); + pThis->Xb_rtFlushEx = 0LL; +} + bool DSStream_Packet_Flush( XTL::X_CDirectSoundStream* pThis ) { + DSStream_Packet_FlushEx_Reset(pThis); + // If host's audio is still playing then return busy-state until buffer has stop playing. DWORD dwStatus; pThis->EmuDirectSoundBuffer8->GetStatus(&dwStatus); diff --git a/src/core/hle/DSOUND/DirectSound/DSStream_PacketManager.hpp b/src/core/hle/DSOUND/DirectSound/DSStream_PacketManager.hpp index 9f8cfd7d7..821e218e1 100644 --- a/src/core/hle/DSOUND/DirectSound/DSStream_PacketManager.hpp +++ b/src/core/hle/DSOUND/DirectSound/DSStream_PacketManager.hpp @@ -39,4 +39,6 @@ extern void DSStream_Packet_Clear( extern bool DSStream_Packet_Process(XTL::X_CDirectSoundStream* pThis); +extern void DSStream_Packet_FlushEx_Reset(XTL::X_CDirectSoundStream* pThis); + extern bool DSStream_Packet_Flush(XTL::X_CDirectSoundStream* pThis); diff --git a/src/core/hle/DSOUND/DirectSound/DirectSound.cpp b/src/core/hle/DSOUND/DirectSound/DirectSound.cpp index d6acc3c99..337397df1 100644 --- a/src/core/hle/DSOUND/DirectSound/DirectSound.cpp +++ b/src/core/hle/DSOUND/DirectSound/DirectSound.cpp @@ -390,15 +390,9 @@ static void dsound_thread_worker(LPVOID nullPtr) { DSoundMutexGuardLock; - vector_ds_stream::iterator ppDSStream = g_pDSoundStreamCache.begin(); - for (; ppDSStream != g_pDSoundStreamCache.end(); ppDSStream++) { - if ((*ppDSStream)->Host_BufferPacketArray.size() == 0) { - continue; - } - if (((*ppDSStream)->EmuFlags & DSE_FLAG_FLUSH_ASYNC) > 0 && (*ppDSStream)->Xb_rtFlushEx == 0LL) { - DSStream_Packet_Process((*ppDSStream)); - } - } + xboxkrnl::LARGE_INTEGER getTime; + xboxkrnl::KeQuerySystemTime(&getTime); + DirectSoundDoWork_Stream(getTime); } } } diff --git a/src/core/hle/DSOUND/DirectSound/DirectSoundStream.cpp b/src/core/hle/DSOUND/DirectSound/DirectSoundStream.cpp index 6b999300f..4fb06bce7 100644 --- a/src/core/hle/DSOUND/DirectSound/DirectSoundStream.cpp +++ b/src/core/hle/DSOUND/DirectSound/DirectSoundStream.cpp @@ -360,10 +360,6 @@ HRESULT WINAPI XTL::EMUPATCH(CDirectSoundStream_Flush) DSoundBufferSynchPlaybackFlagRemove(pThis->EmuFlags); - // Remove flags only (This is the only place it will remove other than FlushEx perform set/remove the flags.) - pThis->EmuFlags &= ~(DSE_FLAG_FLUSH_ASYNC | DSE_FLAG_ENVELOPE | DSE_FLAG_ENVELOPE2); - pThis->Xb_rtFlushEx = 0LL; - while (DSStream_Packet_Flush(pThis)); return DS_OK; @@ -387,6 +383,8 @@ HRESULT WINAPI XTL::EMUPATCH(CDirectSoundStream_FlushEx) LOG_FUNC_END; HRESULT hRet = DSERR_INVALIDPARAM; + // Reset flags here to reprocess dwFlags request. + DSStream_Packet_FlushEx_Reset(pThis); // Cannot use rtTimeStamp here, it must be flush. if (dwFlags == X_DSSFLUSHEX_IMMEDIATE) {