Fix a crash in AXWii with SRC ratio > 4 (which I thought was impossible, but AXWii changed the SRC algorithm)

This commit is contained in:
Pierre Bourdon 2012-11-20 04:18:48 +01:00
parent 321e3a8421
commit 0d3c3f6339
2 changed files with 10 additions and 7 deletions

View File

@ -315,7 +315,7 @@ void CUCode_AXWii::OutputSamples(u32 lr_addr, u32 surround_addr, u16 volume)
void CUCode_AXWii::DoState(PointerWrap &p) void CUCode_AXWii::DoState(PointerWrap &p)
{ {
std::lock_guard<std::mutex> lk(m_csMix); std::lock_guard<std::mutex> lk(m_processing);
// TODO // TODO

View File

@ -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 // 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 // data source. We need to output 32 samples, so we need to read
// 32 * ratio + curr_pos samples. The maximum possible ratio available // 32 * ratio + curr_pos samples. There does not seem to be a maximum
// on the DSP is 4.0, so at most we will read 128 real samples. // value for the ratio in recent versions of AXWii (previously it was
s16 real_samples[130]; // 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; u32 real_samples_needed = (32 * ratio + curr_pos) >> 16;
// The first two real samples are the ones we read at the previous // 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 // Mix LRS, AUXA and AUXB depending on mixer_control
// TODO: Handle DPL2 on AUXB. // 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) if (mctrl & MIX_L)
MixAdd(buffers.left, samples, &pb.mixer.left, mctrl & MIX_L_RAMP); MixAdd(buffers.left, samples, &pb.mixer.left, mctrl & MIX_L_RAMP);
if (mctrl & MIX_R) if (mctrl & MIX_R)