mirror of
https://github.com/libretro/RetroArch
synced 2025-02-21 09:39:56 +00:00
(Android) More elegant way of setting refresh rate
This commit is contained in:
parent
4617f02aaf
commit
1cae4de653
@ -24,7 +24,6 @@ struct droid
|
||||
{
|
||||
struct android_app* app;
|
||||
bool window_ready;
|
||||
float disp_refresh_rate;
|
||||
char current_ime[PATH_MAX];
|
||||
};
|
||||
|
||||
|
@ -242,8 +242,6 @@ static void jni_get(struct jni_params *in_params, struct jni_out_params_char *ou
|
||||
}
|
||||
}
|
||||
|
||||
static float refreshrate;
|
||||
|
||||
static int android_app_set_argv(char** argv)
|
||||
{
|
||||
char rom_path[PATH_MAX];
|
||||
@ -275,14 +273,6 @@ static int android_app_set_argv(char** argv)
|
||||
strlcpy(out_args.in, "LIBRETRO", sizeof(out_args.in));
|
||||
jni_get(&in_params, &out_args);
|
||||
|
||||
// Refresh rate
|
||||
char refreshrate_char[128];
|
||||
out_args.out = refreshrate_char;
|
||||
out_args.out_sizeof = sizeof(refreshrate_char);
|
||||
strlcpy(out_args.in, "REFRESHRATE", sizeof(out_args.in));
|
||||
jni_get(&in_params, &out_args);
|
||||
refreshrate = (float)strtod(refreshrate_char, NULL);
|
||||
|
||||
// Config file
|
||||
out_args.out = config_file;
|
||||
out_args.out_sizeof = sizeof(config_file);
|
||||
@ -301,7 +291,6 @@ static int android_app_set_argv(char** argv)
|
||||
RARCH_LOG("Checking arguments passed ...\n");
|
||||
RARCH_LOG("ROM Filename: [%s].\n", rom_path);
|
||||
RARCH_LOG("Libretro path: [%s].\n", libretro_path);
|
||||
RARCH_LOG("Display Refresh rate: %.2f Hz.\n", refreshrate);
|
||||
RARCH_LOG("Config file: [%s].\n", config_file);
|
||||
RARCH_LOG("Current IME: [%s].\n", g_android.current_ime);
|
||||
|
||||
@ -351,18 +340,6 @@ static void* android_app_entry(void* param)
|
||||
|
||||
g_extern.verbose = true;
|
||||
|
||||
bool disp_refresh_read = refreshrate > 0.0f;
|
||||
g_android.disp_refresh_rate = refresh_rate;
|
||||
if (disp_refresh_read)
|
||||
{
|
||||
if (refreshrate < refresh_rate)
|
||||
{
|
||||
RARCH_WARN("Display refresh rate of your device is likely lower than 60Hz.\n");
|
||||
g_android.disp_refresh_rate = refreshrate;
|
||||
}
|
||||
}
|
||||
|
||||
RARCH_LOG("Setting RetroArch video refresh rate to: %.2fHz.\n", g_android.disp_refresh_rate);
|
||||
|
||||
while (!g_android.window_ready)
|
||||
{
|
||||
@ -379,7 +356,6 @@ static void* android_app_entry(void* param)
|
||||
{
|
||||
RARCH_LOG("RetroArch started.\n");
|
||||
rarch_init_msg_queue();
|
||||
driver_set_monitor_refresh_rate(g_android.disp_refresh_rate);
|
||||
|
||||
while ((input_key_pressed_func(RARCH_PAUSE_TOGGLE)) ?
|
||||
android_run_events(g_android.app) :
|
||||
|
@ -20,16 +20,16 @@
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen android:title="Video Settings" >
|
||||
<PreferenceCategory android:title="General" >
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="video_smooth"
|
||||
android:summary="Applies bilinear filter, smooths out edges."
|
||||
android:title="Bilinear filter" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="video_vsync"
|
||||
android:summary="When set to enabled, prevents screen tearing."
|
||||
android:title="VSync" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="video_sync_refreshrate_to_screen"
|
||||
android:summary="Synchronize RetroArch's refresh rate to the screen's refresh rate (recommended - some screens have refresh rates below 59.95Hz and need this enabled to get good audio/video sync)."
|
||||
android:title="Sync refreshrate to screen" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="video_allow_rotate"
|
||||
@ -44,6 +44,11 @@
|
||||
android:title="Aspect ratio" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="Shaders (1st pass)" >
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="video_smooth"
|
||||
android:summary="Applies Bilinear filtering, smooths out edges (settings still apply even if no shader is selected)."
|
||||
android:title="Bilinear filter" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="video_shader_enable"
|
||||
@ -88,8 +93,8 @@
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="video_second_pass_smooth"
|
||||
android:summary="Use bilinear filtering on FBO texture on second pass."
|
||||
android:title="Second pass bilinear" />
|
||||
android:summary="Use Bilinear filtering on FBO texture on second pass."
|
||||
android:title="Second pass Bilinear Filtering" />
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen android:title="Audio Settings" >
|
||||
<PreferenceCategory android:title="Audio" >
|
||||
|
@ -52,10 +52,10 @@ public class RetroArch extends Activity implements
|
||||
static private final String TAG = "RetroArch-Phoenix";
|
||||
private ConfigFile config;
|
||||
|
||||
public float getRefreshRate() {
|
||||
private final double getRefreshRate() {
|
||||
final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
|
||||
final Display display = wm.getDefaultDisplay();
|
||||
float rate = display.getRefreshRate();
|
||||
double rate = display.getRefreshRate();
|
||||
return rate;
|
||||
}
|
||||
|
||||
@ -199,6 +199,18 @@ public class RetroArch extends Activity implements
|
||||
config.setBoolean("video_vsync", prefs.getBoolean("video_vsync", true));
|
||||
config.setBoolean("input_autodetect_enable", prefs.getBoolean("input_autodetect_enable", true));
|
||||
|
||||
if (prefs.getBoolean("video_sync_refreshrate_to_screen", true) &&
|
||||
(getRefreshRate() < 59.95))
|
||||
{
|
||||
Log.e(TAG, "Refresh rate of screen lower than 59.95Hz, adjusting to screen.");
|
||||
config.setDouble("video_refresh_rate", getRefreshRate());
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.e(TAG, "Refresh rate set to 59.95Hz (default).");
|
||||
config.setDouble("video_refresh_rate", 59.95);
|
||||
}
|
||||
|
||||
String aspect = prefs.getString("video_aspect_ratio", "auto");
|
||||
if (aspect.equals("full")) {
|
||||
config.setBoolean("video_force_aspect", false);
|
||||
@ -266,8 +278,6 @@ public class RetroArch extends Activity implements
|
||||
myIntent = new Intent(this, NativeActivity.class);
|
||||
myIntent.putExtra("ROM", data.getStringExtra("PATH"));
|
||||
myIntent.putExtra("LIBRETRO", libretro_path);
|
||||
myIntent.putExtra("REFRESHRATE",
|
||||
Float.toString(getRefreshRate()));
|
||||
myIntent.putExtra("CONFIGFILE", getDefaultConfigPath());
|
||||
myIntent.putExtra("IME", current_ime);
|
||||
startActivity(myIntent);
|
||||
|
2
driver.c
2
driver.c
@ -245,12 +245,14 @@ static void adjust_system_rates(void)
|
||||
|
||||
void driver_set_monitor_refresh_rate(float hz)
|
||||
{
|
||||
RARCH_LOG("Setting refresh rate to: %.2fHz.\n", hz);
|
||||
g_settings.video.refresh_rate = hz;
|
||||
adjust_system_rates();
|
||||
|
||||
g_extern.audio_data.orig_src_ratio =
|
||||
g_extern.audio_data.src_ratio =
|
||||
(double)g_settings.audio.out_rate / g_settings.audio.in_rate;
|
||||
|
||||
}
|
||||
|
||||
void init_drivers(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user