mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-12 05:50:29 +02:00
Optimize the resampler a little. Update native with new ability to not force 44khz so we actually get any use.
This causes Nexus 4 and Nexus 9 to end up on the fast path, greatly decreasing audio latency! This also removes the "atomic audio" setting as the new audio code is lock-free always.
This commit is contained in:
1 parent
1b926ec59e
commit
0c6ceee210
6 files changed
+16
-40
No files matched your search
@@ -334,8 +334,6 @@ static bool DefaultForceFlushToZero() {
|
||||
static ConfigSetting cpuSettings[] = {
|
||||
ReportedConfigSetting("Jit", &g_Config.bJit, &DefaultJit, true, true),
|
||||
ReportedConfigSetting("SeparateCPUThread", &g_Config.bSeparateCPUThread, false, true, true),
|
||||
ConfigSetting("AtomicAudioLocks", &g_Config.bAtomicAudioLocks, false, true, true),
|
||||
|
||||
ReportedConfigSetting("SeparateIOThread", &g_Config.bSeparateIOThread, true, true, true),
|
||||
ReportedConfigSetting("IOTimingMethod", &g_Config.iIOTimingMethod, IOTIMING_FAST, true, true),
|
||||
ConfigSetting("FastMemoryAccess", &g_Config.bFastMemory, true, true, true),
|
||||
|
||||
@@ -118,7 +118,6 @@ public:
|
||||
bool bSeparateCPUThread;
|
||||
int iIOTimingMethod;
|
||||
bool bSeparateIOThread;
|
||||
bool bAtomicAudioLocks;
|
||||
int iLockedCPUSpeed;
|
||||
bool bAutoSaveSymbolMap;
|
||||
bool bCacheFullIsoInRam;
|
||||
|
||||
+13
-30
@@ -71,20 +71,16 @@ unsigned int StereoResampler::MixerFifo::Mix(short* samples, unsigned int numSam
|
||||
u32 indexR = Common::AtomicLoad(m_indexR);
|
||||
u32 indexW = Common::AtomicLoad(m_indexW);
|
||||
|
||||
// Drift prevention mechanism
|
||||
float numLeft = (float)(((indexW - indexR) & INDEX_MASK) / 2);
|
||||
m_numLeftI = (numLeft + m_numLeftI*(CONTROL_AVG - 1)) / CONTROL_AVG;
|
||||
float offset = (m_numLeftI - LOW_WATERMARK) * CONTROL_FACTOR;
|
||||
if (offset > MAX_FREQ_SHIFT) offset = MAX_FREQ_SHIFT;
|
||||
if (offset < -MAX_FREQ_SHIFT) offset = -MAX_FREQ_SHIFT;
|
||||
|
||||
// render numleft sample pairs to samples[]
|
||||
// advance indexR with sample position
|
||||
// remember fractional offset
|
||||
|
||||
|
||||
float aid_sample_rate = m_input_sample_rate + offset;
|
||||
|
||||
/*
|
||||
/* Hm?
|
||||
u32 framelimit = SConfig::GetInstance().m_Framelimit;
|
||||
if (consider_framelimit && framelimit > 1) {
|
||||
aid_sample_rate = aid_sample_rate * (framelimit - 1) * 5 / 59.994;
|
||||
@@ -96,21 +92,14 @@ unsigned int StereoResampler::MixerFifo::Mix(short* samples, unsigned int numSam
|
||||
// TODO: Add a fast path for 1:1.
|
||||
for (; currentSample < numSamples * 2 && ((indexW - indexR) & INDEX_MASK) > 2; currentSample += 2) {
|
||||
u32 indexR2 = indexR + 2; //next sample
|
||||
|
||||
s16 l1 = m_buffer[indexR & INDEX_MASK]; //current
|
||||
s16 l2 = m_buffer[indexR2 & INDEX_MASK]; //next
|
||||
int sampleL = ((l1 << 16) + (l2 - l1) * (u16)m_frac) >> 16;
|
||||
sampleL += samples[currentSample + 1];
|
||||
MathUtil::Clamp(&sampleL, -32767, 32767);
|
||||
samples[currentSample + 1] = sampleL;
|
||||
|
||||
s16 r1 = m_buffer[(indexR + 1) & INDEX_MASK]; //current
|
||||
s16 l2 = m_buffer[indexR2 & INDEX_MASK]; //next
|
||||
s16 r2 = m_buffer[(indexR2 + 1) & INDEX_MASK]; //next
|
||||
int sampleL = ((l1 << 16) + (l2 - l1) * (u16)m_frac) >> 16;
|
||||
int sampleR = ((r1 << 16) + (r2 - r1) * (u16)m_frac) >> 16;
|
||||
sampleR += samples[currentSample];
|
||||
MathUtil::Clamp(&sampleR, -32767, 32767);
|
||||
samples[currentSample] = sampleR;
|
||||
|
||||
samples[currentSample] = clamp_s16(sampleL); // Do we even need to clamp after interpolation?
|
||||
samples[currentSample + 1] = clamp_s16(sampleR);
|
||||
m_frac += ratio;
|
||||
indexR += 2 * (u16)(m_frac >> 16);
|
||||
m_frac &= 0xffff;
|
||||
@@ -120,23 +109,19 @@ unsigned int StereoResampler::MixerFifo::Mix(short* samples, unsigned int numSam
|
||||
|
||||
// Padding with the last value to reduce clicking
|
||||
short s[2];
|
||||
s[0] = m_buffer[(indexR - 1) & INDEX_MASK];
|
||||
s[1] = m_buffer[(indexR - 2) & INDEX_MASK];
|
||||
s[0] = clamp_s16(m_buffer[(indexR - 1) & INDEX_MASK]);
|
||||
s[1] = clamp_s16(m_buffer[(indexR - 2) & INDEX_MASK]);
|
||||
for (; currentSample < numSamples * 2; currentSample += 2) {
|
||||
int sampleR = s[0] + samples[currentSample];
|
||||
MathUtil::Clamp(&sampleR, -32767, 32767);
|
||||
samples[currentSample] = sampleR;
|
||||
int sampleL = s[1] + samples[currentSample + 1];
|
||||
MathUtil::Clamp(&sampleL, -32767, 32767);
|
||||
samples[currentSample + 1] = sampleL;
|
||||
samples[currentSample] = s[0];
|
||||
samples[currentSample + 1] = s[1];
|
||||
}
|
||||
|
||||
// Flush cached variable
|
||||
Common::AtomicStore(m_indexR, indexR);
|
||||
|
||||
if (realSamples != numSamples * 2) {
|
||||
ILOG("Underrun! %i / %i", realSamples / 2, numSamples);
|
||||
}
|
||||
//if (realSamples != numSamples * 2) {
|
||||
// ILOG("Underrun! %i / %i", realSamples / 2, numSamples);
|
||||
//}
|
||||
|
||||
return realSamples / 2;
|
||||
}
|
||||
@@ -145,8 +130,6 @@ unsigned int StereoResampler::Mix(short* samples, unsigned int num_samples, bool
|
||||
if (!samples)
|
||||
return 0;
|
||||
|
||||
lock_guard lk(m_csMixing);
|
||||
memset(samples, 0, num_samples * 2 * sizeof(short));
|
||||
return m_dma_mixer.Mix(samples, num_samples, consider_framelimit, sample_rate);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,6 @@ public:
|
||||
|
||||
void SetDMAInputSampleRate(unsigned int rate);
|
||||
|
||||
recursive_mutex& MixerCritical() { return m_csMixing; }
|
||||
|
||||
float GetCurrentSpeed() const { return m_speed; }
|
||||
void UpdateSpeed(volatile float val) { m_speed = val; }
|
||||
|
||||
@@ -99,7 +97,5 @@ protected:
|
||||
MixerFifo m_dma_mixer;
|
||||
unsigned int m_sampleRate;
|
||||
|
||||
recursive_mutex m_csMixing;
|
||||
|
||||
volatile float m_speed; // Current rate of the emulation (1.0 = 100% speed)
|
||||
};
|
||||
@@ -428,8 +428,6 @@ void GameSettingsScreen::CreateViews() {
|
||||
#endif
|
||||
systemSettings->Add(new CheckBox(&g_Config.bSetRoundingMode, s->T("Respect FPU rounding (disable for old GEB saves)")))->OnClick.Handle(this, &GameSettingsScreen::OnJitAffectingSetting);
|
||||
|
||||
systemSettings->Add(new CheckBox(&g_Config.bAtomicAudioLocks, s->T("Atomic Audio locks (experimental)")))->SetEnabled(!PSP_IsInited());
|
||||
|
||||
systemSettings->Add(new ItemHeader(s->T("Developer Tools")));
|
||||
systemSettings->Add(new Choice(s->T("Developer Tools")))->OnClick.Handle(this, &GameSettingsScreen::OnDeveloperTools);
|
||||
|
||||
|
||||
+3
-1
@@ -219,8 +219,10 @@ std::string NativeQueryConfig(std::string query) {
|
||||
|
||||
sprintf(temp, "%i", scale);
|
||||
return std::string(temp);
|
||||
} else if (query == "force44khz") {
|
||||
return std::string("0");
|
||||
} else {
|
||||
return std::string("");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user