From 5ac09397316b7bcf0c260f5154cfd6959fad4765 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 6 Sep 2022 20:21:53 -0500 Subject: [PATCH] Don't reduce refresh rate by default in balanced mode --- app/src/main/java/com/limelight/Game.java | 13 +++++++++---- .../preferences/PreferenceConfiguration.java | 4 ++++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/preferences.xml | 5 +++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index 575986cd..c5ce7f87 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -719,6 +719,12 @@ public class Game extends Activity implements SurfaceHolder.Callback, return false; } + private boolean mayReduceRefreshRate() { + return prefConfig.framePacing == PreferenceConfiguration.FRAME_PACING_CAP_FPS || + prefConfig.framePacing == PreferenceConfiguration.FRAME_PACING_MAX_SMOOTHNESS || + (prefConfig.framePacing == PreferenceConfiguration.FRAME_PACING_BALANCED && prefConfig.reduceRefreshRate); + } + private float prepareDisplayForRendering() { Display display = getWindowManager().getDefaultDisplay(); WindowManager.LayoutParams windowLayoutParams = getWindow().getAttributes(); @@ -763,8 +769,7 @@ public class Game extends Activity implements SurfaceHolder.Callback, continue; } - if (prefConfig.framePacing != PreferenceConfiguration.FRAME_PACING_MIN_LATENCY && - refreshRateIsEqual && !isRefreshRateEqualMatch(candidate.getRefreshRate())) { + if (mayReduceRefreshRate() && refreshRateIsEqual && !isRefreshRateEqualMatch(candidate.getRefreshRate())) { // If we had an equal refresh rate and this one is not, skip it. In min latency // mode, we want to always prefer the highest frame rate even though it may cause // microstuttering. @@ -778,9 +783,9 @@ public class Game extends Activity implements SurfaceHolder.Callback, } // We don't want ever reduce our refresh rate unless we found an exact - // match and we're not in min latency mode. + // match and refresh rate reduction is allowed by user preferences if (refreshRateReduced) { - if (prefConfig.framePacing == PreferenceConfiguration.FRAME_PACING_MIN_LATENCY) { + if (!mayReduceRefreshRate()) { continue; } else if (!isRefreshRateEqualMatch(candidate.getRefreshRate())) { diff --git a/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java b/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java index f19592e0..4a7e4deb 100644 --- a/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java +++ b/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java @@ -46,6 +46,7 @@ public class PreferenceConfiguration { private static final String FRAME_PACING_PREF_STRING = "frame_pacing"; private static final String ABSOLUTE_MOUSE_MODE_PREF_STRING = "checkbox_absolute_mouse_mode"; private static final String ENABLE_AUDIO_FX_PREF_STRING = "checkbox_enable_audiofx"; + private static final String REDUCE_REFRESH_RATE_PREF_STRING = "checkbox_reduce_refresh_rate"; static final String DEFAULT_RESOLUTION = "1280x720"; static final String DEFAULT_FPS = "60"; @@ -77,6 +78,7 @@ public class PreferenceConfiguration { private static final String DEFAULT_FRAME_PACING = "latency"; private static final boolean DEFAULT_ABSOLUTE_MOUSE_MODE = false; private static final boolean DEFAULT_ENABLE_AUDIO_FX = false; + private static final boolean DEFAULT_REDUCE_REFRESH_RATE = false; public static final int FORCE_H265_ON = -1; public static final int AUTOSELECT_H265 = 0; @@ -120,6 +122,7 @@ public class PreferenceConfiguration { public int framePacing; public boolean absoluteMouseMode; public boolean enableAudioFx; + public boolean reduceRefreshRate; public static boolean isNativeResolution(int width, int height) { // It's not a native resolution if it matches an existing resolution option @@ -475,6 +478,7 @@ public class PreferenceConfiguration { config.enableLatencyToast = prefs.getBoolean(LATENCY_TOAST_PREF_STRING, DEFAULT_LATENCY_TOAST); config.absoluteMouseMode = prefs.getBoolean(ABSOLUTE_MOUSE_MODE_PREF_STRING, DEFAULT_ABSOLUTE_MOUSE_MODE); config.enableAudioFx = prefs.getBoolean(ENABLE_AUDIO_FX_PREF_STRING, DEFAULT_ENABLE_AUDIO_FX); + config.reduceRefreshRate = prefs.getBoolean(REDUCE_REFRESH_RATE_PREF_STRING, DEFAULT_REDUCE_REFRESH_RATE); return config; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1fb47e5b..ed1827bd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -216,6 +216,8 @@ Advanced Settings Unlock all possible frame rates Streaming at 90 or 120 FPS may reduce latency on high-end devices but can cause lag or instability on devices that can\'t support it + Allow refresh rate reduction + Lower display refresh rates can save power at the expense of some additional video latency Disable warning messages Disable on-screen connection warning messages while streaming Never drop frames diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 1add66f0..82424008 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -189,6 +189,11 @@ android:title="@string/title_unlock_fps" android:summary="@string/summary_unlock_fps" android:defaultValue="false" /> +