fix audio flush async worker

This commit is contained in:
RadWolfie 2020-03-13 13:33:25 -05:00
parent 2c440eb03a
commit 4a27006ce6
4 changed files with 18 additions and 13 deletions

View File

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

View File

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

View File

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

View File

@ -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) {