From 1affa2a68013a76d0f6c3849cce4b214f5c43b93 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Thu, 28 Mar 2019 00:26:50 -0500 Subject: [PATCH] hotfix for convert uint16_t to uint32_t as should be for nBlockAlign equation --- src/core/hle/DSOUND/DirectSound/DirectSound.cpp | 2 +- src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/hle/DSOUND/DirectSound/DirectSound.cpp b/src/core/hle/DSOUND/DirectSound/DirectSound.cpp index 1caa5633c..8dc705e7f 100644 --- a/src/core/hle/DSOUND/DirectSound/DirectSound.cpp +++ b/src/core/hle/DSOUND/DirectSound/DirectSound.cpp @@ -1935,7 +1935,7 @@ HRESULT WINAPI XTL::EMUPATCH(CDirectSoundStream_GetInfo) pInfo->dwFlags = XMO_STREAMF_FIXED_SAMPLE_SIZE | XMO_STREAMF_INPUT_ASYNC; pInfo->dwInputSize = pThis->EmuBufferDesc.lpwfxFormat->nBlockAlign; pInfo->dwOutputSize = 0; - pInfo->dwMaxLookahead = std::max(static_cast(pThis->EmuBufferDesc.lpwfxFormat->nChannels * pThis->EmuBufferDesc.lpwfxFormat->wBitsPerSample / 8) * 32, static_cast(pThis->EmuBufferDesc.lpwfxFormat->nBlockAlign) * 2); + pInfo->dwMaxLookahead = std::max(static_cast(pThis->EmuBufferDesc.lpwfxFormat->nChannels * static_cast(pThis->EmuBufferDesc.lpwfxFormat->wBitsPerSample) / 8) * 32, static_cast(pThis->EmuBufferDesc.lpwfxFormat->nBlockAlign) * 2); } leaveCriticalSection; diff --git a/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp b/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp index 6b4c11a58..ef4a854f1 100644 --- a/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp +++ b/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp @@ -226,7 +226,7 @@ inline void GeneratePCMFormat( lpwfxFormatHost->nChannels = 2; lpwfxFormatHost->nSamplesPerSec = 44100; lpwfxFormatHost->wBitsPerSample = 8; - lpwfxFormatHost->nBlockAlign = lpwfxFormatHost->nChannels * lpwfxFormatHost->wBitsPerSample / 8; + lpwfxFormatHost->nBlockAlign = lpwfxFormatHost->nChannels * static_cast(lpwfxFormatHost->wBitsPerSample) / 8; lpwfxFormatHost->nAvgBytesPerSec = lpwfxFormatHost->nSamplesPerSec * lpwfxFormatHost->nBlockAlign; } else { @@ -249,7 +249,7 @@ inline void GeneratePCMFormat( } if (lpwfxFormatHost->nBlockAlign == 0) { - lpwfxFormatHost->nBlockAlign = lpwfxFormatHost->nChannels * lpwfxFormatHost->wBitsPerSample / 8; + lpwfxFormatHost->nBlockAlign = lpwfxFormatHost->nChannels * static_cast(lpwfxFormatHost->wBitsPerSample) / 8; } if (lpwfxFormatHost->nSamplesPerSec == 0) { @@ -335,7 +335,7 @@ inline void GeneratePCMFormat( // TODO: Still a requirement? Need to retest it again. Can't remember which title cause problem or had been resolved. // sanity check if (!bIsSpecial) { - if (DSBufferDesc.lpwfxFormat->nBlockAlign != (DSBufferDesc.lpwfxFormat->nChannels*DSBufferDesc.lpwfxFormat->wBitsPerSample) / 8) { + if (DSBufferDesc.lpwfxFormat->nBlockAlign != DSBufferDesc.lpwfxFormat->nChannels* static_cast(DSBufferDesc.lpwfxFormat->wBitsPerSample) / 8) { DSBufferDesc.lpwfxFormat->nBlockAlign = (2 * DSBufferDesc.lpwfxFormat->wBitsPerSample) / 8; DSBufferDesc.lpwfxFormat->nAvgBytesPerSec = DSBufferDesc.lpwfxFormat->nSamplesPerSec * DSBufferDesc.lpwfxFormat->nBlockAlign; }