(Android) Build fixes/cleanups to frontend

This commit is contained in:
twinaphex 2014-06-13 01:10:14 +02:00
parent 86ee594b68
commit ddf0dcb165
7 changed files with 43 additions and 106 deletions

View File

@ -10,7 +10,6 @@ import java.io.IOException;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
@ -81,14 +80,11 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
{
prefs.edit().putBoolean("first_time_refreshrate_calculate", true).commit();
if (!detectDevice(false))
{
AlertDialog.Builder alert = new AlertDialog.Builder(ctx)
.setTitle(R.string.welcome_to_retroarch)
.setMessage(R.string.welcome_to_retroarch_desc)
.setPositiveButton(R.string.ok, null);
alert.show();
}
// First-run, so we show the GPL waiver agreement dialog.
GPLWaiverDialogFragment.newInstance().show(getFragmentManager(), "gplWaiver");
@ -203,84 +199,6 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
return version;
}
private boolean detectDevice(boolean show_dialog)
{
boolean retval = false;
final boolean mentionPlayStore = !Build.MODEL.equals("OUYA Console");
final int messageId = (mentionPlayStore ? R.string.detect_device_msg_general : R.string.detect_device_msg_ouya);
Log.i("Device MODEL", Build.MODEL);
if (Build.MODEL.equals("SHIELD"))
{
AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
alert.setTitle(R.string.nvidia_shield_detected);
alert.setMessage(messageId);
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
SharedPreferences prefs = UserPreferences.getPreferences(ctx);
SharedPreferences.Editor edit = prefs.edit();
edit.putString("video_refresh_rate", Double.toString(60.00d));
edit.commit();
UserPreferences.updateConfigFile(ctx);
}
});
alert.show();
retval = true;
}
else if (Build.MODEL.equals("R800x"))
{
AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
alert.setTitle(R.string.xperia_play_detected);
alert.setMessage(messageId);
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
SharedPreferences prefs = UserPreferences.getPreferences(ctx);
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean("video_threaded", false);
edit.putString("video_refresh_rate", Double.toString(59.19132938771038));
edit.commit();
UserPreferences.updateConfigFile(ctx);
}
});
alert.show();
retval = true;
}
else if (Build.ID.equals("JSS15J"))
{
AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
alert.setTitle(R.string.nexus_7_2013_detected);
alert.setMessage(messageId);
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
SharedPreferences prefs = UserPreferences.getPreferences(ctx);
SharedPreferences.Editor edit = prefs.edit();
edit.putString("video_refresh_rate", Double.toString(59.65));
edit.commit();
UserPreferences.updateConfigFile(ctx);
}
});
alert.show();
retval = true;
}
if (show_dialog)
{
Toast.makeText(ctx, R.string.no_optimal_settings, Toast.LENGTH_SHORT).show();
}
return retval;
}
@Override
public boolean onPreferenceClick(Preference preference)
{

View File

@ -3,9 +3,7 @@ package com.retroarch.browser.preferences.fragments;
import com.retroarch.R;
import com.retroarch.browser.preferences.fragments.util.PreferenceListFragment;
import android.os.Build;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
/**
* A {@link PreferenceListFragment} responsible for handling the audio preferences.

View File

@ -182,11 +182,7 @@ public final class UserPreferences
config.setBoolean("video_vsync", prefs.getBoolean("video_vsync", true));
config.setBoolean("input_autodetect_enable", prefs.getBoolean("input_autodetect_enable", true));
config.setBoolean("input_debug_enable", prefs.getBoolean("input_debug_enable", false));
// Set the video refresh rate.
config.setDouble("video_refresh_rate", getRefreshRate(ctx));
// Set whether or not we're using threaded video.
config.setBoolean("video_threaded", prefs.getBoolean("video_threaded", true));
// Refactor these weird values - 'full', 'auto', 'square', whatever -

View File

@ -125,9 +125,14 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency)
GOTO_IF_FAIL(SLEngineItf_CreateOutputMix(sl->engine, &sl->output_mix, 0, NULL, NULL));
GOTO_IF_FAIL(SLObjectItf_Realize(sl->output_mix, SL_BOOLEAN_FALSE));
//FIXME - come up with solution for this - we will need to get AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER
//through JNI - see commit for reference -
//https://github.com/libretro/RetroArch/commit/9ed3f3847c608b26c792c6dcbc3711ed946226b3
#if 0
if (g_settings.audio.block_frames)
sl->buf_size = g_settings.audio.block_frames * 4;
else
#endif
sl->buf_size = next_pow2(32 * latency);
sl->buf_count = (latency * 4 * rate + 500) / 1000;

View File

@ -416,7 +416,7 @@ static void frontend_android_get_name(char *name, size_t sizeof_name)
static void frontend_android_get_environment_settings(int *argc, char *argv[],
void *data, void *params_data)
{
char model_id[PROP_VALUE_MAX];
char device_model[PROP_VALUE_MAX], device_id[PROP_VALUE_MAX];
static char config_path[PATH_MAX];
static char core_path[PATH_MAX];
static char path[PATH_MAX];
@ -520,21 +520,31 @@ static void frontend_android_get_environment_settings(int *argc, char *argv[],
}
}
frontend_android_get_name(model_id, sizeof(model_id));
frontend_android_get_name(device_model, sizeof(device_model));
__system_property_get("ro.product.id", device_id);
// Set audio latency hint values per device (in case we need >64ms latency for good sound)
g_defaults.settings.video_threaded_enable = true;
if (!strcmp(model_id, "R800x"))
// Set automatic default values per device
if (!strcmp(device_model, "SHIELD")) { }
else if (!strcmp(device_model, "R800x"))
{
g_defaults.settings.out_latency = 128;
else if (!strcmp(model_id, "GAMEMID_BT"))
g_defaults.settings.video_refresh_rate = 59.19132938771038;
g_defaults.settings.video_threaded_enable = false;
}
else if (!strcmp(device_model, "GAMEMID_BT"))
{
g_defaults.settings.out_latency = 160;
}
else if (!strcmp(device_id, "JSS15J")) { }
// Explicitly disable input overlay by default for gamepad-like/console devices
if (
!strcmp(model_id, "OUYA Console") ||
!strcmp(model_id, "R800x") ||
!strcmp(model_id, "GAMEMID_BT") ||
!strcmp(model_id, "SHIELD")
!strcmp(device_model, "OUYA Console") ||
!strcmp(device_model, "R800x") ||
!strcmp(device_model, "GAMEMID_BT") ||
!strcmp(device_model, "SHIELD")
)
g_defaults.settings.input_overlay_enable = false;
else
@ -731,16 +741,16 @@ static void frontend_android_shutdown(bool unused)
static int frontend_android_get_rating(void)
{
char model_id[PROP_VALUE_MAX];
frontend_android_get_name(model_id, sizeof(model_id));
char device_model[PROP_VALUE_MAX];
frontend_android_get_name(device_model, sizeof(device_model));
RARCH_LOG("ro.product.model: (%s).\n", model_id);
RARCH_LOG("ro.product.model: (%s).\n", device_model);
if (!strcmp(model_id, "R800x"))
if (!strcmp(device_model, "R800x"))
return 6;
else if (!strcmp(model_id, "GT-I9505"))
else if (!strcmp(device_model, "GT-I9505"))
return 12;
else if (!strcmp(model_id, "SHIELD"))
else if (!strcmp(device_model, "SHIELD"))
return 13;
return -1;
}

View File

@ -142,6 +142,8 @@ struct defaults
struct
{
int out_latency;
float video_refresh_rate;
bool video_threaded_enable;
bool input_overlay_enable;
} settings;
};

View File

@ -279,6 +279,10 @@ void config_set_defaults(void)
g_settings.video.black_frame_insertion = black_frame_insertion;
g_settings.video.swap_interval = swap_interval;
g_settings.video.threaded = video_threaded;
if (g_defaults.settings.video_threaded_enable != video_threaded)
g_settings.video.threaded = g_defaults.settings.video_threaded_enable;
g_settings.video.shared_context = video_shared_context;
g_settings.video.smooth = video_smooth;
g_settings.video.force_aspect = force_aspect;
@ -300,6 +304,10 @@ void config_set_defaults(void)
g_settings.video.msg_color_b = ((message_color >> 0) & 0xff) / 255.0f;
g_settings.video.refresh_rate = refresh_rate;
if (g_defaults.settings.video_refresh_rate > 0.0 && g_defaults.settings.video_refresh_rate != refresh_rate)
g_settings.video.refresh_rate = g_defaults.settings.video_refresh_rate;
g_settings.video.post_filter_record = post_filter_record;
g_settings.video.gpu_record = gpu_record;
g_settings.video.gpu_screenshot = gpu_screenshot;