diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 32 | ||||
| -rw-r--r-- | src/core/hle/service/am/am.h | 6 |
2 files changed, 27 insertions, 11 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 3f009d2b7..4f1541e9d 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -2,10 +2,10 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 5 | #include <array> | 6 | #include <array> |
| 6 | #include <cinttypes> | 7 | #include <cinttypes> |
| 7 | #include <cstring> | 8 | #include <cstring> |
| 8 | #include <stack> | ||
| 9 | #include "audio_core/audio_renderer.h" | 9 | #include "audio_core/audio_renderer.h" |
| 10 | #include "core/core.h" | 10 | #include "core/core.h" |
| 11 | #include "core/file_sys/savedata_factory.h" | 11 | #include "core/file_sys/savedata_factory.h" |
| @@ -93,38 +93,50 @@ void IWindowController::AcquireForegroundRights(Kernel::HLERequestContext& ctx) | |||
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | IAudioController::IAudioController() : ServiceFramework("IAudioController") { | 95 | IAudioController::IAudioController() : ServiceFramework("IAudioController") { |
| 96 | // clang-format off | ||
| 96 | static const FunctionInfo functions[] = { | 97 | static const FunctionInfo functions[] = { |
| 97 | {0, &IAudioController::SetExpectedMasterVolume, "SetExpectedMasterVolume"}, | 98 | {0, &IAudioController::SetExpectedMasterVolume, "SetExpectedMasterVolume"}, |
| 98 | {1, &IAudioController::GetMainAppletExpectedMasterVolume, | 99 | {1, &IAudioController::GetMainAppletExpectedMasterVolume, "GetMainAppletExpectedMasterVolume"}, |
| 99 | "GetMainAppletExpectedMasterVolume"}, | 100 | {2, &IAudioController::GetLibraryAppletExpectedMasterVolume, "GetLibraryAppletExpectedMasterVolume"}, |
| 100 | {2, &IAudioController::GetLibraryAppletExpectedMasterVolume, | ||
| 101 | "GetLibraryAppletExpectedMasterVolume"}, | ||
| 102 | {3, nullptr, "ChangeMainAppletMasterVolume"}, | 101 | {3, nullptr, "ChangeMainAppletMasterVolume"}, |
| 103 | {4, nullptr, "SetTransparentVolumeRate"}, | 102 | {4, nullptr, "SetTransparentVolumeRate"}, |
| 104 | }; | 103 | }; |
| 104 | // clang-format on | ||
| 105 | |||
| 105 | RegisterHandlers(functions); | 106 | RegisterHandlers(functions); |
| 106 | } | 107 | } |
| 107 | 108 | ||
| 108 | IAudioController::~IAudioController() = default; | 109 | IAudioController::~IAudioController() = default; |
| 109 | 110 | ||
| 110 | void IAudioController::SetExpectedMasterVolume(Kernel::HLERequestContext& ctx) { | 111 | void IAudioController::SetExpectedMasterVolume(Kernel::HLERequestContext& ctx) { |
| 111 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 112 | IPC::RequestParser rp{ctx}; |
| 113 | const float main_applet_volume_tmp = rp.Pop<float>(); | ||
| 114 | const float library_applet_volume_tmp = rp.Pop<float>(); | ||
| 115 | |||
| 116 | LOG_DEBUG(Service_AM, "called. main_applet_volume={}, library_applet_volume={}", | ||
| 117 | main_applet_volume_tmp, library_applet_volume_tmp); | ||
| 118 | |||
| 119 | // Ensure the volume values remain within the 0-100% range | ||
| 120 | main_applet_volume = std::clamp(main_applet_volume_tmp, min_allowed_volume, max_allowed_volume); | ||
| 121 | library_applet_volume = | ||
| 122 | std::clamp(library_applet_volume_tmp, min_allowed_volume, max_allowed_volume); | ||
| 123 | |||
| 112 | IPC::ResponseBuilder rb{ctx, 2}; | 124 | IPC::ResponseBuilder rb{ctx, 2}; |
| 113 | rb.Push(RESULT_SUCCESS); | 125 | rb.Push(RESULT_SUCCESS); |
| 114 | } | 126 | } |
| 115 | 127 | ||
| 116 | void IAudioController::GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) { | 128 | void IAudioController::GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) { |
| 117 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 129 | LOG_DEBUG(Service_AM, "called. main_applet_volume={}", main_applet_volume); |
| 118 | IPC::ResponseBuilder rb{ctx, 3}; | 130 | IPC::ResponseBuilder rb{ctx, 3}; |
| 119 | rb.Push(RESULT_SUCCESS); | 131 | rb.Push(RESULT_SUCCESS); |
| 120 | rb.Push(volume); | 132 | rb.Push(main_applet_volume); |
| 121 | } | 133 | } |
| 122 | 134 | ||
| 123 | void IAudioController::GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) { | 135 | void IAudioController::GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) { |
| 124 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 136 | LOG_DEBUG(Service_AM, "called. library_applet_volume={}", library_applet_volume); |
| 125 | IPC::ResponseBuilder rb{ctx, 3}; | 137 | IPC::ResponseBuilder rb{ctx, 3}; |
| 126 | rb.Push(RESULT_SUCCESS); | 138 | rb.Push(RESULT_SUCCESS); |
| 127 | rb.Push(volume); | 139 | rb.Push(library_applet_volume); |
| 128 | } | 140 | } |
| 129 | 141 | ||
| 130 | IDisplayController::IDisplayController() : ServiceFramework("IDisplayController") { | 142 | IDisplayController::IDisplayController() : ServiceFramework("IDisplayController") { |
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index b6113cfdd..bca06c25d 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h | |||
| @@ -82,7 +82,11 @@ private: | |||
| 82 | void GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx); | 82 | void GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx); |
| 83 | void GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx); | 83 | void GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx); |
| 84 | 84 | ||
| 85 | u32 volume{100}; | 85 | static constexpr float min_allowed_volume = 0.0f; |
| 86 | static constexpr float max_allowed_volume = 1.0f; | ||
| 87 | |||
| 88 | float main_applet_volume{0.25f}; | ||
| 89 | float library_applet_volume{max_allowed_volume}; | ||
| 86 | }; | 90 | }; |
| 87 | 91 | ||
| 88 | class IDisplayController final : public ServiceFramework<IDisplayController> { | 92 | class IDisplayController final : public ServiceFramework<IDisplayController> { |