From 95d7f2e57eb343c740fa947c6e79ad9d6995c4b1 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 19 Feb 2024 20:25:54 -0500 Subject: [PATCH] am: record library applet termination result --- src/core/hle/service/am/am_results.h | 1 + src/core/hle/service/am/service/application_accessor.cpp | 3 ++- src/core/hle/service/am/service/library_applet_accessor.cpp | 6 +++--- src/core/hle/service/am/service/library_applet_accessor.h | 2 +- src/core/hle/service/am/window_system.cpp | 3 +++ 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core/hle/service/am/am_results.h b/src/core/hle/service/am/am_results.h index a2afc9eec..44846aa2e 100644 --- a/src/core/hle/service/am/am_results.h +++ b/src/core/hle/service/am/am_results.h @@ -9,6 +9,7 @@ namespace Service::AM { constexpr Result ResultNoDataInChannel{ErrorModule::AM, 2}; constexpr Result ResultNoMessages{ErrorModule::AM, 3}; +constexpr Result ResultLibraryAppletTerminated{ErrorModule::AM, 22}; constexpr Result ResultInvalidOffset{ErrorModule::AM, 503}; constexpr Result ResultInvalidStorageType{ErrorModule::AM, 511}; constexpr Result ResultFatalSectionCountImbalance{ErrorModule::AM, 512}; diff --git a/src/core/hle/service/am/service/application_accessor.cpp b/src/core/hle/service/am/service/application_accessor.cpp index e91d1e98a..986abc716 100644 --- a/src/core/hle/service/am/service/application_accessor.cpp +++ b/src/core/hle/service/am/service/application_accessor.cpp @@ -83,7 +83,8 @@ Result IApplicationAccessor::Terminate() { Result IApplicationAccessor::GetResult() { LOG_INFO(Service_AM, "called"); - R_SUCCEED(); + std::scoped_lock lk{m_applet->lock}; + R_RETURN(m_applet->terminate_result); } Result IApplicationAccessor::GetAppletStateChangedEvent( diff --git a/src/core/hle/service/am/service/library_applet_accessor.cpp b/src/core/hle/service/am/service/library_applet_accessor.cpp index 40e384059..cda8c3eb8 100644 --- a/src/core/hle/service/am/service/library_applet_accessor.cpp +++ b/src/core/hle/service/am/service/library_applet_accessor.cpp @@ -58,10 +58,10 @@ Result ILibraryAppletAccessor::IsCompleted(Out out_is_completed) { R_SUCCEED(); } -Result ILibraryAppletAccessor::GetResult(Out out_result) { +Result ILibraryAppletAccessor::GetResult() { LOG_DEBUG(Service_AM, "called"); - *out_result = m_applet->terminate_result; - R_SUCCEED(); + std::scoped_lock lk{m_applet->lock}; + R_RETURN(m_applet->terminate_result); } Result ILibraryAppletAccessor::PresetLibraryAppletGpuTimeSliceZero() { diff --git a/src/core/hle/service/am/service/library_applet_accessor.h b/src/core/hle/service/am/service/library_applet_accessor.h index 97d3b6c8a..36712821a 100644 --- a/src/core/hle/service/am/service/library_applet_accessor.h +++ b/src/core/hle/service/am/service/library_applet_accessor.h @@ -21,7 +21,7 @@ public: private: Result GetAppletStateChangedEvent(OutCopyHandle out_event); Result IsCompleted(Out out_is_completed); - Result GetResult(Out out_result); + Result GetResult(); Result PresetLibraryAppletGpuTimeSliceZero(); Result Start(); Result RequestExit(); diff --git a/src/core/hle/service/am/window_system.cpp b/src/core/hle/service/am/window_system.cpp index 00fe099fd..5cf24007c 100644 --- a/src/core/hle/service/am/window_system.cpp +++ b/src/core/hle/service/am/window_system.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/core.h" +#include "core/hle/service/am/am_results.h" #include "core/hle/service/am/applet.h" #include "core/hle/service/am/applet_manager.h" #include "core/hle/service/am/event_observer.h" @@ -250,7 +251,9 @@ void WindowSystem::TerminateChildAppletsLocked(Applet* applet) { applet->lock.unlock(); for (const auto& child_applet : child_applets) { + std::scoped_lock lk{child_applet->lock}; child_applet->process->Terminate(); + child_applet->terminate_result = AM::ResultLibraryAppletTerminated; } applet->lock.lock(); }