diff options
| -rw-r--r-- | src/core/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audctl.cpp | 201 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audctl.h | 50 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audio.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audio_controller.cpp | 174 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audio_controller.h | 58 |
6 files changed, 236 insertions, 255 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 7770dbeae..df47033e3 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -491,12 +491,12 @@ add_library(core STATIC | |||
| 491 | hle/service/apm/apm_controller.h | 491 | hle/service/apm/apm_controller.h |
| 492 | hle/service/apm/apm_interface.cpp | 492 | hle/service/apm/apm_interface.cpp |
| 493 | hle/service/apm/apm_interface.h | 493 | hle/service/apm/apm_interface.h |
| 494 | hle/service/audio/audctl.cpp | ||
| 495 | hle/service/audio/audctl.h | ||
| 496 | hle/service/audio/audin_u.cpp | 494 | hle/service/audio/audin_u.cpp |
| 497 | hle/service/audio/audin_u.h | 495 | hle/service/audio/audin_u.h |
| 498 | hle/service/audio/audio.cpp | 496 | hle/service/audio/audio.cpp |
| 499 | hle/service/audio/audio.h | 497 | hle/service/audio/audio.h |
| 498 | hle/service/audio/audio_controller.cpp | ||
| 499 | hle/service/audio/audio_controller.h | ||
| 500 | hle/service/audio/audout_u.cpp | 500 | hle/service/audio/audout_u.cpp |
| 501 | hle/service/audio/audout_u.h | 501 | hle/service/audio/audout_u.h |
| 502 | hle/service/audio/audrec_a.cpp | 502 | hle/service/audio/audrec_a.cpp |
diff --git a/src/core/hle/service/audio/audctl.cpp b/src/core/hle/service/audio/audctl.cpp deleted file mode 100644 index cf4bb4034..000000000 --- a/src/core/hle/service/audio/audctl.cpp +++ /dev/null | |||
| @@ -1,201 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "common/logging/log.h" | ||
| 5 | #include "core/hle/service/audio/audctl.h" | ||
| 6 | #include "core/hle/service/ipc_helpers.h" | ||
| 7 | #include "core/hle/service/set/system_settings_server.h" | ||
| 8 | #include "core/hle/service/sm/sm.h" | ||
| 9 | |||
| 10 | namespace Service::Audio { | ||
| 11 | |||
| 12 | AudCtl::AudCtl(Core::System& system_) : ServiceFramework{system_, "audctl"} { | ||
| 13 | // clang-format off | ||
| 14 | static const FunctionInfo functions[] = { | ||
| 15 | {0, nullptr, "GetTargetVolume"}, | ||
| 16 | {1, nullptr, "SetTargetVolume"}, | ||
| 17 | {2, &AudCtl::GetTargetVolumeMin, "GetTargetVolumeMin"}, | ||
| 18 | {3, &AudCtl::GetTargetVolumeMax, "GetTargetVolumeMax"}, | ||
| 19 | {4, nullptr, "IsTargetMute"}, | ||
| 20 | {5, nullptr, "SetTargetMute"}, | ||
| 21 | {6, nullptr, "IsTargetConnected"}, | ||
| 22 | {7, nullptr, "SetDefaultTarget"}, | ||
| 23 | {8, nullptr, "GetDefaultTarget"}, | ||
| 24 | {9, &AudCtl::GetAudioOutputMode, "GetAudioOutputMode"}, | ||
| 25 | {10, &AudCtl::SetAudioOutputMode, "SetAudioOutputMode"}, | ||
| 26 | {11, nullptr, "SetForceMutePolicy"}, | ||
| 27 | {12, &AudCtl::GetForceMutePolicy, "GetForceMutePolicy"}, | ||
| 28 | {13, &AudCtl::GetOutputModeSetting, "GetOutputModeSetting"}, | ||
| 29 | {14, &AudCtl::SetOutputModeSetting, "SetOutputModeSetting"}, | ||
| 30 | {15, nullptr, "SetOutputTarget"}, | ||
| 31 | {16, nullptr, "SetInputTargetForceEnabled"}, | ||
| 32 | {17, &AudCtl::SetHeadphoneOutputLevelMode, "SetHeadphoneOutputLevelMode"}, | ||
| 33 | {18, &AudCtl::GetHeadphoneOutputLevelMode, "GetHeadphoneOutputLevelMode"}, | ||
| 34 | {19, nullptr, "AcquireAudioVolumeUpdateEventForPlayReport"}, | ||
| 35 | {20, nullptr, "AcquireAudioOutputDeviceUpdateEventForPlayReport"}, | ||
| 36 | {21, nullptr, "GetAudioOutputTargetForPlayReport"}, | ||
| 37 | {22, nullptr, "NotifyHeadphoneVolumeWarningDisplayedEvent"}, | ||
| 38 | {23, nullptr, "SetSystemOutputMasterVolume"}, | ||
| 39 | {24, nullptr, "GetSystemOutputMasterVolume"}, | ||
| 40 | {25, nullptr, "GetAudioVolumeDataForPlayReport"}, | ||
| 41 | {26, nullptr, "UpdateHeadphoneSettings"}, | ||
| 42 | {27, nullptr, "SetVolumeMappingTableForDev"}, | ||
| 43 | {28, nullptr, "GetAudioOutputChannelCountForPlayReport"}, | ||
| 44 | {29, nullptr, "BindAudioOutputChannelCountUpdateEventForPlayReport"}, | ||
| 45 | {30, &AudCtl::SetSpeakerAutoMuteEnabled, "SetSpeakerAutoMuteEnabled"}, | ||
| 46 | {31, &AudCtl::IsSpeakerAutoMuteEnabled, "IsSpeakerAutoMuteEnabled"}, | ||
| 47 | {32, nullptr, "GetActiveOutputTarget"}, | ||
| 48 | {33, nullptr, "GetTargetDeviceInfo"}, | ||
| 49 | {34, nullptr, "AcquireTargetNotification"}, | ||
| 50 | {35, nullptr, "SetHearingProtectionSafeguardTimerRemainingTimeForDebug"}, | ||
| 51 | {36, nullptr, "GetHearingProtectionSafeguardTimerRemainingTimeForDebug"}, | ||
| 52 | {37, nullptr, "SetHearingProtectionSafeguardEnabled"}, | ||
| 53 | {38, nullptr, "IsHearingProtectionSafeguardEnabled"}, | ||
| 54 | {39, nullptr, "IsHearingProtectionSafeguardMonitoringOutputForDebug"}, | ||
| 55 | {40, nullptr, "GetSystemInformationForDebug"}, | ||
| 56 | {41, nullptr, "SetVolumeButtonLongPressTime"}, | ||
| 57 | {42, nullptr, "SetNativeVolumeForDebug"}, | ||
| 58 | {10000, nullptr, "NotifyAudioOutputTargetForPlayReport"}, | ||
| 59 | {10001, nullptr, "NotifyAudioOutputChannelCountForPlayReport"}, | ||
| 60 | {10002, nullptr, "NotifyUnsupportedUsbOutputDeviceAttachedForPlayReport"}, | ||
| 61 | {10100, nullptr, "GetAudioVolumeDataForPlayReport"}, | ||
| 62 | {10101, nullptr, "BindAudioVolumeUpdateEventForPlayReport"}, | ||
| 63 | {10102, nullptr, "BindAudioOutputTargetUpdateEventForPlayReport"}, | ||
| 64 | {10103, nullptr, "GetAudioOutputTargetForPlayReport"}, | ||
| 65 | {10104, nullptr, "GetAudioOutputChannelCountForPlayReport"}, | ||
| 66 | {10105, nullptr, "BindAudioOutputChannelCountUpdateEventForPlayReport"}, | ||
| 67 | {10106, nullptr, "GetDefaultAudioOutputTargetForPlayReport"}, | ||
| 68 | {50000, nullptr, "SetAnalogInputBoostGainForPrototyping"}, | ||
| 69 | }; | ||
| 70 | // clang-format on | ||
| 71 | |||
| 72 | RegisterHandlers(functions); | ||
| 73 | |||
| 74 | m_set_sys = | ||
| 75 | system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true); | ||
| 76 | } | ||
| 77 | |||
| 78 | AudCtl::~AudCtl() = default; | ||
| 79 | |||
| 80 | void AudCtl::GetTargetVolumeMin(HLERequestContext& ctx) { | ||
| 81 | LOG_DEBUG(Audio, "called."); | ||
| 82 | |||
| 83 | // This service function is currently hardcoded on the | ||
| 84 | // actual console to this value (as of 8.0.0). | ||
| 85 | constexpr s32 target_min_volume = 0; | ||
| 86 | |||
| 87 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 88 | rb.Push(ResultSuccess); | ||
| 89 | rb.Push(target_min_volume); | ||
| 90 | } | ||
| 91 | |||
| 92 | void AudCtl::GetTargetVolumeMax(HLERequestContext& ctx) { | ||
| 93 | LOG_DEBUG(Audio, "called."); | ||
| 94 | |||
| 95 | // This service function is currently hardcoded on the | ||
| 96 | // actual console to this value (as of 8.0.0). | ||
| 97 | constexpr s32 target_max_volume = 15; | ||
| 98 | |||
| 99 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 100 | rb.Push(ResultSuccess); | ||
| 101 | rb.Push(target_max_volume); | ||
| 102 | } | ||
| 103 | |||
| 104 | void AudCtl::GetAudioOutputMode(HLERequestContext& ctx) { | ||
| 105 | IPC::RequestParser rp{ctx}; | ||
| 106 | const auto target{rp.PopEnum<Set::AudioOutputModeTarget>()}; | ||
| 107 | |||
| 108 | Set::AudioOutputMode output_mode{}; | ||
| 109 | const auto result = m_set_sys->GetAudioOutputMode(&output_mode, target); | ||
| 110 | |||
| 111 | LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode); | ||
| 112 | |||
| 113 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 114 | rb.Push(result); | ||
| 115 | rb.PushEnum(output_mode); | ||
| 116 | } | ||
| 117 | |||
| 118 | void AudCtl::SetAudioOutputMode(HLERequestContext& ctx) { | ||
| 119 | IPC::RequestParser rp{ctx}; | ||
| 120 | const auto target{rp.PopEnum<Set::AudioOutputModeTarget>()}; | ||
| 121 | const auto output_mode{rp.PopEnum<Set::AudioOutputMode>()}; | ||
| 122 | |||
| 123 | const auto result = m_set_sys->SetAudioOutputMode(target, output_mode); | ||
| 124 | |||
| 125 | LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode); | ||
| 126 | |||
| 127 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 128 | rb.Push(result); | ||
| 129 | } | ||
| 130 | |||
| 131 | void AudCtl::GetForceMutePolicy(HLERequestContext& ctx) { | ||
| 132 | LOG_WARNING(Audio, "(STUBBED) called"); | ||
| 133 | |||
| 134 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 135 | rb.Push(ResultSuccess); | ||
| 136 | rb.PushEnum(ForceMutePolicy::Disable); | ||
| 137 | } | ||
| 138 | |||
| 139 | void AudCtl::GetOutputModeSetting(HLERequestContext& ctx) { | ||
| 140 | IPC::RequestParser rp{ctx}; | ||
| 141 | const auto target{rp.PopEnum<Set::AudioOutputModeTarget>()}; | ||
| 142 | |||
| 143 | LOG_WARNING(Audio, "(STUBBED) called, target={}", target); | ||
| 144 | |||
| 145 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 146 | rb.Push(ResultSuccess); | ||
| 147 | rb.PushEnum(Set::AudioOutputMode::ch_7_1); | ||
| 148 | } | ||
| 149 | |||
| 150 | void AudCtl::SetOutputModeSetting(HLERequestContext& ctx) { | ||
| 151 | IPC::RequestParser rp{ctx}; | ||
| 152 | const auto target{rp.PopEnum<Set::AudioOutputModeTarget>()}; | ||
| 153 | const auto output_mode{rp.PopEnum<Set::AudioOutputMode>()}; | ||
| 154 | |||
| 155 | LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode); | ||
| 156 | |||
| 157 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 158 | rb.Push(ResultSuccess); | ||
| 159 | } | ||
| 160 | |||
| 161 | void AudCtl::SetHeadphoneOutputLevelMode(HLERequestContext& ctx) { | ||
| 162 | LOG_WARNING(Audio, "(STUBBED) called"); | ||
| 163 | |||
| 164 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 165 | rb.Push(ResultSuccess); | ||
| 166 | } | ||
| 167 | |||
| 168 | void AudCtl::GetHeadphoneOutputLevelMode(HLERequestContext& ctx) { | ||
| 169 | LOG_WARNING(Audio, "(STUBBED) called"); | ||
| 170 | |||
| 171 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 172 | rb.Push(ResultSuccess); | ||
| 173 | rb.PushEnum(HeadphoneOutputLevelMode::Normal); | ||
| 174 | } | ||
| 175 | |||
| 176 | void AudCtl::SetSpeakerAutoMuteEnabled(HLERequestContext& ctx) { | ||
| 177 | IPC::RequestParser rp{ctx}; | ||
| 178 | const auto is_speaker_auto_mute_enabled{rp.Pop<bool>()}; | ||
| 179 | |||
| 180 | LOG_WARNING(Audio, "(STUBBED) called, is_speaker_auto_mute_enabled={}", | ||
| 181 | is_speaker_auto_mute_enabled); | ||
| 182 | |||
| 183 | const auto result = m_set_sys->SetSpeakerAutoMuteFlag(is_speaker_auto_mute_enabled); | ||
| 184 | |||
| 185 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 186 | rb.Push(result); | ||
| 187 | } | ||
| 188 | |||
| 189 | void AudCtl::IsSpeakerAutoMuteEnabled(HLERequestContext& ctx) { | ||
| 190 | bool is_speaker_auto_mute_enabled{}; | ||
| 191 | const auto result = m_set_sys->GetSpeakerAutoMuteFlag(&is_speaker_auto_mute_enabled); | ||
| 192 | |||
| 193 | LOG_WARNING(Audio, "(STUBBED) called, is_speaker_auto_mute_enabled={}", | ||
| 194 | is_speaker_auto_mute_enabled); | ||
| 195 | |||
| 196 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 197 | rb.Push(result); | ||
| 198 | rb.Push<u8>(is_speaker_auto_mute_enabled); | ||
| 199 | } | ||
| 200 | |||
| 201 | } // namespace Service::Audio | ||
diff --git a/src/core/hle/service/audio/audctl.h b/src/core/hle/service/audio/audctl.h deleted file mode 100644 index 4c90ead70..000000000 --- a/src/core/hle/service/audio/audctl.h +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/service.h" | ||
| 7 | |||
| 8 | namespace Core { | ||
| 9 | class System; | ||
| 10 | } | ||
| 11 | |||
| 12 | namespace Service::Set { | ||
| 13 | class ISystemSettingsServer; | ||
| 14 | } | ||
| 15 | |||
| 16 | namespace Service::Audio { | ||
| 17 | |||
| 18 | class AudCtl final : public ServiceFramework<AudCtl> { | ||
| 19 | public: | ||
| 20 | explicit AudCtl(Core::System& system_); | ||
| 21 | ~AudCtl() override; | ||
| 22 | |||
| 23 | private: | ||
| 24 | enum class ForceMutePolicy { | ||
| 25 | Disable, | ||
| 26 | SpeakerMuteOnHeadphoneUnplugged, | ||
| 27 | }; | ||
| 28 | |||
| 29 | enum class HeadphoneOutputLevelMode { | ||
| 30 | Normal, | ||
| 31 | HighPower, | ||
| 32 | }; | ||
| 33 | |||
| 34 | void GetTargetVolumeMin(HLERequestContext& ctx); | ||
| 35 | void GetTargetVolumeMax(HLERequestContext& ctx); | ||
| 36 | void GetAudioOutputMode(HLERequestContext& ctx); | ||
| 37 | void SetAudioOutputMode(HLERequestContext& ctx); | ||
| 38 | void GetForceMutePolicy(HLERequestContext& ctx); | ||
| 39 | void GetOutputModeSetting(HLERequestContext& ctx); | ||
| 40 | void SetOutputModeSetting(HLERequestContext& ctx); | ||
| 41 | void SetHeadphoneOutputLevelMode(HLERequestContext& ctx); | ||
| 42 | void GetHeadphoneOutputLevelMode(HLERequestContext& ctx); | ||
| 43 | void SetSpeakerAutoMuteEnabled(HLERequestContext& ctx); | ||
| 44 | void IsSpeakerAutoMuteEnabled(HLERequestContext& ctx); | ||
| 45 | void AcquireTargetNotification(HLERequestContext& ctx); | ||
| 46 | |||
| 47 | std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys; | ||
| 48 | }; | ||
| 49 | |||
| 50 | } // namespace Service::Audio | ||
diff --git a/src/core/hle/service/audio/audio.cpp b/src/core/hle/service/audio/audio.cpp index dccd16309..44af030eb 100644 --- a/src/core/hle/service/audio/audio.cpp +++ b/src/core/hle/service/audio/audio.cpp | |||
| @@ -2,9 +2,9 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/core.h" | 4 | #include "core/core.h" |
| 5 | #include "core/hle/service/audio/audctl.h" | ||
| 6 | #include "core/hle/service/audio/audin_u.h" | 5 | #include "core/hle/service/audio/audin_u.h" |
| 7 | #include "core/hle/service/audio/audio.h" | 6 | #include "core/hle/service/audio/audio.h" |
| 7 | #include "core/hle/service/audio/audio_controller.h" | ||
| 8 | #include "core/hle/service/audio/audout_u.h" | 8 | #include "core/hle/service/audio/audout_u.h" |
| 9 | #include "core/hle/service/audio/audrec_a.h" | 9 | #include "core/hle/service/audio/audrec_a.h" |
| 10 | #include "core/hle/service/audio/audrec_u.h" | 10 | #include "core/hle/service/audio/audrec_u.h" |
| @@ -18,7 +18,7 @@ namespace Service::Audio { | |||
| 18 | void LoopProcess(Core::System& system) { | 18 | void LoopProcess(Core::System& system) { |
| 19 | auto server_manager = std::make_unique<ServerManager>(system); | 19 | auto server_manager = std::make_unique<ServerManager>(system); |
| 20 | 20 | ||
| 21 | server_manager->RegisterNamedService("audctl", std::make_shared<AudCtl>(system)); | 21 | server_manager->RegisterNamedService("audctl", std::make_shared<IAudioController>(system)); |
| 22 | server_manager->RegisterNamedService("audout:u", std::make_shared<AudOutU>(system)); | 22 | server_manager->RegisterNamedService("audout:u", std::make_shared<AudOutU>(system)); |
| 23 | server_manager->RegisterNamedService("audin:u", std::make_shared<AudInU>(system)); | 23 | server_manager->RegisterNamedService("audin:u", std::make_shared<AudInU>(system)); |
| 24 | server_manager->RegisterNamedService("audrec:a", std::make_shared<AudRecA>(system)); | 24 | server_manager->RegisterNamedService("audrec:a", std::make_shared<AudRecA>(system)); |
diff --git a/src/core/hle/service/audio/audio_controller.cpp b/src/core/hle/service/audio/audio_controller.cpp new file mode 100644 index 000000000..a6da66d0f --- /dev/null +++ b/src/core/hle/service/audio/audio_controller.cpp | |||
| @@ -0,0 +1,174 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "common/logging/log.h" | ||
| 5 | #include "core/hle/service/audio/audio_controller.h" | ||
| 6 | #include "core/hle/service/cmif_serialization.h" | ||
| 7 | #include "core/hle/service/ipc_helpers.h" | ||
| 8 | #include "core/hle/service/set/system_settings_server.h" | ||
| 9 | #include "core/hle/service/sm/sm.h" | ||
| 10 | |||
| 11 | namespace Service::Audio { | ||
| 12 | |||
| 13 | IAudioController::IAudioController(Core::System& system_) | ||
| 14 | : ServiceFramework{system_, "audctl"}, service_context{system, "audctl"} { | ||
| 15 | // clang-format off | ||
| 16 | static const FunctionInfo functions[] = { | ||
| 17 | {0, nullptr, "GetTargetVolume"}, | ||
| 18 | {1, nullptr, "SetTargetVolume"}, | ||
| 19 | {2, C<&IAudioController::GetTargetVolumeMin>, "GetTargetVolumeMin"}, | ||
| 20 | {3, C<&IAudioController::GetTargetVolumeMax>, "GetTargetVolumeMax"}, | ||
| 21 | {4, nullptr, "IsTargetMute"}, | ||
| 22 | {5, nullptr, "SetTargetMute"}, | ||
| 23 | {6, nullptr, "IsTargetConnected"}, | ||
| 24 | {7, nullptr, "SetDefaultTarget"}, | ||
| 25 | {8, nullptr, "GetDefaultTarget"}, | ||
| 26 | {9, C<&IAudioController::GetAudioOutputMode>, "GetAudioOutputMode"}, | ||
| 27 | {10, C<&IAudioController::SetAudioOutputMode>, "SetAudioOutputMode"}, | ||
| 28 | {11, nullptr, "SetForceMutePolicy"}, | ||
| 29 | {12, C<&IAudioController::GetForceMutePolicy>, "GetForceMutePolicy"}, | ||
| 30 | {13, C<&IAudioController::GetOutputModeSetting>, "GetOutputModeSetting"}, | ||
| 31 | {14, C<&IAudioController::SetOutputModeSetting>, "SetOutputModeSetting"}, | ||
| 32 | {15, nullptr, "SetOutputTarget"}, | ||
| 33 | {16, nullptr, "SetInputTargetForceEnabled"}, | ||
| 34 | {17, C<&IAudioController::SetHeadphoneOutputLevelMode>, "SetHeadphoneOutputLevelMode"}, | ||
| 35 | {18, C<&IAudioController::GetHeadphoneOutputLevelMode>, "GetHeadphoneOutputLevelMode"}, | ||
| 36 | {19, nullptr, "AcquireAudioVolumeUpdateEventForPlayReport"}, | ||
| 37 | {20, nullptr, "AcquireAudioOutputDeviceUpdateEventForPlayReport"}, | ||
| 38 | {21, nullptr, "GetAudioOutputTargetForPlayReport"}, | ||
| 39 | {22, nullptr, "NotifyHeadphoneVolumeWarningDisplayedEvent"}, | ||
| 40 | {23, nullptr, "SetSystemOutputMasterVolume"}, | ||
| 41 | {24, nullptr, "GetSystemOutputMasterVolume"}, | ||
| 42 | {25, nullptr, "GetAudioVolumeDataForPlayReport"}, | ||
| 43 | {26, nullptr, "UpdateHeadphoneSettings"}, | ||
| 44 | {27, nullptr, "SetVolumeMappingTableForDev"}, | ||
| 45 | {28, nullptr, "GetAudioOutputChannelCountForPlayReport"}, | ||
| 46 | {29, nullptr, "BindAudioOutputChannelCountUpdateEventForPlayReport"}, | ||
| 47 | {30, C<&IAudioController::SetSpeakerAutoMuteEnabled>, "SetSpeakerAutoMuteEnabled"}, | ||
| 48 | {31, C<&IAudioController::IsSpeakerAutoMuteEnabled>, "IsSpeakerAutoMuteEnabled"}, | ||
| 49 | {32, nullptr, "GetActiveOutputTarget"}, | ||
| 50 | {33, nullptr, "GetTargetDeviceInfo"}, | ||
| 51 | {34, C<&IAudioController::AcquireTargetNotification>, "AcquireTargetNotification"}, | ||
| 52 | {35, nullptr, "SetHearingProtectionSafeguardTimerRemainingTimeForDebug"}, | ||
| 53 | {36, nullptr, "GetHearingProtectionSafeguardTimerRemainingTimeForDebug"}, | ||
| 54 | {37, nullptr, "SetHearingProtectionSafeguardEnabled"}, | ||
| 55 | {38, nullptr, "IsHearingProtectionSafeguardEnabled"}, | ||
| 56 | {39, nullptr, "IsHearingProtectionSafeguardMonitoringOutputForDebug"}, | ||
| 57 | {40, nullptr, "GetSystemInformationForDebug"}, | ||
| 58 | {41, nullptr, "SetVolumeButtonLongPressTime"}, | ||
| 59 | {42, nullptr, "SetNativeVolumeForDebug"}, | ||
| 60 | {10000, nullptr, "NotifyAudioOutputTargetForPlayReport"}, | ||
| 61 | {10001, nullptr, "NotifyAudioOutputChannelCountForPlayReport"}, | ||
| 62 | {10002, nullptr, "NotifyUnsupportedUsbOutputDeviceAttachedForPlayReport"}, | ||
| 63 | {10100, nullptr, "GetAudioVolumeDataForPlayReport"}, | ||
| 64 | {10101, nullptr, "BindAudioVolumeUpdateEventForPlayReport"}, | ||
| 65 | {10102, nullptr, "BindAudioOutputTargetUpdateEventForPlayReport"}, | ||
| 66 | {10103, nullptr, "GetAudioOutputTargetForPlayReport"}, | ||
| 67 | {10104, nullptr, "GetAudioOutputChannelCountForPlayReport"}, | ||
| 68 | {10105, nullptr, "BindAudioOutputChannelCountUpdateEventForPlayReport"}, | ||
| 69 | {10106, nullptr, "GetDefaultAudioOutputTargetForPlayReport"}, | ||
| 70 | {50000, nullptr, "SetAnalogInputBoostGainForPrototyping"}, | ||
| 71 | }; | ||
| 72 | // clang-format on | ||
| 73 | |||
| 74 | RegisterHandlers(functions); | ||
| 75 | |||
| 76 | m_set_sys = | ||
| 77 | system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true); | ||
| 78 | notification_event = service_context.CreateEvent("IAudioController:NotificationEvent"); | ||
| 79 | } | ||
| 80 | |||
| 81 | IAudioController::~IAudioController() { | ||
| 82 | service_context.CloseEvent(notification_event); | ||
| 83 | }; | ||
| 84 | |||
| 85 | Result IAudioController::GetTargetVolumeMin(Out<s32> out_target_min_volume) { | ||
| 86 | LOG_DEBUG(Audio, "called."); | ||
| 87 | |||
| 88 | // This service function is currently hardcoded on the | ||
| 89 | // actual console to this value (as of 8.0.0). | ||
| 90 | *out_target_min_volume = 0; | ||
| 91 | R_SUCCEED(); | ||
| 92 | } | ||
| 93 | |||
| 94 | Result IAudioController::GetTargetVolumeMax(Out<s32> out_target_max_volume) { | ||
| 95 | LOG_DEBUG(Audio, "called."); | ||
| 96 | |||
| 97 | // This service function is currently hardcoded on the | ||
| 98 | // actual console to this value (as of 8.0.0). | ||
| 99 | *out_target_max_volume = 15; | ||
| 100 | R_SUCCEED(); | ||
| 101 | } | ||
| 102 | |||
| 103 | Result IAudioController::GetAudioOutputMode(Out<Set::AudioOutputMode> out_output_mode, | ||
| 104 | Set::AudioOutputModeTarget target) { | ||
| 105 | const auto result = m_set_sys->GetAudioOutputMode(out_output_mode, target); | ||
| 106 | |||
| 107 | LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, *out_output_mode); | ||
| 108 | R_RETURN(result); | ||
| 109 | } | ||
| 110 | |||
| 111 | Result IAudioController::SetAudioOutputMode(Set::AudioOutputModeTarget target, | ||
| 112 | Set::AudioOutputMode output_mode) { | ||
| 113 | LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode); | ||
| 114 | |||
| 115 | R_RETURN(m_set_sys->SetAudioOutputMode(target, output_mode)); | ||
| 116 | } | ||
| 117 | |||
| 118 | Result IAudioController::GetForceMutePolicy(Out<ForceMutePolicy> out_mute_policy) { | ||
| 119 | LOG_WARNING(Audio, "(STUBBED) called"); | ||
| 120 | |||
| 121 | // Removed on FW 13.2.1+ | ||
| 122 | *out_mute_policy = ForceMutePolicy::Disable; | ||
| 123 | R_SUCCEED(); | ||
| 124 | } | ||
| 125 | |||
| 126 | Result IAudioController::GetOutputModeSetting(Out<Set::AudioOutputMode> out_output_mode, | ||
| 127 | Set::AudioOutputModeTarget target) { | ||
| 128 | LOG_WARNING(Audio, "(STUBBED) called, target={}", target); | ||
| 129 | |||
| 130 | *out_output_mode = Set::AudioOutputMode::ch_7_1; | ||
| 131 | R_SUCCEED(); | ||
| 132 | } | ||
| 133 | |||
| 134 | Result IAudioController::SetOutputModeSetting(Set::AudioOutputModeTarget target, | ||
| 135 | Set::AudioOutputMode output_mode) { | ||
| 136 | LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode); | ||
| 137 | R_SUCCEED(); | ||
| 138 | } | ||
| 139 | |||
| 140 | Result IAudioController::SetHeadphoneOutputLevelMode(HeadphoneOutputLevelMode output_level_mode) { | ||
| 141 | LOG_WARNING(Audio, "(STUBBED) called"); | ||
| 142 | R_SUCCEED(); | ||
| 143 | } | ||
| 144 | |||
| 145 | Result IAudioController::GetHeadphoneOutputLevelMode( | ||
| 146 | Out<HeadphoneOutputLevelMode> out_output_level_mode) { | ||
| 147 | LOG_INFO(Audio, "called"); | ||
| 148 | |||
| 149 | *out_output_level_mode = HeadphoneOutputLevelMode::Normal; | ||
| 150 | R_SUCCEED(); | ||
| 151 | } | ||
| 152 | |||
| 153 | Result IAudioController::SetSpeakerAutoMuteEnabled(bool is_speaker_auto_mute_enabled) { | ||
| 154 | LOG_INFO(Audio, "called, is_speaker_auto_mute_enabled={}", is_speaker_auto_mute_enabled); | ||
| 155 | |||
| 156 | R_RETURN(m_set_sys->SetSpeakerAutoMuteFlag(is_speaker_auto_mute_enabled)); | ||
| 157 | } | ||
| 158 | |||
| 159 | Result IAudioController::IsSpeakerAutoMuteEnabled(Out<bool> out_is_speaker_auto_mute_enabled) { | ||
| 160 | const auto result = m_set_sys->GetSpeakerAutoMuteFlag(out_is_speaker_auto_mute_enabled); | ||
| 161 | |||
| 162 | LOG_INFO(Audio, "called, is_speaker_auto_mute_enabled={}", *out_is_speaker_auto_mute_enabled); | ||
| 163 | R_RETURN(result); | ||
| 164 | } | ||
| 165 | |||
| 166 | Result IAudioController::AcquireTargetNotification( | ||
| 167 | OutCopyHandle<Kernel::KReadableEvent> out_notification_event) { | ||
| 168 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 169 | |||
| 170 | *out_notification_event = ¬ification_event->GetReadableEvent(); | ||
| 171 | R_SUCCEED(); | ||
| 172 | } | ||
| 173 | |||
| 174 | } // namespace Service::Audio | ||
diff --git a/src/core/hle/service/audio/audio_controller.h b/src/core/hle/service/audio/audio_controller.h new file mode 100644 index 000000000..9e8514373 --- /dev/null +++ b/src/core/hle/service/audio/audio_controller.h | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | #include "core/hle/service/set/settings_types.h" | ||
| 9 | |||
| 10 | namespace Core { | ||
| 11 | class System; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::Set { | ||
| 15 | class ISystemSettingsServer; | ||
| 16 | } | ||
| 17 | |||
| 18 | namespace Service::Audio { | ||
| 19 | |||
| 20 | class IAudioController final : public ServiceFramework<IAudioController> { | ||
| 21 | public: | ||
| 22 | explicit IAudioController(Core::System& system_); | ||
| 23 | ~IAudioController() override; | ||
| 24 | |||
| 25 | private: | ||
| 26 | enum class ForceMutePolicy { | ||
| 27 | Disable, | ||
| 28 | SpeakerMuteOnHeadphoneUnplugged, | ||
| 29 | }; | ||
| 30 | |||
| 31 | enum class HeadphoneOutputLevelMode { | ||
| 32 | Normal, | ||
| 33 | HighPower, | ||
| 34 | }; | ||
| 35 | |||
| 36 | Result GetTargetVolumeMin(Out<s32> out_target_min_volume); | ||
| 37 | Result GetTargetVolumeMax(Out<s32> out_target_max_volume); | ||
| 38 | Result GetAudioOutputMode(Out<Set::AudioOutputMode> out_output_mode, | ||
| 39 | Set::AudioOutputModeTarget target); | ||
| 40 | Result SetAudioOutputMode(Set::AudioOutputModeTarget target, Set::AudioOutputMode output_mode); | ||
| 41 | Result GetForceMutePolicy(Out<ForceMutePolicy> out_mute_policy); | ||
| 42 | Result GetOutputModeSetting(Out<Set::AudioOutputMode> out_output_mode, | ||
| 43 | Set::AudioOutputModeTarget target); | ||
| 44 | Result SetOutputModeSetting(Set::AudioOutputModeTarget target, | ||
| 45 | Set::AudioOutputMode output_mode); | ||
| 46 | Result SetHeadphoneOutputLevelMode(HeadphoneOutputLevelMode output_level_mode); | ||
| 47 | Result GetHeadphoneOutputLevelMode(Out<HeadphoneOutputLevelMode> out_output_level_mode); | ||
| 48 | Result SetSpeakerAutoMuteEnabled(bool is_speaker_auto_mute_enabled); | ||
| 49 | Result IsSpeakerAutoMuteEnabled(Out<bool> out_is_speaker_auto_mute_enabled); | ||
| 50 | Result AcquireTargetNotification(OutCopyHandle<Kernel::KReadableEvent> out_notification_event); | ||
| 51 | |||
| 52 | KernelHelpers::ServiceContext service_context; | ||
| 53 | |||
| 54 | Kernel::KEvent* notification_event; | ||
| 55 | std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys; | ||
| 56 | }; | ||
| 57 | |||
| 58 | } // namespace Service::Audio | ||