From 0d3c3f633975a8d88a124bc5d03d9408df710f43 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Tue, 20 Nov 2012 04:18:48 +0100 Subject: [PATCH] Fix a crash in AXWii with SRC ratio > 4 (which I thought was impossible, but AXWii changed the SRC algorithm) --- .../Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp | 2 +- .../Core/Src/HW/DSPHLE/UCodes/UCode_AX_Voice.h | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp index 7f9879a8f6..3e67629226 100644 --- a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp +++ b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp @@ -315,7 +315,7 @@ void CUCode_AXWii::OutputSamples(u32 lr_addr, u32 surround_addr, u16 volume) void CUCode_AXWii::DoState(PointerWrap &p) { - std::lock_guard lk(m_csMix); + std::lock_guard lk(m_processing); // TODO diff --git a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX_Voice.h b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX_Voice.h index 22ef0583ce..5f43fc5b6e 100644 --- a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX_Voice.h +++ b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX_Voice.h @@ -234,9 +234,15 @@ inline void GetInputSamples(PB_TYPE& pb, s16* samples) // Compute the number of real samples we will need to read from the // data source. We need to output 32 samples, so we need to read - // 32 * ratio + curr_pos samples. The maximum possible ratio available - // on the DSP is 4.0, so at most we will read 128 real samples. - s16 real_samples[130]; + // 32 * ratio + curr_pos samples. There does not seem to be a maximum + // value for the ratio in recent versions of AXWii (previously it was + // limited to 4.0), so we will limit it to 16.0 and clamp the ratio if + // needed. This is a HACK, and using another algorithm for linear + // interpolation might be a better idea. + if (ratio > 0x00100000) + ratio = 0x00100000; + + s16 real_samples[514]; u32 real_samples_needed = (32 * ratio + curr_pos) >> 16; // The first two real samples are the ones we read at the previous @@ -341,9 +347,6 @@ void Process1ms(PB_TYPE& pb, const AXBuffers& buffers, AXMixControl mctrl) // Mix LRS, AUXA and AUXB depending on mixer_control // TODO: Handle DPL2 on AUXB. - // HACK: at the moment we don't mix surround into left and right, so always - // mix left and right in order to have sound even if a game uses surround - // only. if (mctrl & MIX_L) MixAdd(buffers.left, samples, &pb.mixer.left, mctrl & MIX_L_RAMP); if (mctrl & MIX_R)