Walk a pointer when enqueuing audio.

Profiler says this will give ~0.5% perf improvement.
This commit is contained in:
Unknown W. Brackets 2013-01-27 13:40:57 -08:00
parent 1b75e7f5c8
commit bf80de9e8d
2 changed files with 19 additions and 2 deletions

View File

@ -128,9 +128,23 @@ u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking)
}
if (chan.format == PSP_AUDIO_FORMAT_STEREO)
{
for (u32 i = 0; i < chan.sampleCount * 2; i++)
const u32 totalSamples = chan.sampleCount * 2;
if (IS_LITTLE_ENDIAN)
{
chan.sampleQueue.push((s16)Memory::Read_U16(chan.sampleAddress + 2 * i));
s16 *sampleData = (s16 *) Memory::GetPointer(chan.sampleAddress);
// Walking a pointer for speed. But let's make sure we wouldn't trip on an invalid ptr.
if (Memory::IsValidAddress(chan.sampleAddress + (totalSamples - 1) * sizeof(s16)))
{
for (u32 i = 0; i < totalSamples; i++)
chan.sampleQueue.push(*sampleData++);
}
}
else
{
for (u32 i = 0; i < totalSamples; i++)
chan.sampleQueue.push((s16)Memory::Read_U16(chan.sampleAddress + sizeof(s16) * i));
}
}
else if (chan.format == PSP_AUDIO_FORMAT_MONO)

View File

@ -26,6 +26,9 @@
#include "CommonTypes.h"
#define IS_LITTLE_ENDIAN (*(const u16 *)"\0\xff" >= 0x100)
#define IS_BIG_ENDIAN (*(const u16 *)"\0\xff" < 0x100)
#ifndef _WIN32
inline u32 _byteswap_ulong(u32 data)