Sas: Estimate time taken for mixing.

Tests seem to show it's not affected by mhz.
This commit is contained in:
Unknown W. Brackets 2015-11-25 18:23:50 -08:00
parent 75290cfd56
commit 23441d12fb
3 changed files with 17 additions and 4 deletions

View file

@ -243,8 +243,7 @@ static u32 _sceSasCore(u32 core, u32 outAddr) {
__SasEnqueueMix(outAddr);
// Actual delay time seems to between 240 and 1000 us, based on grain and possibly other factors.
return hleLogSuccessI(SCESAS, hleDelayResult(0, "sas core", 240));
return hleLogSuccessI(SCESAS, hleDelayResult(0, "sas core", sas->EstimateMixUs()));
}
// Another way of running the mixer, the inoutAddr should be both input and output
@ -260,8 +259,7 @@ static u32 _sceSasCoreWithMix(u32 core, u32 inoutAddr, int leftVolume, int right
__SasEnqueueMix(inoutAddr, inoutAddr, leftVolume, rightVolume);
// Actual delay time seems to between 240 and 1000 us, based on grain and possibly other factors.
return hleLogSuccessI(SCESAS, hleDelayResult(0, "sas core", 240));
return hleLogSuccessI(SCESAS, hleDelayResult(0, "sas core", sas->EstimateMixUs()));
}
static u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loop) {

View file

@ -408,6 +408,20 @@ void SasInstance::SetGrainSize(int newGrainSize) {
resampleBuffer = new s16[grainSize * 4 + 3];
}
int SasInstance::EstimateMixUs() {
int voicesPlayingCount = 0;
for (int v = 0; v < PSP_SAS_VOICES_MAX; v++) {
SasVoice &voice = voices[v];
if (!voice.playing || voice.paused)
continue;
voicesPlayingCount++;
}
// Each voice costs extra time, and each byte of grain costs extra time.
return 20 + voicesPlayingCount * 68 + (grainSize * 60) / 100;
}
void SasVoice::ReadSamples(s16 *output, int numSamples) {
// Read N samples into the resample buffer. Could do either PCM or VAG here.
switch (type) {

View file

@ -278,6 +278,7 @@ public:
void ClearGrainSize();
void SetGrainSize(int newGrainSize);
int GetGrainSize() const { return grainSize; }
int EstimateMixUs();
int maxVoices;
int sampleRate;