Introduce RETURN_RESULT_CHECK for DSound
Performing this method shall reduce hidden failures.
This commit is contained in:
parent
a3872923a7
commit
db3c23066d
|
@ -137,6 +137,12 @@ static XTL::X_CDirectSoundStream* g_pDSoundStreamCache[SOUNDSTREAM_CACHE_SIZE]
|
|||
static int g_bDSoundCreateCalled = FALSE;
|
||||
unsigned int g_iDSoundSynchPlaybackCounter = 0;
|
||||
|
||||
#define RETURN_RESULT_CHECK(hRet) { static bool bPopupShown = false; if (!bPopupShown) { bPopupShown = true; \
|
||||
printf("Return result report: 0x%08X\nIn %s (%s)", hRet, __func__, __FILE__); \
|
||||
MessageBoxA(NULL, "An issue has been found. Please report game title and console's output of return result," \
|
||||
" function, and file name to https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/issues/485", \
|
||||
"WARNING", MB_OK | MB_ICONWARNING); } return hRet; }
|
||||
|
||||
#include "EmuDSoundInline.hpp"
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -244,7 +250,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreate)
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -498,7 +504,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSound_SetOrientation)
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -737,7 +743,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSound_SetPosition)
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -769,7 +775,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSound_SetVelocity)
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -797,7 +803,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSound_SetAllParameters)
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -821,7 +827,7 @@ HRESULT WINAPI XTL::EMUPATCH(CDirectSound_CommitDeferredSettings)
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -1109,7 +1115,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_Lock)
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -1297,7 +1303,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_SetCurrentPosition)
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -1391,7 +1397,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_Stop)
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -1423,7 +1429,7 @@ extern "C" HRESULT __stdcall XTL::EMUPATCH(IDirectSoundBuffer_StopEx)
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -3564,7 +3570,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_SetNotificationPositions)
|
|||
");\n",
|
||||
pThis, dwNotifyCount, paNotifies);
|
||||
|
||||
HRESULT hr = DSERR_INVALIDPARAM;
|
||||
HRESULT hRet = DSERR_INVALIDPARAM;
|
||||
|
||||
// If we have a valid buffer, query a PC IDirectSoundNotify pointer and
|
||||
// use the paramaters as is since they are directly compatible, then release
|
||||
|
@ -3575,10 +3581,10 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_SetNotificationPositions)
|
|||
|
||||
if (pThis) {
|
||||
if (pThis->EmuDirectSoundBuffer8) {
|
||||
hr = pThis->EmuDirectSoundBuffer8->QueryInterface(IID_IDirectSoundNotify8, (LPVOID*)&pNotify);
|
||||
if (SUCCEEDED(hr) && pNotify != nullptr) {
|
||||
hr = pNotify->SetNotificationPositions(dwNotifyCount, paNotifies);
|
||||
if (FAILED(hr)) {
|
||||
hRet = pThis->EmuDirectSoundBuffer8->QueryInterface(IID_IDirectSoundNotify8, (LPVOID*)&pNotify);
|
||||
if (SUCCEEDED(hRet) && pNotify != nullptr) {
|
||||
hRet = pNotify->SetNotificationPositions(dwNotifyCount, paNotifies);
|
||||
if (FAILED(hRet)) {
|
||||
EmuWarning("Could not set notification position(s)!");
|
||||
}
|
||||
|
||||
|
@ -3591,7 +3597,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_SetNotificationPositions)
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hr;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
|
|
@ -564,7 +564,7 @@ inline HRESULT HybridDirectSoundBuffer_GetCurrentPosition(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
//IDirectSoundStream
|
||||
|
@ -579,7 +579,8 @@ inline HRESULT HybridDirectSoundBuffer_GetStatus(
|
|||
HRESULT hRet = pDSBuffer->GetStatus(pdwStatus);
|
||||
|
||||
leaveCriticalSection;
|
||||
return hRet;
|
||||
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -609,15 +610,15 @@ inline HRESULT HybridDirectSoundBuffer_Pause(
|
|||
enterCriticalSection;
|
||||
|
||||
DWORD dwStatus;
|
||||
HRESULT hRet;
|
||||
HRESULT hRet = DS_OK, hStatus;
|
||||
switch (dwPause) {
|
||||
case X_DSSPAUSE_RESUME:
|
||||
pDSBuffer->Play(0, 0, DSBPLAY_LOOPING);
|
||||
DSoundBufferRemoveSynchPlaybackFlag(dwEmuFlags);
|
||||
break;
|
||||
case X_DSSPAUSE_PAUSE:
|
||||
hRet = pDSBuffer->GetStatus(&dwStatus);
|
||||
if (hRet == DS_OK && dwStatus & DSBSTATUS_PLAYING) {
|
||||
hStatus = pDSBuffer->GetStatus(&dwStatus);
|
||||
if (hStatus == DS_OK && dwStatus & DSBSTATUS_PLAYING) {
|
||||
pDSBuffer->Stop();
|
||||
}
|
||||
DSoundBufferRemoveSynchPlaybackFlag(dwEmuFlags);
|
||||
|
@ -627,17 +628,17 @@ inline HRESULT HybridDirectSoundBuffer_Pause(
|
|||
|
||||
//SynchPlayback flag append should only occur in HybridDirectSoundBuffer_Pause function, nothing else is able to do this.
|
||||
if (g_iDSoundSynchPlaybackCounter >= DSOUND_MAX_SYNCHPLAYBACK_AUDIO) {
|
||||
return DSERR_GENERIC;
|
||||
}
|
||||
hRet = DSERR_GENERIC;
|
||||
} else {
|
||||
|
||||
g_iDSoundSynchPlaybackCounter++;
|
||||
dwEmuFlags |= DSB_FLAG_SYNCHPLAYBACK_CONTROL;
|
||||
hRet = pDSBuffer->GetStatus(&dwStatus);
|
||||
if (hRet == DS_OK && dwStatus & DSBSTATUS_PLAYING) {
|
||||
pDSBuffer->Stop();
|
||||
pDSBuffer->SetCurrentPosition(0);
|
||||
g_iDSoundSynchPlaybackCounter++;
|
||||
dwEmuFlags |= DSB_FLAG_SYNCHPLAYBACK_CONTROL;
|
||||
hRet = pDSBuffer->GetStatus(&dwStatus);
|
||||
if (hRet == DS_OK && dwStatus & DSBSTATUS_PLAYING) {
|
||||
pDSBuffer->Stop();
|
||||
pDSBuffer->SetCurrentPosition(0);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case X_DSSPAUSE_PAUSENOACTIVATE:
|
||||
EmuWarning("X_DSSPAUSE_PAUSENOACTIVATE is unsupported!");
|
||||
|
@ -646,7 +647,7 @@ inline HRESULT HybridDirectSoundBuffer_Pause(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return DS_OK;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
/*
|
||||
inline HRESULT HybridDirectSoundBuffer_PauseEx(
|
||||
|
@ -696,7 +697,7 @@ inline HRESULT HybridDirectSoundBuffer_Play(
|
|||
hRet = pDSBuffer->Play(0, 0, dwFlags);
|
||||
}
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
/*
|
||||
//IDirectSoundBuffer
|
||||
|
@ -734,7 +735,7 @@ inline HRESULT HybridDirectSound3DBuffer_SetAllParameters(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
/*
|
||||
//Only has one function, this is not a requirement.
|
||||
|
@ -764,7 +765,7 @@ inline HRESULT HybridDirectSound3DBuffer_SetConeAngles(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
//IDirectSoundStream
|
||||
|
@ -783,7 +784,7 @@ inline HRESULT HybridDirectSound3DBuffer_SetConeOrientation(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
//IDirectSoundStream
|
||||
|
@ -803,7 +804,7 @@ inline HRESULT HybridDirectSound3DBuffer_SetConeOutsideVolume(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
/*
|
||||
//Only has one function, this is not a requirement.
|
||||
|
@ -831,7 +832,7 @@ inline HRESULT HybridDirectSound3DListener_SetDistanceFactor(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
//IDirectSound
|
||||
|
@ -849,7 +850,7 @@ inline HRESULT HybridDirectSound3DListener_SetDopplerFactor(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
/*
|
||||
//TODO: PC DirectSound does not have SetHeadroom method function.
|
||||
|
@ -891,7 +892,7 @@ inline HRESULT HybridDirectSoundBuffer_SetFormat(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
//IDirectSoundStream
|
||||
|
@ -909,7 +910,7 @@ inline HRESULT HybridDirectSoundBuffer_SetFrequency(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -976,7 +977,7 @@ inline HRESULT HybridDirectSound3DBuffer_SetMaxDistance(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
//IDirectSoundStream
|
||||
|
@ -996,7 +997,7 @@ inline HRESULT HybridDirectSound3DBuffer_SetMinDistance(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
/*
|
||||
//TODO: PC DirectSound does not have SetMixBins method function.
|
||||
|
@ -1037,7 +1038,7 @@ inline HRESULT HybridDirectSound3DBuffer_SetMode(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
/*
|
||||
//Only has one function, this is not a requirement.
|
||||
|
@ -1106,7 +1107,7 @@ inline HRESULT HybridDirectSound3DBuffer_SetPosition(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
/*
|
||||
//TODO: PC DirectSound does not have SetRolloffCurve method function.
|
||||
|
@ -1137,7 +1138,7 @@ inline HRESULT HybridDirectSound3DListener_SetRolloffFactor(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
//IDirectSound
|
||||
|
@ -1160,7 +1161,7 @@ inline HRESULT HybridDirectSound3DBuffer_SetVelocity(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
//IDirectSoundStream x2
|
||||
|
@ -1176,7 +1177,7 @@ inline HRESULT HybridDirectSoundBuffer_SetVolume(
|
|||
|
||||
leaveCriticalSection;
|
||||
|
||||
return hRet;
|
||||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
/*/
|
||||
//Only has one function, this is not a requirement.
|
||||
|
|
Loading…
Reference in New Issue