summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2023-01-29 11:10:45 +0100
committerbunnei <bunneidev@gmail.com>2023-06-03 09:05:29 +0200
commit39ab81a098a28a229b254f6ff82e0a02c9de5c81 (patch)
treedb19194f51a18d9b05cd2f24b9d0fd0ec7847089
parentandroid: SettingsFragmentPresenter: Fix default renderer backend. (diff)
downloadyuzu-39ab81a098a28a229b254f6ff82e0a02c9de5c81.tar
yuzu-39ab81a098a28a229b254f6ff82e0a02c9de5c81.tar.gz
yuzu-39ab81a098a28a229b254f6ff82e0a02c9de5c81.tar.bz2
yuzu-39ab81a098a28a229b254f6ff82e0a02c9de5c81.tar.lz
yuzu-39ab81a098a28a229b254f6ff82e0a02c9de5c81.tar.xz
yuzu-39ab81a098a28a229b254f6ff82e0a02c9de5c81.tar.zst
yuzu-39ab81a098a28a229b254f6ff82e0a02c9de5c81.zip
-rw-r--r--src/android/app/src/main/jni/native.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp
index e1b771468..f0df6cac1 100644
--- a/src/android/app/src/main/jni/native.cpp
+++ b/src/android/app/src/main/jni/native.cpp
@@ -96,8 +96,7 @@ public:
system.GetFileSystemController().CreateFactories(*system.GetFilesystem());
// Load the ROM.
- const Core::SystemResultStatus load_result{
- system.Load(EmulationSession::GetInstance().Window(), filepath)};
+ load_result = system.Load(EmulationSession::GetInstance().Window(), filepath);
if (load_result != Core::SystemResultStatus::Success) {
return load_result;
}
@@ -113,13 +112,18 @@ public:
void ShutdownEmulation() {
std::scoped_lock lock(mutex);
+ is_running = false;
+
// Unload user input.
system.HIDCore().UnloadInputDevices();
// Shutdown the main emulated process
- system.DetachDebugger();
- system.ShutdownMainProcess();
- detached_tasks.WaitForAllTasks();
+ if (load_result == Core::SystemResultStatus::Success) {
+ system.DetachDebugger();
+ system.ShutdownMainProcess();
+ detached_tasks.WaitForAllTasks();
+ load_result = Core::SystemResultStatus::ErrorNotInitialized;
+ }
// Tear down the render window.
window.reset();
@@ -174,6 +178,7 @@ private:
std::unique_ptr<EmuWindow_Android> window;
std::condition_variable_any cv;
bool is_running{};
+ Core::SystemResultStatus load_result{Core::SystemResultStatus::ErrorNotInitialized};
mutable std::mutex perf_stats_mutex;
mutable std::mutex mutex;
@@ -217,13 +222,14 @@ static Core::SystemResultStatus RunEmulation(const std::string& filepath) {
return Core::SystemResultStatus::ErrorLoader;
}
+ SCOPE_EXIT({ EmulationSession::GetInstance().ShutdownEmulation(); });
+
const auto result = EmulationSession::GetInstance().InitializeEmulation(filepath);
if (result != Core::SystemResultStatus::Success) {
return result;
}
EmulationSession::GetInstance().RunEmulation();
- EmulationSession::GetInstance().ShutdownEmulation();
return Core::SystemResultStatus::Success;
}