From 04dce78f53844bca276d02a5473a68078d065ab5 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Fri, 1 May 2020 06:26:17 -0500 Subject: [PATCH] forward xbox audio format to internal voice class --- .../DSOUND/DirectSound/DirectSoundInline.hpp | 4 ++-- .../hle/DSOUND/common/windows/WFXformat.hpp | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp b/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp index 9bedb165c..cc591eaf2 100644 --- a/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp +++ b/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp @@ -290,7 +290,7 @@ static inline void GeneratePCMFormat( dwEmuFlags = dwEmuFlags & ~DSE_FLAG_AUDIO_CODECS; - CODEC_FORMAT cf_audio = WFXformat_SyncHostFormat(DSBufferDesc.lpwfxFormat, Xb_lpwfxFormat, X_BufferSizeRequest, Xb_flags); + CODEC_FORMAT cf_audio = WFXformat_SyncHostFormat(DSBufferDesc.lpwfxFormat, Xb_lpwfxFormat, X_BufferSizeRequest, Xb_flags, Xb_Voice); if (cf_audio == CF_PCM) { dwEmuFlags |= DSE_FLAG_PCM; } @@ -304,7 +304,7 @@ static inline void GeneratePCMFormat( } else { dwEmuFlags |= DSE_FLAG_RECIEVEDATA; - (void)WFXformat_SyncHostFormat(DSBufferDesc.lpwfxFormat, Xb_lpwfxFormat, X_BufferSizeRequest, Xb_flags); + (void)WFXformat_SyncHostFormat(DSBufferDesc.lpwfxFormat, Xb_lpwfxFormat, X_BufferSizeRequest, Xb_flags, Xb_Voice); DSBufferDesc.dwFlags = DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY; DSBufferDesc.dwBufferBytes = 5 * DSBufferDesc.lpwfxFormat->nAvgBytesPerSec; diff --git a/src/core/hle/DSOUND/common/windows/WFXformat.hpp b/src/core/hle/DSOUND/common/windows/WFXformat.hpp index 9118a996a..ac81e54ae 100644 --- a/src/core/hle/DSOUND/common/windows/WFXformat.hpp +++ b/src/core/hle/DSOUND/common/windows/WFXformat.hpp @@ -251,15 +251,17 @@ static void WFXformat_SanityFix( } static CODEC_FORMAT WFXformat_SyncHostFormat( - void* Host_wfx_ptr, - const void* Xb_wfx_ptr, - uint32_t Xb_buffer_request_size, - uint32_t Xb_flags) + void* Host_wfx_ptr, + const void* Xb_wfx_ptr, + uint32_t Xb_buffer_request_size, + uint32_t Xb_flags, + XTL::CDirectSoundVoice* Xb_Voice) { PWAVEFORMATEXTENSIBLE Xb_wfxFormat = (PWAVEFORMATEXTENSIBLE)Xb_wfx_ptr; PWAVEFORMATEXTENSIBLE Host_wfxFormat = (PWAVEFORMATEXTENSIBLE)Host_wfx_ptr; CODEC_FORMAT codec_format_ret = CF_PCM; bool require_validate = true; + XTL::audio_format xb_format; // If no format is provided, then use default. if (Xb_wfx_ptr == xbnullptr) { @@ -332,5 +334,13 @@ static CODEC_FORMAT WFXformat_SyncHostFormat( WFXformat_GeneratePCMFormat(2, 44100, 16, Host_wfxFormat); } } + // Forward xbox format to internal XTL::CDirectSoundVoice class. + xb_format.audio_codec = (codec_format_ret == CF_XADPCM ? WAVE_FORMAT_XBOX_ADPCM : WAVE_FORMAT_PCM); + xb_format.nChannels = Host_wfxFormat->Format.nChannels; + xb_format.cbSize = (codec_format_ret == CF_XADPCM ? 4 : 0); + xb_format.nSamplesPerSec = Host_wfxFormat->Format.nSamplesPerSec; + xb_format.bitsPerSample = (codec_format_ret == CF_XADPCM ? 4 : Host_wfxFormat->Format.wBitsPerSample); + Xb_Voice->SetFormat(Xb_Voice, xb_format); + return codec_format_ret; }