Update config variable and sanitize input.

This commit is contained in:
Brandon Wright 2017-11-24 13:03:24 -06:00
parent 618519457b
commit 1369d724f7
4 changed files with 6 additions and 5 deletions

View File

@ -475,7 +475,7 @@ void S9xSetSamplesAvailableCallback (apu_callback callback, void *data)
void S9xUpdateDynamicRate (int avail, int buffer_size)
{
spc::dynamic_rate_multiplier = 1.0 + ((int) Settings.DynamicRateLimit * (buffer_size - 2 * avail)) /
spc::dynamic_rate_multiplier = 1.0 + (Settings.DynamicRateLimit * (buffer_size - 2 * avail)) /
(double)(1000 * buffer_size);
UpdatePlaybackRate();

View File

@ -253,8 +253,8 @@ Snes9xConfig::load_defaults (void)
Settings.FrameTime = Settings.FrameTimeNTSC;
Settings.BlockInvalidVRAMAccessMaster = TRUE;
Settings.SoundSync = 1;
Settings.DynamicRateControl = 0;
Settings.DynamicRateLimit = 1000;
Settings.DynamicRateControl = 1;
Settings.DynamicRateLimit = 5;
Settings.HDMATimingHack = 100;
Settings.ApplyCheats = 1;
@ -675,6 +675,7 @@ Snes9xConfig::set_option (const char *name, const char *value)
else if (!strcasecmp (name, "dynamic_rate_limit"))
{
Settings.DynamicRateLimit = atoi (value);
Settings.DynamicRateLimit = CLAMP (Settings.DynamicRateLimit, 1, 1000);
}
else if (!strcasecmp (name, "gaussian_interpolation"))
{

View File

@ -423,7 +423,7 @@ void S9xLoadConfigFiles (char **argv, int argc)
Settings.SoundInputRate = conf.GetUInt("Sound::InputRate", 32000);
Settings.Mute = conf.GetBool("Sound::Mute", false);
Settings.DynamicRateControl = conf.GetBool("Sound::DynamicRateControl", false);
Settings.DynamicRateLimit = conf.GetUInt("Sound::DynamicRateLimit", 1000);
Settings.DynamicRateLimit = conf.GetInt ("Sound::DynamicRateLimit", 5);
// Display

View File

@ -408,7 +408,7 @@ struct SSettings
bool8 ReverseStereo;
bool8 Mute;
bool8 DynamicRateControl;
uint32 DynamicRateLimit; /* Multiplied by 1000 */
int32 DynamicRateLimit; /* Multiplied by 1000 */
bool8 SupportHiRes;
bool8 Transparency;