diff --git a/Source/Core/AudioCommon/Src/Mixer.cpp b/Source/Core/AudioCommon/Src/Mixer.cpp index 36a3030707..b5843a3e8d 100644 --- a/Source/Core/AudioCommon/Src/Mixer.cpp +++ b/Source/Core/AudioCommon/Src/Mixer.cpp @@ -37,19 +37,30 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples) } unsigned int numLeft = Common::AtomicLoad(m_numSamples); - numLeft = (numLeft > numSamples) ? numSamples : numLeft; - - // Do re-sampling if needed - if (m_sampleRate == 32000) - { - for (unsigned int i = 0; i < numLeft * 2; i++) - samples[i] = Common::swap16(m_buffer[(m_indexR + i) & INDEX_MASK]); - m_indexR += numLeft * 2; + if (m_LLEplaying) { + if (numLeft < numSamples)//cannot do much about this + m_LLEplaying = false; + if (numLeft < MAX_SAMPLES/4)//low watermark + m_LLEplaying = false; + } else { + if (numLeft > MAX_SAMPLES/2)//high watermark + m_LLEplaying = true; } - else - { - // AyuanX: Up-sampling is not implemented yet - PanicAlert("Mixer: Up-sampling is not implemented yet!"); + + if (m_LLEplaying) { + numLeft = (numLeft > numSamples) ? numSamples : numLeft; + + // Do re-sampling if needed + if (m_sampleRate == 32000) + { + for (unsigned int i = 0; i < numLeft * 2; i++) + samples[i] = Common::swap16(m_buffer[(m_indexR + i) & INDEX_MASK]); + m_indexR += numLeft * 2; + } + else + { + // AyuanX: Up-sampling is not implemented yet + PanicAlert("Mixer: Up-sampling is not implemented yet!"); /* static int PV1l=0,PV2l=0,PV3l=0,PV4l=0; static int PV1r=0,PV2r=0,PV3r=0,PV4r=0; @@ -112,6 +123,10 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples) m_queueSize += 2; } */ + } + + } else { + numLeft = 0; } // Padding diff --git a/Source/Core/AudioCommon/Src/Mixer.h b/Source/Core/AudioCommon/Src/Mixer.h index c1bf17be1a..8db6da1ca7 100644 --- a/Source/Core/AudioCommon/Src/Mixer.h +++ b/Source/Core/AudioCommon/Src/Mixer.h @@ -35,6 +35,7 @@ public: , m_numSamples(0) , m_indexW(0) , m_indexR(0) + , m_LLEplaying(true) { // AyuanX: The internal (Core & DSP) sample rate is fixed at 32KHz // So when AI/DAC sample rate differs than 32KHz, we have to do re-sampling @@ -80,6 +81,8 @@ protected: u32 m_indexW; u32 m_indexR; + bool m_LLEplaying; + private: };