mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-27 05:24:23 +01:00
android: Harden emulation shutdown when loader fails.
This commit is contained in:
parent
e12e1efa40
commit
39ab81a098
@ -96,8 +96,7 @@ public:
|
|||||||
system.GetFileSystemController().CreateFactories(*system.GetFilesystem());
|
system.GetFileSystemController().CreateFactories(*system.GetFilesystem());
|
||||||
|
|
||||||
// Load the ROM.
|
// Load the ROM.
|
||||||
const Core::SystemResultStatus load_result{
|
load_result = system.Load(EmulationSession::GetInstance().Window(), filepath);
|
||||||
system.Load(EmulationSession::GetInstance().Window(), filepath)};
|
|
||||||
if (load_result != Core::SystemResultStatus::Success) {
|
if (load_result != Core::SystemResultStatus::Success) {
|
||||||
return load_result;
|
return load_result;
|
||||||
}
|
}
|
||||||
@ -113,13 +112,18 @@ public:
|
|||||||
void ShutdownEmulation() {
|
void ShutdownEmulation() {
|
||||||
std::scoped_lock lock(mutex);
|
std::scoped_lock lock(mutex);
|
||||||
|
|
||||||
|
is_running = false;
|
||||||
|
|
||||||
// Unload user input.
|
// Unload user input.
|
||||||
system.HIDCore().UnloadInputDevices();
|
system.HIDCore().UnloadInputDevices();
|
||||||
|
|
||||||
// Shutdown the main emulated process
|
// Shutdown the main emulated process
|
||||||
|
if (load_result == Core::SystemResultStatus::Success) {
|
||||||
system.DetachDebugger();
|
system.DetachDebugger();
|
||||||
system.ShutdownMainProcess();
|
system.ShutdownMainProcess();
|
||||||
detached_tasks.WaitForAllTasks();
|
detached_tasks.WaitForAllTasks();
|
||||||
|
load_result = Core::SystemResultStatus::ErrorNotInitialized;
|
||||||
|
}
|
||||||
|
|
||||||
// Tear down the render window.
|
// Tear down the render window.
|
||||||
window.reset();
|
window.reset();
|
||||||
@ -174,6 +178,7 @@ private:
|
|||||||
std::unique_ptr<EmuWindow_Android> window;
|
std::unique_ptr<EmuWindow_Android> window;
|
||||||
std::condition_variable_any cv;
|
std::condition_variable_any cv;
|
||||||
bool is_running{};
|
bool is_running{};
|
||||||
|
Core::SystemResultStatus load_result{Core::SystemResultStatus::ErrorNotInitialized};
|
||||||
|
|
||||||
mutable std::mutex perf_stats_mutex;
|
mutable std::mutex perf_stats_mutex;
|
||||||
mutable std::mutex mutex;
|
mutable std::mutex mutex;
|
||||||
@ -217,13 +222,14 @@ static Core::SystemResultStatus RunEmulation(const std::string& filepath) {
|
|||||||
return Core::SystemResultStatus::ErrorLoader;
|
return Core::SystemResultStatus::ErrorLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCOPE_EXIT({ EmulationSession::GetInstance().ShutdownEmulation(); });
|
||||||
|
|
||||||
const auto result = EmulationSession::GetInstance().InitializeEmulation(filepath);
|
const auto result = EmulationSession::GetInstance().InitializeEmulation(filepath);
|
||||||
if (result != Core::SystemResultStatus::Success) {
|
if (result != Core::SystemResultStatus::Success) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmulationSession::GetInstance().RunEmulation();
|
EmulationSession::GetInstance().RunEmulation();
|
||||||
EmulationSession::GetInstance().ShutdownEmulation();
|
|
||||||
|
|
||||||
return Core::SystemResultStatus::Success;
|
return Core::SystemResultStatus::Success;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user