Permalink
Browse files

audio: reduced the aggresiveness of audio speed changes.

  • Loading branch information...
fzurita committed Feb 21, 2016
1 parent b0516d2 commit 0127dc3c80cd60c8a79b66c7c74c4d3a81c78017
Showing with 14 additions and 4 deletions.
  1. +14 −4 jni/mupen64plus-audio-sles/main.c
@@ -867,6 +867,7 @@ void* audioConsumer(void* param)
//Sound queue ran dry, device is running slow
int ranDry = 0;
+ const int ranDryTakeAction = 20;
//adjustment used when a device running too slow
int slowAdjustment = 0;
@@ -881,7 +882,14 @@ void* audioConsumer(void* param)
waitTime.tv_sec = 1;
waitTime.tv_nsec = 0;
- ranDry = thread_queue_length(&audioConsumerQueue) == 0;
+ if(thread_queue_length(&audioConsumerQueue) == 0)
+ {
+ ++ranDry;
+ }
+ else
+ {
+ ranDry = 0;
+ }
struct threadmsg msg;
int result = thread_queue_get(&audioConsumerQueue, &waitTime, &msg);
@@ -920,15 +928,17 @@ void* audioConsumer(void* param)
}
}
// Oh no! game is going too slow now, speed it up
- else if(ranDry && matchGameToAudioOffset > 0)
+ else if(ranDry > ranDryTakeAction && matchGameToAudioOffset > 0)
{
+ ranDry = 0;
--matchGameToAudioOffset;
desiredGameSpeed = fullSpeed - matchGameToAudioOffset;
CoreDoCommand(M64CMD_CORE_STATE_SET, M64CORE_SPEED_FACTOR, &desiredGameSpeed);
}
//Device can't keep up with the game, slow audio down
- else if(ranDry)
+ else if(ranDry > ranDryTakeAction)
{
+ ranDry = 0;
currentPeriod++;
//Don't adjust it too quickly, it sounds bad
@@ -1098,7 +1108,7 @@ EXPORT void CALL SetSpeedFactor(int percentage)
}
//We don't want to snap ourselves out of this mode
- if(matchGameToAudio && (percentage > 115 || percentage < 85))
+ if(matchGameToAudio && percentage > 100)
{
matchGameToAudio = 0;
}

0 comments on commit 0127dc3

Please sign in to comment.