summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/am/am.cpp22
-rw-r--r--src/core/hle/service/am/am.h8
2 files changed, 29 insertions, 1 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 4ef449ccb..c750d70ac 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -98,7 +98,7 @@ IAudioController::IAudioController() : ServiceFramework("IAudioController") {
98 {0, &IAudioController::SetExpectedMasterVolume, "SetExpectedMasterVolume"}, 98 {0, &IAudioController::SetExpectedMasterVolume, "SetExpectedMasterVolume"},
99 {1, &IAudioController::GetMainAppletExpectedMasterVolume, "GetMainAppletExpectedMasterVolume"}, 99 {1, &IAudioController::GetMainAppletExpectedMasterVolume, "GetMainAppletExpectedMasterVolume"},
100 {2, &IAudioController::GetLibraryAppletExpectedMasterVolume, "GetLibraryAppletExpectedMasterVolume"}, 100 {2, &IAudioController::GetLibraryAppletExpectedMasterVolume, "GetLibraryAppletExpectedMasterVolume"},
101 {3, nullptr, "ChangeMainAppletMasterVolume"}, 101 {3, &IAudioController::ChangeMainAppletMasterVolume, "ChangeMainAppletMasterVolume"},
102 {4, &IAudioController::SetTransparentAudioRate, "SetTransparentVolumeRate"}, 102 {4, &IAudioController::SetTransparentAudioRate, "SetTransparentVolumeRate"},
103 }; 103 };
104 // clang-format on 104 // clang-format on
@@ -139,6 +139,26 @@ void IAudioController::GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestCo
139 rb.Push(library_applet_volume); 139 rb.Push(library_applet_volume);
140} 140}
141 141
142void IAudioController::ChangeMainAppletMasterVolume(Kernel::HLERequestContext& ctx) {
143 struct Parameters {
144 float volume;
145 s64 fade_time_ns;
146 };
147 static_assert(sizeof(Parameters) == 16);
148
149 IPC::RequestParser rp{ctx};
150 const auto parameters = rp.PopRaw<Parameters>();
151
152 LOG_DEBUG(Service_AM, "called. volume={}, fade_time_ns={}", parameters.volume,
153 parameters.fade_time_ns);
154
155 main_applet_volume = std::clamp(parameters.volume, min_allowed_volume, max_allowed_volume);
156 fade_time_ns = std::chrono::nanoseconds{parameters.fade_time_ns};
157
158 IPC::ResponseBuilder rb{ctx, 2};
159 rb.Push(RESULT_SUCCESS);
160}
161
142void IAudioController::SetTransparentAudioRate(Kernel::HLERequestContext& ctx) { 162void IAudioController::SetTransparentAudioRate(Kernel::HLERequestContext& ctx) {
143 IPC::RequestParser rp{ctx}; 163 IPC::RequestParser rp{ctx};
144 const float transparent_volume_rate_tmp = rp.Pop<float>(); 164 const float transparent_volume_rate_tmp = rp.Pop<float>();
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h
index b77a8c96c..565dd8e9e 100644
--- a/src/core/hle/service/am/am.h
+++ b/src/core/hle/service/am/am.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <chrono>
7#include <memory> 8#include <memory>
8#include <queue> 9#include <queue>
9#include "core/hle/kernel/writable_event.h" 10#include "core/hle/kernel/writable_event.h"
@@ -81,6 +82,7 @@ private:
81 void SetExpectedMasterVolume(Kernel::HLERequestContext& ctx); 82 void SetExpectedMasterVolume(Kernel::HLERequestContext& ctx);
82 void GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx); 83 void GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx);
83 void GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx); 84 void GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx);
85 void ChangeMainAppletMasterVolume(Kernel::HLERequestContext& ctx);
84 void SetTransparentAudioRate(Kernel::HLERequestContext& ctx); 86 void SetTransparentAudioRate(Kernel::HLERequestContext& ctx);
85 87
86 static constexpr float min_allowed_volume = 0.0f; 88 static constexpr float min_allowed_volume = 0.0f;
@@ -89,6 +91,12 @@ private:
89 float main_applet_volume{0.25f}; 91 float main_applet_volume{0.25f};
90 float library_applet_volume{max_allowed_volume}; 92 float library_applet_volume{max_allowed_volume};
91 float transparent_volume_rate{min_allowed_volume}; 93 float transparent_volume_rate{min_allowed_volume};
94
95 // Volume transition fade time in nanoseconds.
96 // e.g. If the main applet volume was 0% and was changed to 50%
97 // with a fade of 50ns, then over the course of 50ns,
98 // the volume will gradually fade up to 50%
99 std::chrono::nanoseconds fade_time_ns{0};
92}; 100};
93 101
94class IDisplayController final : public ServiceFramework<IDisplayController> { 102class IDisplayController final : public ServiceFramework<IDisplayController> {