Core/AudioCommon: Feed bigger audio chunks to the output devices in case of underrun.

This should eliminate the crackling with alsa and pulseaudio backends and replace it
with much nicer pauses. This is only interesting for audio backends that do not
respect Mixer::GetNumSamples() and should not impact users able to run the DSPLLE at
full speed.

The cost of this is an added LLE audio latency of about 0.06 s in the continuous
playback case. If that is too much, lower the low watermark.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6239 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
pierre 2010-09-28 21:43:38 +00:00
parent 7eb99b9088
commit ce1057f17d
2 changed files with 30 additions and 12 deletions

View File

@ -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

View File

@ -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:
};