mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-22 08:44:51 +00:00
iOS: Reduce CPU consumption for audio, adjust sync.
Still is clicking...
This commit is contained in:
parent
947f838165
commit
e8ac8d49b6
@ -273,5 +273,5 @@ int __AudioMix(short *outstereo, int numFrames)
|
||||
// DEBUG_LOG(HLE, "No underrun, mixed %i samples fine", numFrames);
|
||||
}
|
||||
section.unlock();
|
||||
return numFrames;
|
||||
return underrun;
|
||||
}
|
||||
|
@ -149,6 +149,13 @@ void NativeMix(short *audio, int num_samples)
|
||||
}
|
||||
}
|
||||
|
||||
int NativeMixCount(short *audio, int num_samples)
|
||||
{
|
||||
if (g_mixer)
|
||||
return g_mixer->Mix(audio, num_samples);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NativeGetAppInfo(std::string *app_dir_name, std::string *app_nice_name, bool *landscape)
|
||||
{
|
||||
*app_nice_name = "PPSSPP";
|
||||
|
@ -16,10 +16,10 @@
|
||||
|
||||
static volatile BOOL done = 0;
|
||||
|
||||
#define SAMPLE_SIZE 44100/6
|
||||
#define SAMPLE_SIZE 44100
|
||||
static short stream[SAMPLE_SIZE];
|
||||
|
||||
void NativeMix(short *audio, int num_samples);
|
||||
int NativeMixCount(short *audio, int num_samples);
|
||||
|
||||
@interface AudioEngine ()
|
||||
|
||||
@ -122,15 +122,26 @@ void NativeMix(short *audio, int num_samples);
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
|
||||
while (!done)
|
||||
{
|
||||
size_t frames_ready;
|
||||
if (![self playing])
|
||||
frames_ready = NativeMixCount(stream, SAMPLE_SIZE / 2);
|
||||
else
|
||||
frames_ready = 0;
|
||||
|
||||
if (frames_ready > 0)
|
||||
{
|
||||
NativeMix(stream, SAMPLE_SIZE/2);
|
||||
|
||||
const size_t bytes_ready = frames_ready * sizeof(short) * 2;
|
||||
alSourcei(source, AL_BUFFER, 0);
|
||||
alBufferData(buffer, AL_FORMAT_STEREO16, stream, SAMPLE_SIZE, 44100);
|
||||
alBufferData(buffer, AL_FORMAT_STEREO16, stream, bytes_ready, 44100);
|
||||
alSourcei(source, AL_BUFFER, buffer);
|
||||
alSourcePlay(source);
|
||||
|
||||
// TODO: Maybe this could get behind?
|
||||
usleep((1000000 * frames_ready) / 44100);
|
||||
}
|
||||
else
|
||||
usleep(100);
|
||||
pthread_yield_np();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user