AudioCommon: Improve pad silence when ppc does not keep up with realtime

Uses the last sample from the ppc buffer to fill the samples the ppc
didn't deliver data for, avoids clicking on underruns.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7338 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
pierre 2011-03-12 22:02:46 +00:00
parent 344c4019db
commit 37e31f2df6
2 changed files with 14 additions and 5 deletions

View File

@ -62,12 +62,12 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples)
if (m_sampleRate == 32000) if (m_sampleRate == 32000)
{ {
#if _M_SSE >= 0x301 #if _M_SSE >= 0x301
static const __m128i sr_mask =
_mm_set_epi32(0x0C0D0E0FL, 0x08090A0BL,
0x04050607L, 0x00010203L);
if (cpu_info.bSSSE3 && !((numLeft * 2) % 8)) if (cpu_info.bSSSE3 && !((numLeft * 2) % 8))
{ {
static const __m128i sr_mask =
_mm_set_epi32(0x0C0D0E0FL, 0x08090A0BL,
0x04050607L, 0x00010203L);
for (unsigned int i = 0; i < numLeft * 2; i += 8) for (unsigned int i = 0; i < numLeft * 2; i += 8)
{ {
_mm_storeu_si128((__m128i *)&samples[i], _mm_shuffle_epi8(_mm_loadu_si128((__m128i *)&m_buffer[(m_indexR + i) & INDEX_MASK]), sr_mask)); _mm_storeu_si128((__m128i *)&samples[i], _mm_shuffle_epi8(_mm_loadu_si128((__m128i *)&m_buffer[(m_indexR + i) & INDEX_MASK]), sr_mask));
@ -123,7 +123,14 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples)
// Padding // Padding
if (numSamples > numLeft) if (numSamples > numLeft)
memset(&samples[numLeft * 2], 0, (numSamples - numLeft) * 4); {
unsigned short s[2];
s[0] = Common::swap16(m_buffer[(m_indexR - 1) & INDEX_MASK]);
s[1] = Common::swap16(m_buffer[(m_indexR - 2) & INDEX_MASK]);
for (unsigned int i = numLeft*2; i < numSamples*2; i+=2)
*(u32*)(samples+i) = *(u32*)(s);
// memset(&samples[numLeft * 2], 0, (numSamples - numLeft) * 4);
}
//when logging, also throttle HLE audio //when logging, also throttle HLE audio
if (m_logAudio) { if (m_logAudio) {

View File

@ -44,6 +44,8 @@ public:
// So when AI/DAC sample rate differs than 32KHz, we have to do re-sampling // So when AI/DAC sample rate differs than 32KHz, we have to do re-sampling
m_sampleRate = BackendSampleRate; m_sampleRate = BackendSampleRate;
memset(m_buffer, 0, sizeof(m_buffer));
INFO_LOG(AUDIO_INTERFACE, "Mixer is initialized (AISampleRate:%i, DACSampleRate:%i)", AISampleRate, DACSampleRate); INFO_LOG(AUDIO_INTERFACE, "Mixer is initialized (AISampleRate:%i, DACSampleRate:%i)", AISampleRate, DACSampleRate);
} }