mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Walk a pointer when enqueuing audio.
Profiler says this will give ~0.5% perf improvement.
This commit is contained in:
parent
1b75e7f5c8
commit
bf80de9e8d
2 changed files with 19 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue