am: shorten shutdown timeout when lock is not held

This commit is contained in:
Liam 2023-08-26 17:12:05 -04:00
parent bc4e58eb51
commit b7523d6fa7
4 changed files with 41 additions and 13 deletions

View File

@ -273,7 +273,8 @@ struct System::Impl {
time_manager.Initialize(); time_manager.Initialize();
is_powered_on = true; is_powered_on = true;
exit_lock = false; exit_locked = false;
exit_requested = false;
microprofile_cpu[0] = MICROPROFILE_TOKEN(ARM_CPU0); microprofile_cpu[0] = MICROPROFILE_TOKEN(ARM_CPU0);
microprofile_cpu[1] = MICROPROFILE_TOKEN(ARM_CPU1); microprofile_cpu[1] = MICROPROFILE_TOKEN(ARM_CPU1);
@ -398,7 +399,8 @@ struct System::Impl {
} }
is_powered_on = false; is_powered_on = false;
exit_lock = false; exit_locked = false;
exit_requested = false;
if (gpu_core != nullptr) { if (gpu_core != nullptr) {
gpu_core->NotifyShutdown(); gpu_core->NotifyShutdown();
@ -507,7 +509,8 @@ struct System::Impl {
CpuManager cpu_manager; CpuManager cpu_manager;
std::atomic_bool is_powered_on{}; std::atomic_bool is_powered_on{};
bool exit_lock = false; bool exit_locked = false;
bool exit_requested = false;
bool nvdec_active{}; bool nvdec_active{};
@ -943,12 +946,20 @@ const Service::Time::TimeManager& System::GetTimeManager() const {
return impl->time_manager; return impl->time_manager;
} }
void System::SetExitLock(bool locked) { void System::SetExitLocked(bool locked) {
impl->exit_lock = locked; impl->exit_locked = locked;
} }
bool System::GetExitLock() const { bool System::GetExitLocked() const {
return impl->exit_lock; return impl->exit_locked;
}
void System::SetExitRequested(bool requested) {
impl->exit_requested = requested;
}
bool System::GetExitRequested() const {
return impl->exit_requested;
} }
void System::SetApplicationProcessBuildID(const CurrentBuildProcessID& id) { void System::SetApplicationProcessBuildID(const CurrentBuildProcessID& id) {

View File

@ -412,8 +412,11 @@ public:
/// Gets an immutable reference to the Room Network. /// Gets an immutable reference to the Room Network.
[[nodiscard]] const Network::RoomNetwork& GetRoomNetwork() const; [[nodiscard]] const Network::RoomNetwork& GetRoomNetwork() const;
void SetExitLock(bool locked); void SetExitLocked(bool locked);
[[nodiscard]] bool GetExitLock() const; bool GetExitLocked() const;
void SetExitRequested(bool requested);
bool GetExitRequested() const;
void SetApplicationProcessBuildID(const CurrentBuildProcessID& id); void SetApplicationProcessBuildID(const CurrentBuildProcessID& id);
[[nodiscard]] const CurrentBuildProcessID& GetApplicationProcessBuildID() const; [[nodiscard]] const CurrentBuildProcessID& GetApplicationProcessBuildID() const;

View File

@ -340,7 +340,7 @@ void ISelfController::Exit(HLERequestContext& ctx) {
void ISelfController::LockExit(HLERequestContext& ctx) { void ISelfController::LockExit(HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called"); LOG_DEBUG(Service_AM, "called");
system.SetExitLock(true); system.SetExitLocked(true);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
@ -349,10 +349,14 @@ void ISelfController::LockExit(HLERequestContext& ctx) {
void ISelfController::UnlockExit(HLERequestContext& ctx) { void ISelfController::UnlockExit(HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called"); LOG_DEBUG(Service_AM, "called");
system.SetExitLock(false); system.SetExitLocked(false);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
if (system.GetExitRequested()) {
system.Exit();
}
} }
void ISelfController::EnterFatalSection(HLERequestContext& ctx) { void ISelfController::EnterFatalSection(HLERequestContext& ctx) {

View File

@ -2010,8 +2010,16 @@ bool GMainWindow::OnShutdownBegin() {
emit EmulationStopping(); emit EmulationStopping();
int shutdown_time = 1000;
if (system->DebuggerEnabled()) {
shutdown_time = 0;
} else if (system->GetExitLocked()) {
shutdown_time = 5000;
}
shutdown_timer.setSingleShot(true); shutdown_timer.setSingleShot(true);
shutdown_timer.start(system->DebuggerEnabled() ? 0 : 5000); shutdown_timer.start(shutdown_time);
connect(&shutdown_timer, &QTimer::timeout, this, &GMainWindow::OnEmulationStopTimeExpired); connect(&shutdown_timer, &QTimer::timeout, this, &GMainWindow::OnEmulationStopTimeExpired);
connect(emu_thread.get(), &QThread::finished, this, &GMainWindow::OnEmulationStopped); connect(emu_thread.get(), &QThread::finished, this, &GMainWindow::OnEmulationStopped);
@ -3261,7 +3269,7 @@ void GMainWindow::OnPauseContinueGame() {
} }
void GMainWindow::OnStopGame() { void GMainWindow::OnStopGame() {
if (system->GetExitLock() && !ConfirmForceLockedExit()) { if (system->GetExitLocked() && !ConfirmForceLockedExit()) {
return; return;
} }
@ -4514,6 +4522,8 @@ void GMainWindow::RequestGameExit() {
auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE"); auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE");
bool has_signalled = false; bool has_signalled = false;
system->SetExitRequested(true);
if (applet_oe != nullptr) { if (applet_oe != nullptr) {
applet_oe->GetMessageQueue()->RequestExit(); applet_oe->GetMessageQueue()->RequestExit();
has_signalled = true; has_signalled = true;