summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/hle/service/am/audio_controller.cpp91
-rw-r--r--src/core/hle/service/am/audio_controller.h36
-rw-r--r--src/core/hle/service/am/service/application_proxy.cpp2
-rw-r--r--src/core/hle/service/am/service/audio_controller.cpp69
-rw-r--r--src/core/hle/service/am/service/audio_controller.h37
-rw-r--r--src/core/hle/service/am/service/library_applet_proxy.cpp2
-rw-r--r--src/core/hle/service/am/service/system_applet_proxy.cpp2
8 files changed, 111 insertions, 132 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 4486a355c..8e4928e08 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -429,8 +429,6 @@ add_library(core STATIC
hle/service/am/application_creator.h
hle/service/am/application_functions.cpp
hle/service/am/application_functions.h
- hle/service/am/audio_controller.cpp
- hle/service/am/audio_controller.h
hle/service/am/common_state_getter.cpp
hle/service/am/common_state_getter.h
hle/service/am/debug_functions.cpp
@@ -471,6 +469,8 @@ add_library(core STATIC
hle/service/am/service/application_proxy_service.h
hle/service/am/service/application_proxy.cpp
hle/service/am/service/application_proxy.h
+ hle/service/am/service/audio_controller.cpp
+ hle/service/am/service/audio_controller.h
hle/service/am/service/library_applet_proxy.cpp
hle/service/am/service/library_applet_proxy.h
hle/service/am/service/system_applet_proxy.cpp
diff --git a/src/core/hle/service/am/audio_controller.cpp b/src/core/hle/service/am/audio_controller.cpp
deleted file mode 100644
index ae75db174..000000000
--- a/src/core/hle/service/am/audio_controller.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-#include "core/hle/service/am/audio_controller.h"
-#include "core/hle/service/ipc_helpers.h"
-
-namespace Service::AM {
-
-IAudioController::IAudioController(Core::System& system_)
- : ServiceFramework{system_, "IAudioController"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, &IAudioController::SetExpectedMasterVolume, "SetExpectedMasterVolume"},
- {1, &IAudioController::GetMainAppletExpectedMasterVolume, "GetMainAppletExpectedMasterVolume"},
- {2, &IAudioController::GetLibraryAppletExpectedMasterVolume, "GetLibraryAppletExpectedMasterVolume"},
- {3, &IAudioController::ChangeMainAppletMasterVolume, "ChangeMainAppletMasterVolume"},
- {4, &IAudioController::SetTransparentAudioRate, "SetTransparentVolumeRate"},
- };
- // clang-format on
-
- RegisterHandlers(functions);
-}
-
-IAudioController::~IAudioController() = default;
-
-void IAudioController::SetExpectedMasterVolume(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const float main_applet_volume_tmp = rp.Pop<float>();
- const float library_applet_volume_tmp = rp.Pop<float>();
-
- LOG_DEBUG(Service_AM, "called. main_applet_volume={}, library_applet_volume={}",
- main_applet_volume_tmp, library_applet_volume_tmp);
-
- // Ensure the volume values remain within the 0-100% range
- main_applet_volume = std::clamp(main_applet_volume_tmp, min_allowed_volume, max_allowed_volume);
- library_applet_volume =
- std::clamp(library_applet_volume_tmp, min_allowed_volume, max_allowed_volume);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
-}
-
-void IAudioController::GetMainAppletExpectedMasterVolume(HLERequestContext& ctx) {
- LOG_DEBUG(Service_AM, "called. main_applet_volume={}", main_applet_volume);
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(ResultSuccess);
- rb.Push(main_applet_volume);
-}
-
-void IAudioController::GetLibraryAppletExpectedMasterVolume(HLERequestContext& ctx) {
- LOG_DEBUG(Service_AM, "called. library_applet_volume={}", library_applet_volume);
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(ResultSuccess);
- rb.Push(library_applet_volume);
-}
-
-void IAudioController::ChangeMainAppletMasterVolume(HLERequestContext& ctx) {
- struct Parameters {
- float volume;
- s64 fade_time_ns;
- };
- static_assert(sizeof(Parameters) == 16);
-
- IPC::RequestParser rp{ctx};
- const auto parameters = rp.PopRaw<Parameters>();
-
- LOG_DEBUG(Service_AM, "called. volume={}, fade_time_ns={}", parameters.volume,
- parameters.fade_time_ns);
-
- main_applet_volume = std::clamp(parameters.volume, min_allowed_volume, max_allowed_volume);
- fade_time_ns = std::chrono::nanoseconds{parameters.fade_time_ns};
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
-}
-
-void IAudioController::SetTransparentAudioRate(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const float transparent_volume_rate_tmp = rp.Pop<float>();
-
- LOG_DEBUG(Service_AM, "called. transparent_volume_rate={}", transparent_volume_rate_tmp);
-
- // Clamp volume range to 0-100%.
- transparent_volume_rate =
- std::clamp(transparent_volume_rate_tmp, min_allowed_volume, max_allowed_volume);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
-}
-
-} // namespace Service::AM
diff --git a/src/core/hle/service/am/audio_controller.h b/src/core/hle/service/am/audio_controller.h
deleted file mode 100644
index a47e3bad8..000000000
--- a/src/core/hle/service/am/audio_controller.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-#pragma once
-
-#include "core/hle/service/service.h"
-
-namespace Service::AM {
-
-class IAudioController final : public ServiceFramework<IAudioController> {
-public:
- explicit IAudioController(Core::System& system_);
- ~IAudioController() override;
-
-private:
- void SetExpectedMasterVolume(HLERequestContext& ctx);
- void GetMainAppletExpectedMasterVolume(HLERequestContext& ctx);
- void GetLibraryAppletExpectedMasterVolume(HLERequestContext& ctx);
- void ChangeMainAppletMasterVolume(HLERequestContext& ctx);
- void SetTransparentAudioRate(HLERequestContext& ctx);
-
- static constexpr float min_allowed_volume = 0.0f;
- static constexpr float max_allowed_volume = 1.0f;
-
- float main_applet_volume{0.25f};
- float library_applet_volume{max_allowed_volume};
- float transparent_volume_rate{min_allowed_volume};
-
- // Volume transition fade time in nanoseconds.
- // e.g. If the main applet volume was 0% and was changed to 50%
- // with a fade of 50ns, then over the course of 50ns,
- // the volume will gradually fade up to 50%
- std::chrono::nanoseconds fade_time_ns{0};
-};
-
-} // namespace Service::AM
diff --git a/src/core/hle/service/am/service/application_proxy.cpp b/src/core/hle/service/am/service/application_proxy.cpp
index d1f87709e..d28321a4a 100644
--- a/src/core/hle/service/am/service/application_proxy.cpp
+++ b/src/core/hle/service/am/service/application_proxy.cpp
@@ -3,7 +3,6 @@
#include "core/hle/service/am/applet_common_functions.h"
#include "core/hle/service/am/application_functions.h"
-#include "core/hle/service/am/audio_controller.h"
#include "core/hle/service/am/common_state_getter.h"
#include "core/hle/service/am/debug_functions.h"
#include "core/hle/service/am/display_controller.h"
@@ -12,6 +11,7 @@
#include "core/hle/service/am/process_winding_controller.h"
#include "core/hle/service/am/self_controller.h"
#include "core/hle/service/am/service/application_proxy.h"
+#include "core/hle/service/am/service/audio_controller.h"
#include "core/hle/service/am/window_controller.h"
#include "core/hle/service/cmif_serialization.h"
diff --git a/src/core/hle/service/am/service/audio_controller.cpp b/src/core/hle/service/am/service/audio_controller.cpp
new file mode 100644
index 000000000..ad731c7bd
--- /dev/null
+++ b/src/core/hle/service/am/service/audio_controller.cpp
@@ -0,0 +1,69 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "core/hle/service/am/service/audio_controller.h"
+#include "core/hle/service/cmif_serialization.h"
+
+namespace Service::AM {
+
+IAudioController::IAudioController(Core::System& system_)
+ : ServiceFramework{system_, "IAudioController"} {
+ // clang-format off
+ static const FunctionInfo functions[] = {
+ {0, D<&IAudioController::SetExpectedMasterVolume>, "SetExpectedMasterVolume"},
+ {1, D<&IAudioController::GetMainAppletExpectedMasterVolume>, "GetMainAppletExpectedMasterVolume"},
+ {2, D<&IAudioController::GetLibraryAppletExpectedMasterVolume>, "GetLibraryAppletExpectedMasterVolume"},
+ {3, D<&IAudioController::ChangeMainAppletMasterVolume>, "ChangeMainAppletMasterVolume"},
+ {4, D<&IAudioController::SetTransparentVolumeRate>, "SetTransparentVolumeRate"},
+ };
+ // clang-format on
+
+ RegisterHandlers(functions);
+}
+
+IAudioController::~IAudioController() = default;
+
+Result IAudioController::SetExpectedMasterVolume(f32 main_applet_volume,
+ f32 library_applet_volume) {
+ LOG_DEBUG(Service_AM, "called. main_applet_volume={}, library_applet_volume={}",
+ main_applet_volume, library_applet_volume);
+
+ // Ensure the volume values remain within the 0-100% range
+ m_main_applet_volume = std::clamp(main_applet_volume, MinAllowedVolume, MaxAllowedVolume);
+ m_library_applet_volume = std::clamp(library_applet_volume, MinAllowedVolume, MaxAllowedVolume);
+
+ R_SUCCEED();
+}
+
+Result IAudioController::GetMainAppletExpectedMasterVolume(Out<f32> out_main_applet_volume) {
+ LOG_DEBUG(Service_AM, "called. main_applet_volume={}", m_main_applet_volume);
+ *out_main_applet_volume = m_main_applet_volume;
+ R_SUCCEED();
+}
+
+Result IAudioController::GetLibraryAppletExpectedMasterVolume(Out<f32> out_library_applet_volume) {
+ LOG_DEBUG(Service_AM, "called. library_applet_volume={}", m_library_applet_volume);
+ *out_library_applet_volume = m_library_applet_volume;
+ R_SUCCEED();
+}
+
+Result IAudioController::ChangeMainAppletMasterVolume(f32 volume, s64 fade_time_ns) {
+ LOG_DEBUG(Service_AM, "called. volume={}, fade_time_ns={}", volume, fade_time_ns);
+
+ m_main_applet_volume = std::clamp(volume, MinAllowedVolume, MaxAllowedVolume);
+ m_fade_time_ns = std::chrono::nanoseconds{fade_time_ns};
+
+ R_SUCCEED();
+}
+
+Result IAudioController::SetTransparentVolumeRate(f32 transparent_volume_rate) {
+ LOG_DEBUG(Service_AM, "called. transparent_volume_rate={}", transparent_volume_rate);
+
+ // Clamp volume range to 0-100%.
+ m_transparent_volume_rate =
+ std::clamp(transparent_volume_rate, MinAllowedVolume, MaxAllowedVolume);
+
+ R_SUCCEED();
+}
+
+} // namespace Service::AM
diff --git a/src/core/hle/service/am/service/audio_controller.h b/src/core/hle/service/am/service/audio_controller.h
new file mode 100644
index 000000000..4b0f3f9ae
--- /dev/null
+++ b/src/core/hle/service/am/service/audio_controller.h
@@ -0,0 +1,37 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "core/hle/service/cmif_types.h"
+#include "core/hle/service/service.h"
+
+namespace Service::AM {
+
+class IAudioController final : public ServiceFramework<IAudioController> {
+public:
+ explicit IAudioController(Core::System& system_);
+ ~IAudioController() override;
+
+private:
+ Result SetExpectedMasterVolume(f32 main_applet_volume, f32 library_applet_volume);
+ Result GetMainAppletExpectedMasterVolume(Out<f32> out_main_applet_volume);
+ Result GetLibraryAppletExpectedMasterVolume(Out<f32> out_library_applet_volume);
+ Result ChangeMainAppletMasterVolume(f32 volume, s64 fade_time_ns);
+ Result SetTransparentVolumeRate(f32 transparent_volume_rate);
+
+ static constexpr float MinAllowedVolume = 0.0f;
+ static constexpr float MaxAllowedVolume = 1.0f;
+
+ float m_main_applet_volume{0.25f};
+ float m_library_applet_volume{MaxAllowedVolume};
+ float m_transparent_volume_rate{MinAllowedVolume};
+
+ // Volume transition fade time in nanoseconds.
+ // e.g. If the main applet volume was 0% and was changed to 50%
+ // with a fade of 50ns, then over the course of 50ns,
+ // the volume will gradually fade up to 50%
+ std::chrono::nanoseconds m_fade_time_ns{0};
+};
+
+} // namespace Service::AM
diff --git a/src/core/hle/service/am/service/library_applet_proxy.cpp b/src/core/hle/service/am/service/library_applet_proxy.cpp
index 9a0d363ac..dd0f8ff11 100644
--- a/src/core/hle/service/am/service/library_applet_proxy.cpp
+++ b/src/core/hle/service/am/service/library_applet_proxy.cpp
@@ -2,7 +2,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/am/applet_common_functions.h"
-#include "core/hle/service/am/audio_controller.h"
#include "core/hle/service/am/common_state_getter.h"
#include "core/hle/service/am/debug_functions.h"
#include "core/hle/service/am/display_controller.h"
@@ -12,6 +11,7 @@
#include "core/hle/service/am/library_applet_self_accessor.h"
#include "core/hle/service/am/process_winding_controller.h"
#include "core/hle/service/am/self_controller.h"
+#include "core/hle/service/am/service/audio_controller.h"
#include "core/hle/service/am/service/library_applet_proxy.h"
#include "core/hle/service/am/window_controller.h"
#include "core/hle/service/cmif_serialization.h"
diff --git a/src/core/hle/service/am/service/system_applet_proxy.cpp b/src/core/hle/service/am/service/system_applet_proxy.cpp
index 0a69d1502..cc1f83fef 100644
--- a/src/core/hle/service/am/service/system_applet_proxy.cpp
+++ b/src/core/hle/service/am/service/system_applet_proxy.cpp
@@ -3,7 +3,6 @@
#include "core/hle/service/am/applet_common_functions.h"
#include "core/hle/service/am/application_creator.h"
-#include "core/hle/service/am/audio_controller.h"
#include "core/hle/service/am/common_state_getter.h"
#include "core/hle/service/am/debug_functions.h"
#include "core/hle/service/am/display_controller.h"
@@ -13,6 +12,7 @@
#include "core/hle/service/am/library_applet_self_accessor.h"
#include "core/hle/service/am/process_winding_controller.h"
#include "core/hle/service/am/self_controller.h"
+#include "core/hle/service/am/service/audio_controller.h"
#include "core/hle/service/am/service/system_applet_proxy.h"
#include "core/hle/service/am/window_controller.h"
#include "core/hle/service/cmif_serialization.h"