From ddd2cd8bddc6f7ceedf50310d8692e057e104980 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Tue, 22 Jan 2019 13:22:07 -0600 Subject: [PATCH] HACK fix for DSound's LOCDEFER flag Due to title doesn't passdown specific channels, I am assuming it is relying on hardware level to output the mixin audio. --- .../hle/DSOUND/DirectSound/DirectSoundInline.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp b/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp index 0c1662989..e86c62d72 100644 --- a/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp +++ b/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp @@ -221,12 +221,23 @@ inline void GeneratePCMFormat( if (DSBufferDesc.lpwfxFormat == nullptr) { // Only allocate extra value for setting extra values later on. WAVEFORMATEXTENSIBLE is the highest size I had seen. DSBufferDesc.lpwfxFormat = (WAVEFORMATEX*)calloc(1, sizeof(WAVEFORMATEXTENSIBLE)); - } + } + if (lpwfxFormat->wFormatTag == WAVE_FORMAT_PCM) { // Test case: Hulk crash due to cbSize is not a valid size. memcpy(DSBufferDesc.lpwfxFormat, lpwfxFormat, sizeof(WAVEFORMATEX)); DSBufferDesc.lpwfxFormat->cbSize = 0; // Let's enforce this value to prevent any other exception later on. - } else { + } + else if (lpwfxFormat->wFormatTag == 0 && (DSBufferDesc.dwFlags & DSBCAPS_LOCDEFER) > 0) { + // NOTE: This is currently a hack for ability to create buffer class with DSBCAPS_LOCDEFER flag. + DSBufferDesc.lpwfxFormat->wFormatTag = WAVE_FORMAT_PCM; + DSBufferDesc.lpwfxFormat->nChannels = 2; + DSBufferDesc.lpwfxFormat->nSamplesPerSec = 44100; + DSBufferDesc.lpwfxFormat->wBitsPerSample = 8; + DSBufferDesc.lpwfxFormat->nBlockAlign = (DSBufferDesc.lpwfxFormat->wBitsPerSample / 8 * DSBufferDesc.lpwfxFormat->nChannels); + DSBufferDesc.lpwfxFormat->nAvgBytesPerSec = DSBufferDesc.lpwfxFormat->nSamplesPerSec * DSBufferDesc.lpwfxFormat->nBlockAlign; + } + else { memcpy(DSBufferDesc.lpwfxFormat, lpwfxFormat, sizeof(WAVEFORMATEX) + lpwfxFormat->cbSize); }