From 1471d150d096a8863bb3d5d07425541686773e92 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Fri, 20 Jun 2025 15:52:14 +1000 Subject: [PATCH] Implement IApplicationFunctions function 210 (RequestToAcquireUserUsedMemory) --- src/audio_core/renderer/behavior/info_updater.cpp | 14 ++++---------- src/audio_core/renderer/voice/voice_info.h | 4 +--- src/core/hle/service/am/applet.cpp | 2 +- src/core/hle/service/am/applet.h | 1 + .../service/am/service/application_functions.cpp | 7 +++++++ .../hle/service/am/service/application_functions.h | 1 + 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/audio_core/renderer/behavior/info_updater.cpp b/src/audio_core/renderer/behavior/info_updater.cpp index 014e4bf14..3dae6069f 100644 --- a/src/audio_core/renderer/behavior/info_updater.cpp +++ b/src/audio_core/renderer/behavior/info_updater.cpp @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project -// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "audio_core/common/feature_support.h" @@ -326,18 +325,13 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co } if (consumed_input_size != in_header->mix_size) { - LOG_WARNING(Service_Audio, "Consumed an incorrect mixes size, header size={}, consumed={}, adjusting input pointer", + LOG_ERROR(Service_Audio, "Consumed an incorrect mixes size, header size={}, consumed={}", in_header->mix_size, consumed_input_size); - // Calculate the adjustment needed - const auto adjustment = in_header->mix_size - consumed_input_size; - // Adjust input pointer to match expected header size to prevent desync - input = reinterpret_cast(input) + adjustment; - // Also adjust the expected input size for CheckConsumedSize - expected_input_size += adjustment; - // Continue processing instead of failing + return Service::Audio::ResultInvalidUpdateInfo; } - // Input pointer adjustment is now handled in the size check above + input += mix_count * sizeof(MixInfo::InParameter); + return ResultSuccess; } diff --git a/src/audio_core/renderer/voice/voice_info.h b/src/audio_core/renderer/voice/voice_info.h index c29dd780b..14a687dcb 100644 --- a/src/audio_core/renderer/voice/voice_info.h +++ b/src/audio_core/renderer/voice/voice_info.h @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project -// SPDX-FileCopyrightText: Copyright 2025 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -166,9 +165,8 @@ public: /* 0x15D */ char unk15D[0x1]; /* 0x15E */ SrcQuality src_quality; /* 0x15F */ char unk15F[0x11]; - /* 0x170 */ char unk170[0x18]; // Additional 24 bytes for newer audio renderer versions }; - static_assert(sizeof(InParameter) == 0x188, "VoiceInfo::InParameter has the wrong size!"); + static_assert(sizeof(InParameter) == 0x170, "VoiceInfo::InParameter has the wrong size!"); struct OutStatus { /* 0x00 */ u64 played_sample_count; diff --git a/src/core/hle/service/am/applet.cpp b/src/core/hle/service/am/applet.cpp index 6847f250c..8b2178405 100644 --- a/src/core/hle/service/am/applet.cpp +++ b/src/core/hle/service/am/applet.cpp @@ -14,7 +14,7 @@ Applet::Applet(Core::System& system, std::unique_ptr process_, bool is_ 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), state_changed_event(context) { + sleep_lock_event(context), state_changed_event(context), user_used_memory_event(context) { aruid.pid = process->GetProcessId(); program_id = process->GetProgramId(); diff --git a/src/core/hle/service/am/applet.h b/src/core/hle/service/am/applet.h index 571904fab..8cea589c7 100644 --- a/src/core/hle/service/am/applet.h +++ b/src/core/hle/service/am/applet.h @@ -125,6 +125,7 @@ struct Applet { Event accumulated_suspended_tick_changed_event; Event sleep_lock_event; Event state_changed_event; + Event user_used_memory_event; // Frontend state std::shared_ptr frontend{}; diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp index 3bab5ac5f..bf7dc795a 100644 --- a/src/core/hle/service/am/service/application_functions.cpp +++ b/src/core/hle/service/am/service/application_functions.cpp @@ -85,6 +85,7 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_, std::shared_ {181, nullptr, "UpgradeLaunchRequiredVersion"}, {190, nullptr, "SendServerMaintenanceOverlayNotification"}, {200, nullptr, "GetLastApplicationExitReason"}, + {210, D<&IApplicationFunctions::RequestToAcquireUserUsedMemory>, "RequestToAcquireUserUsedMemory"}, {500, nullptr, "StartContinuousRecordingFlushForDebug"}, {1000, nullptr, "CreateMovieMaker"}, {1001, D<&IApplicationFunctions::PrepareForJit>, "PrepareForJit"}, @@ -483,4 +484,10 @@ Result IApplicationFunctions::PrepareForJit() { R_SUCCEED(); } +Result IApplicationFunctions::RequestToAcquireUserUsedMemory(OutCopyHandle out_event) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + *out_event = m_applet->user_used_memory_event.GetHandle(); + R_SUCCEED(); +} + } // namespace Service::AM diff --git a/src/core/hle/service/am/service/application_functions.h b/src/core/hle/service/am/service/application_functions.h index 10025a152..a8a1761dd 100644 --- a/src/core/hle/service/am/service/application_functions.h +++ b/src/core/hle/service/am/service/application_functions.h @@ -77,6 +77,7 @@ private: Result GetNotificationStorageChannelEvent(OutCopyHandle out_event); Result GetHealthWarningDisappearedSystemEvent(OutCopyHandle out_event); Result PrepareForJit(); + Result RequestToAcquireUserUsedMemory(OutCopyHandle out_event); const std::shared_ptr m_applet; };