mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-27 08:30:06 +00:00
service/am: Add basic implementation of ChangeMainAppletMasterVolume
All this does is supply a new volume level and a fade time in nanoseconds for the volume transition to occur within.
This commit is contained in:
parent
c07ebeac19
commit
26b809549b
@ -98,7 +98,7 @@ IAudioController::IAudioController() : ServiceFramework("IAudioController") {
|
|||||||
{0, &IAudioController::SetExpectedMasterVolume, "SetExpectedMasterVolume"},
|
{0, &IAudioController::SetExpectedMasterVolume, "SetExpectedMasterVolume"},
|
||||||
{1, &IAudioController::GetMainAppletExpectedMasterVolume, "GetMainAppletExpectedMasterVolume"},
|
{1, &IAudioController::GetMainAppletExpectedMasterVolume, "GetMainAppletExpectedMasterVolume"},
|
||||||
{2, &IAudioController::GetLibraryAppletExpectedMasterVolume, "GetLibraryAppletExpectedMasterVolume"},
|
{2, &IAudioController::GetLibraryAppletExpectedMasterVolume, "GetLibraryAppletExpectedMasterVolume"},
|
||||||
{3, nullptr, "ChangeMainAppletMasterVolume"},
|
{3, &IAudioController::ChangeMainAppletMasterVolume, "ChangeMainAppletMasterVolume"},
|
||||||
{4, &IAudioController::SetTransparentAudioRate, "SetTransparentVolumeRate"},
|
{4, &IAudioController::SetTransparentAudioRate, "SetTransparentVolumeRate"},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
@ -139,6 +139,26 @@ void IAudioController::GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestCo
|
|||||||
rb.Push(library_applet_volume);
|
rb.Push(library_applet_volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IAudioController::ChangeMainAppletMasterVolume(Kernel::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(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
void IAudioController::SetTransparentAudioRate(Kernel::HLERequestContext& ctx) {
|
void IAudioController::SetTransparentAudioRate(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const float transparent_volume_rate_tmp = rp.Pop<float>();
|
const float transparent_volume_rate_tmp = rp.Pop<float>();
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include "core/hle/kernel/writable_event.h"
|
#include "core/hle/kernel/writable_event.h"
|
||||||
@ -81,6 +82,7 @@ private:
|
|||||||
void SetExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
void SetExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
||||||
void GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
void GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
||||||
void GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
void GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
||||||
|
void ChangeMainAppletMasterVolume(Kernel::HLERequestContext& ctx);
|
||||||
void SetTransparentAudioRate(Kernel::HLERequestContext& ctx);
|
void SetTransparentAudioRate(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
static constexpr float min_allowed_volume = 0.0f;
|
static constexpr float min_allowed_volume = 0.0f;
|
||||||
@ -89,6 +91,12 @@ private:
|
|||||||
float main_applet_volume{0.25f};
|
float main_applet_volume{0.25f};
|
||||||
float library_applet_volume{max_allowed_volume};
|
float library_applet_volume{max_allowed_volume};
|
||||||
float transparent_volume_rate{min_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};
|
||||||
};
|
};
|
||||||
|
|
||||||
class IDisplayController final : public ServiceFramework<IDisplayController> {
|
class IDisplayController final : public ServiceFramework<IDisplayController> {
|
||||||
|
Loading…
Reference in New Issue
Block a user