From c71d1be2a5aef44c770110e9849d3931a90c2408 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sat, 9 Feb 2019 19:03:01 -0600 Subject: [PATCH] use shorter variable for host's lpwfxFormat --- .../DSOUND/DirectSound/DirectSoundInline.hpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp b/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp index 09cf5cfd3..bf83537be 100644 --- a/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp +++ b/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp @@ -211,7 +211,7 @@ inline void GeneratePCMFormat( if (lpwfxFormat != xbnullptr) { //TODO: RadWolfie - Need implement support for WAVEFORMATEXTENSIBLE as stated in CDirectSoundStream_SetFormat function note below - // Do we need to convert it? Or just only do the WAVEFORMATEX only? + // Do we need to convert it? Or just do the WAVEFORMATEX only? // NOTE: pwfxFormat is not always a WAVEFORMATEX structure, it can // be WAVEFORMATEXTENSIBLE if that's what the programmer(s) wanted @@ -222,23 +222,24 @@ inline void GeneratePCMFormat( // 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)); } + WAVEFORMATEX* lpwfxFormatHost = DSBufferDesc.lpwfxFormat; 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. + memcpy(lpwfxFormatHost, lpwfxFormat, sizeof(WAVEFORMATEX)); + lpwfxFormatHost->cbSize = 0; // Let's enforce this value to prevent any other exception later on. } 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; + lpwfxFormatHost->wFormatTag = WAVE_FORMAT_PCM; + lpwfxFormatHost->nChannels = 2; + lpwfxFormatHost->nSamplesPerSec = 44100; + lpwfxFormatHost->wBitsPerSample = 8; + lpwfxFormatHost->nBlockAlign = (lpwfxFormatHost->wBitsPerSample / 8 * lpwfxFormatHost->nChannels); + lpwfxFormatHost->nAvgBytesPerSec = lpwfxFormatHost->nSamplesPerSec * lpwfxFormatHost->nBlockAlign; } else { - memcpy(DSBufferDesc.lpwfxFormat, lpwfxFormat, sizeof(WAVEFORMATEX) + lpwfxFormat->cbSize); + memcpy(lpwfxFormatHost, lpwfxFormat, sizeof(WAVEFORMATEX) + lpwfxFormat->cbSize); } dwEmuFlags = dwEmuFlags & ~DSE_FLAG_AUDIO_CODECS;