android: jni: Ensure system is only initialized once.

- Fixes likelihood that fastmem allocation succeeds.
This commit is contained in:
bunnei 2023-02-20 03:19:51 -08:00
parent ff2f370946
commit 0276197744
4 changed files with 8 additions and 8 deletions

View File

@ -185,8 +185,7 @@ public final class NativeLibrary {
public static native boolean ReloadKeys(); public static native boolean ReloadKeys();
// Create the config.ini file. public static native void InitializeEmulation();
public static native void CreateConfigFile();
public static native int DefaultCPUCore(); public static native int DefaultCPUCore();

View File

@ -27,7 +27,7 @@ public final class DirectoryInitialization {
if (directoryState != DirectoryInitializationState.YUZU_DIRECTORIES_INITIALIZED) { if (directoryState != DirectoryInitializationState.YUZU_DIRECTORIES_INITIALIZED) {
initializeInternalStorage(context); initializeInternalStorage(context);
NativeLibrary.CreateConfigFile(); NativeLibrary.InitializeEmulation();
directoryState = DirectoryInitializationState.YUZU_DIRECTORIES_INITIALIZED; directoryState = DirectoryInitializationState.YUZU_DIRECTORIES_INITIALIZED;
} }

View File

@ -40,7 +40,6 @@ namespace {
class EmulationSession final { class EmulationSession final {
public: public:
EmulationSession() { EmulationSession() {
m_system.Initialize();
m_vfs = std::make_shared<FileSys::RealVfsFilesystem>(); m_vfs = std::make_shared<FileSys::RealVfsFilesystem>();
} }
@ -126,7 +125,6 @@ public:
// Initialize system. // Initialize system.
m_system.SetShuttingDown(false); m_system.SetShuttingDown(false);
m_system.Initialize();
m_system.ApplySettings(); m_system.ApplySettings();
m_system.HIDCore().ReloadInputDevices(); m_system.HIDCore().ReloadInputDevices();
m_system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>()); m_system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>());
@ -498,9 +496,12 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_GetGitRevision([[maybe_unused]] JN
return {}; return {};
} }
void Java_org_yuzu_yuzu_1emu_NativeLibrary_CreateConfigFile void Java_org_yuzu_yuzu_1emu_NativeLibrary_InitializeEmulation
[[maybe_unused]] (JNIEnv* env, [[maybe_unused]] jclass clazz) { [[maybe_unused]] (JNIEnv* env, [[maybe_unused]] jclass clazz) {
// Create the default config.ini.
Config{}; Config{};
// Initialize the emulated system.
EmulationSession::GetInstance().System().Initialize();
} }
jint Java_org_yuzu_yuzu_1emu_NativeLibrary_DefaultCPUCore([[maybe_unused]] JNIEnv* env, jint Java_org_yuzu_yuzu_1emu_NativeLibrary_DefaultCPUCore([[maybe_unused]] JNIEnv* env,

View File

@ -86,7 +86,7 @@ JNIEXPORT void JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_SetSysDirectory(JNI
jclass clazz, jclass clazz,
jstring path); jstring path);
JNIEXPORT void JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_CreateConfigFile(JNIEnv* env, JNIEXPORT void JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_InitializeEmulation(JNIEnv* env,
jclass clazz); jclass clazz);
JNIEXPORT jint JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_DefaultCPUCore(JNIEnv* env, JNIEXPORT jint JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_DefaultCPUCore(JNIEnv* env,