Skip to content

Commit

Permalink
core: use busywait instead of sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
fzurita committed Jan 24, 2016
1 parent ae0c334 commit eb24230
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion jni/mupen64plus-core/src/main/main.c
Expand Up @@ -774,7 +774,12 @@ static void apply_speed_limiter(void)
{ {
TimeToWait = (IntegratedDelta > ThisFrameDelta) ? -IntegratedDelta : -ThisFrameDelta; TimeToWait = (IntegratedDelta > ThisFrameDelta) ? -IntegratedDelta : -ThisFrameDelta;
DebugMessage(M64MSG_VERBOSE, " apply_speed_limiter(): Waiting %ims", (int) TimeToWait); DebugMessage(M64MSG_VERBOSE, " apply_speed_limiter(): Waiting %ims", (int) TimeToWait);
SDL_Delay((int) TimeToWait); //SDL_Delay((int) TimeToWait);

int StartTime = SDL_GetTicks();
int EndTime = StartTime + TimeToWait;
while(SDL_GetTicks() <= EndTime);

This comment has been minimized.

Copy link
@fzurita

fzurita Jan 25, 2016

Author Member

@Gillou68310 Do you think this is something that upstream would take as an optional setting?

There are a lot of times where the core is not taking enough CPU or the CPU utilization is kind of strange. This results in a lot of newer ARM devices underclocking their CPUs which causes slow downs in games.

A busy wait, however battery inefficient it is, seem to fix this situation.

Are you aware of any better way to prevent an android device from underclocking?

I have already tried setting higher thread priority and using a wake lock. Making thread priority high did seem to fix some hiccups I was seeing, at least in my phone. Wake lock seemed to have no effect.

This comment has been minimized.

Copy link
@Gillou68310

Gillou68310 Jan 27, 2016

I would rather add such hack in the SDL library as it's maintained downstream. Also I think this should be configurable in order to let the user choose between battery life and performance.

This comment has been minimized.

Copy link
@Gillou68310

Gillou68310 Jan 27, 2016

Wake lock seemed to have no effect.

Maybe this should be reverted then : ae0c334

Also don't hesitate to remove branches that have been merged already ;-).


// recalculate # of milliseconds that have passed since the last video interrupt, // recalculate # of milliseconds that have passed since the last video interrupt,
// taking into account the time we just waited // taking into account the time we just waited
CurrentFPSTime = SDL_GetTicks(); CurrentFPSTime = SDL_GetTicks();
Expand Down

0 comments on commit eb24230

Please sign in to comment.