DSound Improvement
- Fixed ResizeIDirectSoundBuffer bug for return value. - Fixed IDirectSoundBuffer_SetNotificationPositions to only check hRet, not nullptr itself. - Replaced SUCCEEDED check to == DS_OK - Replaced FAILED check to != DS_OK
This commit is contained in:
parent
e2f38df63e
commit
b019c2ea56
|
@ -193,7 +193,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreate)
|
|||
if (!initialized || !g_pDSound8) {
|
||||
hRet = DirectSoundCreate8(&g_XBAudio.GetAudioAdapter(), ppDirectSound, NULL);
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("DirectSoundCreate8 Failed!");
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreate)
|
|||
|
||||
hRet = g_pDSound8->SetCooperativeLevel(g_hEmuWindow, DSSCL_PRIORITY);
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("g_pDSound8->SetCooperativeLevel Failed!");
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreate)
|
|||
|
||||
hRet = g_pDSound8->CreateSoundBuffer(&bufferDesc, &g_pDSoundPrimaryBuffer, NULL);
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("Creating primary buffer for DirectSound Failed!");
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreate)
|
|||
|
||||
hRet = g_pDSoundPrimaryBuffer->QueryInterface(IID_IDirectSound3DListener8, (LPVOID*)&g_pDSoundPrimary3DListener8);
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("Creating primary 3D Listener for DirectSound Failed!");
|
||||
}
|
||||
|
||||
|
@ -831,20 +831,20 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreateBuffer)
|
|||
LPDIRECTSOUNDBUFFER pTempBuffer;
|
||||
HRESULT hRet = g_pDSound8->CreateSoundBuffer(pDSBufferDesc, &pTempBuffer, NULL);
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("CreateSoundBuffer Failed!");
|
||||
(*ppBuffer)->EmuDirectSoundBuffer8 = NULL;
|
||||
} else {
|
||||
hRet = pTempBuffer->QueryInterface(IID_IDirectSoundBuffer8, (LPVOID*)&((*ppBuffer)->EmuDirectSoundBuffer8));
|
||||
pTempBuffer->Release();
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("CreateSoundBuffer8 Failed!");
|
||||
}
|
||||
if (pdsbd->dwFlags & DSBCAPS_CTRL3D) {
|
||||
|
||||
HRESULT hRet3D = (*ppBuffer)->EmuDirectSoundBuffer8->QueryInterface(IID_IDirectSound3DBuffer8, (LPVOID*)&((*ppBuffer)->EmuDirectSound3DBuffer8));
|
||||
if (FAILED(hRet3D)) {
|
||||
if (hRet != DS_OK) {
|
||||
EmuWarning("CreateSound3DBuffer8 Failed!");
|
||||
(*ppBuffer)->EmuDirectSound3DBuffer8 = NULL;
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_Lock)
|
|||
|
||||
hRet = pThis->EmuDirectSoundBuffer8->Lock(dwOffset, dwBytes, ppvAudioPtr1, pdwAudioBytes1, ppvAudioPtr2, pdwAudioBytes2, dwFlags);
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("DirectSoundBuffer Lock Failed!");
|
||||
}
|
||||
pThis->EmuLockOffset = dwOffset;
|
||||
|
@ -1241,7 +1241,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_SetCurrentPosition)
|
|||
// NOTE: TODO: This call *will* (by MSDN) fail on primary buffers!
|
||||
HRESULT hRet = pThis->EmuDirectSoundBuffer8->SetCurrentPosition(dwNewPosition);
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
EmuWarning("SetCurrentPosition Failed!");
|
||||
}
|
||||
|
||||
|
@ -1424,7 +1424,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreateStream)
|
|||
EmuWarning("Initializing DirectSound pointer since it DirectSoundCreate was not called!");
|
||||
|
||||
hRet = XTL::EMUPATCH(DirectSoundCreate)(NULL, &g_pDSound8, NULL);
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("Unable to initialize DirectSound!");
|
||||
}
|
||||
}
|
||||
|
@ -1473,14 +1473,14 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreateStream)
|
|||
LPDIRECTSOUNDBUFFER pTempBuffer;
|
||||
HRESULT hRet = g_pDSound8->CreateSoundBuffer(pDSBufferDesc, &pTempBuffer, NULL);
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("CreateSoundBuffer Failed!");
|
||||
(*ppStream)->EmuDirectSoundBuffer8 = NULL;
|
||||
} else {
|
||||
hRet = pTempBuffer->QueryInterface(IID_IDirectSoundBuffer8, (LPVOID*)&((*ppStream)->EmuDirectSoundBuffer8));
|
||||
pTempBuffer->Release();
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("CreateSoundBuffer8 Failed!");
|
||||
}
|
||||
|
||||
|
@ -1490,7 +1490,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreateStream)
|
|||
if (pDSBufferDesc->dwFlags & DSBCAPS_CTRL3D) {
|
||||
|
||||
HRESULT hRet3D = (*ppStream)->EmuDirectSoundBuffer8->QueryInterface(IID_IDirectSound3DBuffer8, (LPVOID*)&((*ppStream)->EmuDirectSound3DBuffer8));
|
||||
if (FAILED(hRet3D)) {
|
||||
if (hRet != DS_OK) {
|
||||
EmuWarning("CreateSound3DBuffer Failed!");
|
||||
(*ppStream)->EmuDirectSound3DBuffer8 = NULL;
|
||||
}
|
||||
|
@ -1765,7 +1765,7 @@ HRESULT WINAPI XTL::EMUPATCH(CDirectSoundStream_Process)
|
|||
} else {
|
||||
hRet = pThis->EmuDirectSoundBuffer8->Lock(0, pThis->EmuBufferDesc->dwBufferBytes, &pAudioPtr, &dwAudioBytes, &pAudioPtr2, &dwAudioBytes2, 0);
|
||||
|
||||
if (SUCCEEDED(hRet)) {
|
||||
if (hRet == DS_OK) {
|
||||
|
||||
if (pAudioPtr != 0) {
|
||||
memcpy(pAudioPtr, pThis->EmuBuffer, dwAudioBytes);
|
||||
|
@ -3019,7 +3019,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSound_GetCaps)
|
|||
ZeroMemory(&DSCapsPC, sizeof(DSCAPS));
|
||||
|
||||
HRESULT hRet = g_pDSound8->GetCaps(&DSCapsPC);
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
EmuWarning("Failed to get PC DirectSound caps!");
|
||||
}
|
||||
|
||||
|
@ -3397,9 +3397,9 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_SetNotificationPositions)
|
|||
if (pThis) {
|
||||
if (pThis->EmuDirectSoundBuffer8) {
|
||||
hRet = pThis->EmuDirectSoundBuffer8->QueryInterface(IID_IDirectSoundNotify8, (LPVOID*)&pNotify);
|
||||
if (SUCCEEDED(hRet) && pNotify != nullptr) {
|
||||
if (hRet == DS_OK) {
|
||||
hRet = pNotify->SetNotificationPositions(dwNotifyCount, paNotifies);
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
EmuWarning("Could not set notification position(s)!");
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ void DSoundBufferXboxAdpcmDecoder(
|
|||
if (isLock == false) {
|
||||
hr = pDSBuffer->Lock(dwOffset, pDSBufferDesc->dwBufferBytes, &pPtrX, &dwBytesX, &pPtrX2, &dwBytesX2, 0);
|
||||
}
|
||||
if (SUCCEEDED(hr)) {
|
||||
if (hr == DS_OK) {
|
||||
// Write the converted PCM buffer bytes
|
||||
|
||||
if (isLock == false) {
|
||||
|
@ -386,22 +386,22 @@ inline void ResizeIDirectSoundBuffer(
|
|||
pDSBuffer->GetFrequency(&dwFrequency);
|
||||
pDSBuffer->GetPan(&lPan);
|
||||
|
||||
if (pDSBufferDesc->dwFlags & DSBCAPS_CTRL3D) {
|
||||
if (pDS3DBuffer != xbnullptr && pDSBufferDesc->dwFlags & DSBCAPS_CTRL3D) {
|
||||
pDS3DBuffer->GetAllParameters(&ds3dBuffer);
|
||||
}
|
||||
|
||||
HRESULT hRet = pDSBuffer->GetCurrentPosition(&dwPlayCursor, &dwWriteCursor);
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("Unable to retrieve current position for resize reallocation!");
|
||||
}
|
||||
hRet = pDSBuffer->GetStatus(&dwStatus);
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("Unable to retrieve current status for resize reallocation!");
|
||||
}
|
||||
|
||||
if (pDS3DBuffer != NULL) {
|
||||
if (pDS3DBuffer != xbnullptr) {
|
||||
pDS3DBuffer->Release();
|
||||
}
|
||||
// release old buffer
|
||||
|
@ -415,25 +415,25 @@ inline void ResizeIDirectSoundBuffer(
|
|||
LPDIRECTSOUNDBUFFER pTempBuffer;
|
||||
hRet = g_pDSound8->CreateSoundBuffer(pDSBufferDesc, &pTempBuffer, NULL);
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("CreateSoundBuffer Failed!");
|
||||
pDSBufferDesc = NULL;
|
||||
pDSBufferDesc = xbnullptr;
|
||||
} else {
|
||||
hRet = pTempBuffer->QueryInterface(IID_IDirectSoundBuffer8, (LPVOID*)&(pDSBuffer));
|
||||
pTempBuffer->Release();
|
||||
}
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
CxbxKrnlCleanup("IDirectSoundBuffer8 resize Failed!");
|
||||
}
|
||||
if (refCount) {
|
||||
while (pDSBuffer->AddRef() < refCount);
|
||||
}
|
||||
if (pDSBufferDesc->dwFlags & DSBCAPS_CTRL3D) {
|
||||
HRESULT hRet3D = pDSBuffer->QueryInterface(IID_IDirectSound3DBuffer, (LPVOID*)&(pDS3DBuffer));
|
||||
if (FAILED(hRet3D)) {
|
||||
if (pDS3DBuffer != xbnullptr && pDSBufferDesc->dwFlags & DSBCAPS_CTRL3D) {
|
||||
hRet = pDSBuffer->QueryInterface(IID_IDirectSound3DBuffer, (LPVOID*)&(pDS3DBuffer));
|
||||
if (hRet != DS_OK) {
|
||||
EmuWarning("CreateSound3DBuffer Failed!");
|
||||
pDS3DBuffer = NULL;
|
||||
pDS3DBuffer = xbnullptr;
|
||||
} else {
|
||||
pDS3DBuffer->SetAllParameters(&ds3dBuffer, DS3D_IMMEDIATE);
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ inline void DSoundBufferUpdate(
|
|||
} else {
|
||||
HRESULT hRet = pThis->Lock(dwOffset, pDSBufferDesc->dwBufferBytes, &pAudioPtr, &dwAudioBytes, &pAudioPtr2, &dwAudioBytes2, 0);
|
||||
|
||||
if (SUCCEEDED(hRet)) {
|
||||
if (hRet == DS_OK) {
|
||||
if (pAudioPtr != nullptr) {
|
||||
memcpy(pAudioPtr, pBuffer, dwAudioBytes);
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ inline HRESULT HybridDirectSoundBuffer_GetCurrentPosition(
|
|||
|
||||
HRESULT hRet = pDSBuffer->GetCurrentPosition(pdwCurrentPlayCursor, pdwCurrentWriteCursor);
|
||||
|
||||
if (FAILED(hRet)) {
|
||||
if (hRet != DS_OK) {
|
||||
EmuWarning("GetCurrentPosition Failed!");
|
||||
}
|
||||
if (pdwCurrentPlayCursor != 0 && pdwCurrentWriteCursor != 0) {
|
||||
|
@ -715,7 +715,7 @@ inline HRESULT HybridDirectSoundBuffer_Play(
|
|||
}
|
||||
// rewind buffer
|
||||
if ((dwFlags & X_DSBPLAY_FROMSTART)) {
|
||||
if (FAILED(pDSBuffer->SetCurrentPosition(0))) {
|
||||
if (pDSBuffer->SetCurrentPosition(0) != DS_OK) {
|
||||
EmuWarning("Rewinding buffer failed!");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue