From a7e9d7842dc78e09bfe50ba3bc471b8a75d29b96 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 2 Jan 2024 19:22:02 -0500 Subject: am: add new datatypes for per-applet state --- src/core/hle/service/am/applet.cpp | 63 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/core/hle/service/am/applet.cpp (limited to 'src/core/hle/service/am/applet.cpp') diff --git a/src/core/hle/service/am/applet.cpp b/src/core/hle/service/am/applet.cpp new file mode 100644 index 000000000..8f44fab33 --- /dev/null +++ b/src/core/hle/service/am/applet.cpp @@ -0,0 +1,63 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/scope_exit.h" + +#include "core/hle/service/am/am_results.h" +#include "core/hle/service/am/applet.h" + +namespace Service::AM { + +AppletStorageChannel::AppletStorageChannel(KernelHelpers::ServiceContext& context) + : m_event(context) {} +AppletStorageChannel::~AppletStorageChannel() = default; + +void AppletStorageChannel::PushData(std::shared_ptr storage) { + std::scoped_lock lk{m_lock}; + + m_data.emplace_back(std::move(storage)); + m_event.Signal(); +} + +Result AppletStorageChannel::PopData(std::shared_ptr* out_storage) { + std::scoped_lock lk{m_lock}; + + SCOPE_EXIT({ + if (m_data.empty()) { + m_event.Clear(); + } + }); + + R_UNLESS(!m_data.empty(), AM::ResultNoDataInChannel); + + *out_storage = std::move(m_data.front()); + m_data.pop_front(); + + R_SUCCEED(); +} + +Kernel::KReadableEvent* AppletStorageChannel::GetEvent() { + return m_event.GetHandle(); +} + +AppletStorageHolder::AppletStorageHolder(Core::System& system) + : context(system, "AppletStorageHolder"), in_data(context), interactive_in_data(context), + out_data(context), interactive_out_data(context), state_changed_event(context) {} + +AppletStorageHolder::~AppletStorageHolder() = default; + +Applet::Applet(Core::System& system, std::unique_ptr process_) + : context(system, "Applet"), message_queue(system), process(std::move(process_)), + hid_registration(system, *process), gpu_error_detected_event(context), + friend_invitation_storage_channel_event(context), notification_storage_channel_event(context), + health_warning_disappeared_system_event(context), acquired_sleep_lock_event(context), + pop_from_general_channel_event(context), library_applet_launchable_event(context), + accumulated_suspended_tick_changed_event(context), sleep_lock_event(context) { + + aruid = process->GetProcessId(); + program_id = process->GetProgramId(); +} + +Applet::~Applet() = default; + +} // namespace Service::AM -- cgit v1.2.3 From 8a146469c0639ff402e77da8843072ce1f2bce0c Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 3 Jan 2024 01:16:27 -0500 Subject: am: return AppletDataBroker and use for frontend applets --- src/core/hle/service/am/applet.cpp | 40 ++------------------------------------ 1 file changed, 2 insertions(+), 38 deletions(-) (limited to 'src/core/hle/service/am/applet.cpp') diff --git a/src/core/hle/service/am/applet.cpp b/src/core/hle/service/am/applet.cpp index 8f44fab33..5b9056c12 100644 --- a/src/core/hle/service/am/applet.cpp +++ b/src/core/hle/service/am/applet.cpp @@ -3,49 +3,13 @@ #include "common/scope_exit.h" +#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" namespace Service::AM { -AppletStorageChannel::AppletStorageChannel(KernelHelpers::ServiceContext& context) - : m_event(context) {} -AppletStorageChannel::~AppletStorageChannel() = default; - -void AppletStorageChannel::PushData(std::shared_ptr storage) { - std::scoped_lock lk{m_lock}; - - m_data.emplace_back(std::move(storage)); - m_event.Signal(); -} - -Result AppletStorageChannel::PopData(std::shared_ptr* out_storage) { - std::scoped_lock lk{m_lock}; - - SCOPE_EXIT({ - if (m_data.empty()) { - m_event.Clear(); - } - }); - - R_UNLESS(!m_data.empty(), AM::ResultNoDataInChannel); - - *out_storage = std::move(m_data.front()); - m_data.pop_front(); - - R_SUCCEED(); -} - -Kernel::KReadableEvent* AppletStorageChannel::GetEvent() { - return m_event.GetHandle(); -} - -AppletStorageHolder::AppletStorageHolder(Core::System& system) - : context(system, "AppletStorageHolder"), in_data(context), interactive_in_data(context), - out_data(context), interactive_out_data(context), state_changed_event(context) {} - -AppletStorageHolder::~AppletStorageHolder() = default; - Applet::Applet(Core::System& system, std::unique_ptr process_) : context(system, "Applet"), message_queue(system), process(std::move(process_)), hid_registration(system, *process), gpu_error_detected_event(context), -- cgit v1.2.3