From 1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 26 Nov 2020 15:19:08 -0500 Subject: service: Eliminate usages of the global system instance Completely removes all usages of the global system instance within the services code by passing in the using system instance to the services. --- src/core/hle/service/audio/audctl.cpp | 2 +- src/core/hle/service/audio/audctl.h | 6 +++++- src/core/hle/service/audio/auddbg.cpp | 2 +- src/core/hle/service/audio/auddbg.h | 6 +++++- src/core/hle/service/audio/audin_a.cpp | 2 +- src/core/hle/service/audio/audin_a.h | 6 +++++- src/core/hle/service/audio/audin_u.cpp | 6 +++--- src/core/hle/service/audio/audin_u.h | 6 +++++- src/core/hle/service/audio/audio.cpp | 26 +++++++++++++------------- src/core/hle/service/audio/audout_a.cpp | 2 +- src/core/hle/service/audio/audout_a.h | 6 +++++- src/core/hle/service/audio/audout_u.cpp | 12 ++++++------ src/core/hle/service/audio/audout_u.h | 2 -- src/core/hle/service/audio/audrec_a.cpp | 2 +- src/core/hle/service/audio/audrec_a.h | 6 +++++- src/core/hle/service/audio/audrec_u.cpp | 5 +++-- src/core/hle/service/audio/audrec_u.h | 6 +++--- src/core/hle/service/audio/audren_a.cpp | 2 +- src/core/hle/service/audio/audren_a.h | 6 +++++- src/core/hle/service/audio/audren_u.cpp | 8 ++++---- src/core/hle/service/audio/audren_u.h | 1 - src/core/hle/service/audio/codecctl.cpp | 5 +---- src/core/hle/service/audio/codecctl.h | 6 +++--- src/core/hle/service/audio/hwopus.cpp | 9 +++++---- src/core/hle/service/audio/hwopus.h | 6 +++++- 25 files changed, 87 insertions(+), 59 deletions(-) (limited to 'src/core/hle/service/audio') diff --git a/src/core/hle/service/audio/audctl.cpp b/src/core/hle/service/audio/audctl.cpp index 6ddb547fb..84890be72 100644 --- a/src/core/hle/service/audio/audctl.cpp +++ b/src/core/hle/service/audio/audctl.cpp @@ -8,7 +8,7 @@ namespace Service::Audio { -AudCtl::AudCtl() : ServiceFramework{"audctl"} { +AudCtl::AudCtl(Core::System& system_) : ServiceFramework{system_, "audctl"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "GetTargetVolume"}, diff --git a/src/core/hle/service/audio/audctl.h b/src/core/hle/service/audio/audctl.h index c7fafc02e..15f6c77a0 100644 --- a/src/core/hle/service/audio/audctl.h +++ b/src/core/hle/service/audio/audctl.h @@ -6,11 +6,15 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::Audio { class AudCtl final : public ServiceFramework { public: - explicit AudCtl(); + explicit AudCtl(Core::System& system_); ~AudCtl() override; private: diff --git a/src/core/hle/service/audio/auddbg.cpp b/src/core/hle/service/audio/auddbg.cpp index 8fff3e4b4..6264e4bda 100644 --- a/src/core/hle/service/audio/auddbg.cpp +++ b/src/core/hle/service/audio/auddbg.cpp @@ -6,7 +6,7 @@ namespace Service::Audio { -AudDbg::AudDbg(const char* name) : ServiceFramework{name} { +AudDbg::AudDbg(Core::System& system_, const char* name) : ServiceFramework{system_, name} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "RequestSuspendForDebug"}, diff --git a/src/core/hle/service/audio/auddbg.h b/src/core/hle/service/audio/auddbg.h index 6689f4759..d1653eedd 100644 --- a/src/core/hle/service/audio/auddbg.h +++ b/src/core/hle/service/audio/auddbg.h @@ -6,11 +6,15 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::Audio { class AudDbg final : public ServiceFramework { public: - explicit AudDbg(const char* name); + explicit AudDbg(Core::System& system_, const char* name); ~AudDbg() override; }; diff --git a/src/core/hle/service/audio/audin_a.cpp b/src/core/hle/service/audio/audin_a.cpp index ddd12f35e..79c3aa920 100644 --- a/src/core/hle/service/audio/audin_a.cpp +++ b/src/core/hle/service/audio/audin_a.cpp @@ -6,7 +6,7 @@ namespace Service::Audio { -AudInA::AudInA() : ServiceFramework{"audin:a"} { +AudInA::AudInA(Core::System& system_) : ServiceFramework{system_, "audin:a"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "RequestSuspendAudioIns"}, diff --git a/src/core/hle/service/audio/audin_a.h b/src/core/hle/service/audio/audin_a.h index e7623bc29..15120a4b6 100644 --- a/src/core/hle/service/audio/audin_a.h +++ b/src/core/hle/service/audio/audin_a.h @@ -6,11 +6,15 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::Audio { class AudInA final : public ServiceFramework { public: - explicit AudInA(); + explicit AudInA(Core::System& system_); ~AudInA() override; }; diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp index 3e2299426..26a6deddf 100644 --- a/src/core/hle/service/audio/audin_u.cpp +++ b/src/core/hle/service/audio/audin_u.cpp @@ -11,7 +11,7 @@ namespace Service::Audio { class IAudioIn final : public ServiceFramework { public: - IAudioIn() : ServiceFramework("IAudioIn") { + explicit IAudioIn(Core::System& system_) : ServiceFramework{system_, "IAudioIn"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "GetAudioInState"}, @@ -36,7 +36,7 @@ public: } }; -AudInU::AudInU() : ServiceFramework("audin:u") { +AudInU::AudInU(Core::System& system_) : ServiceFramework{system_, "audin:u"} { // clang-format off static const FunctionInfo functions[] = { {0, &AudInU::ListAudioIns, "ListAudioIns"}, @@ -96,7 +96,7 @@ void AudInU::OpenInOutImpl(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 6, 0, 1}; rb.Push(RESULT_SUCCESS); rb.PushRaw(params); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } void AudInU::OpenAudioIn(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/audio/audin_u.h b/src/core/hle/service/audio/audin_u.h index a599f4a64..0d75ae5ac 100644 --- a/src/core/hle/service/audio/audin_u.h +++ b/src/core/hle/service/audio/audin_u.h @@ -6,6 +6,10 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Kernel { class HLERequestContext; } @@ -14,7 +18,7 @@ namespace Service::Audio { class AudInU final : public ServiceFramework { public: - explicit AudInU(); + explicit AudInU(Core::System& system_); ~AudInU() override; private: diff --git a/src/core/hle/service/audio/audio.cpp b/src/core/hle/service/audio/audio.cpp index 1781bec83..b3f24f9bb 100644 --- a/src/core/hle/service/audio/audio.cpp +++ b/src/core/hle/service/audio/audio.cpp @@ -20,22 +20,22 @@ namespace Service::Audio { void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { - std::make_shared()->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); std::make_shared(system)->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); std::make_shared(system)->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); - std::make_shared("audin:d")->InstallAsService(service_manager); - std::make_shared("audout:d")->InstallAsService(service_manager); - std::make_shared("audrec:d")->InstallAsService(service_manager); - std::make_shared("audren:d")->InstallAsService(service_manager); + std::make_shared(system, "audin:d")->InstallAsService(service_manager); + std::make_shared(system, "audout:d")->InstallAsService(service_manager); + std::make_shared(system, "audrec:d")->InstallAsService(service_manager); + std::make_shared(system, "audren:d")->InstallAsService(service_manager); } } // namespace Service::Audio diff --git a/src/core/hle/service/audio/audout_a.cpp b/src/core/hle/service/audio/audout_a.cpp index 85febbca3..19825fd5d 100644 --- a/src/core/hle/service/audio/audout_a.cpp +++ b/src/core/hle/service/audio/audout_a.cpp @@ -6,7 +6,7 @@ namespace Service::Audio { -AudOutA::AudOutA() : ServiceFramework{"audout:a"} { +AudOutA::AudOutA(Core::System& system_) : ServiceFramework{system_, "audout:a"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "RequestSuspendAudioOuts"}, diff --git a/src/core/hle/service/audio/audout_a.h b/src/core/hle/service/audio/audout_a.h index d65b66e8e..2043dfb77 100644 --- a/src/core/hle/service/audio/audout_a.h +++ b/src/core/hle/service/audio/audout_a.h @@ -6,11 +6,15 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::Audio { class AudOutA final : public ServiceFramework { public: - explicit AudOutA(); + explicit AudOutA(Core::System& system_); ~AudOutA() override; }; diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 9b4910e53..145f47ee2 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp @@ -40,11 +40,11 @@ enum class AudioState : u32 { class IAudioOut final : public ServiceFramework { public: - IAudioOut(Core::System& system, AudoutParams audio_params, AudioCore::AudioOut& audio_core, - std::string&& device_name, std::string&& unique_name) - : ServiceFramework("IAudioOut"), audio_core(audio_core), - device_name(std::move(device_name)), - audio_params(audio_params), main_memory{system.Memory()} { + IAudioOut(Core::System& system_, AudoutParams audio_params_, AudioCore::AudioOut& audio_core_, + std::string&& device_name_, std::string&& unique_name) + : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_}, + device_name{std::move(device_name_)}, audio_params{audio_params_}, main_memory{ + system.Memory()} { // clang-format off static const FunctionInfo functions[] = { {0, &IAudioOut::GetAudioOutState, "GetAudioOutState"}, @@ -213,7 +213,7 @@ private: Core::Memory::Memory& main_memory; }; -AudOutU::AudOutU(Core::System& system_) : ServiceFramework("audout:u"), system{system_} { +AudOutU::AudOutU(Core::System& system_) : ServiceFramework{system_, "audout:u"} { // clang-format off static const FunctionInfo functions[] = { {0, &AudOutU::ListAudioOutsImpl, "ListAudioOuts"}, diff --git a/src/core/hle/service/audio/audout_u.h b/src/core/hle/service/audio/audout_u.h index c9f532ccd..f7ae2f2bf 100644 --- a/src/core/hle/service/audio/audout_u.h +++ b/src/core/hle/service/audio/audout_u.h @@ -34,8 +34,6 @@ private: std::vector> audio_out_interfaces; std::unique_ptr audio_core; - - Core::System& system; }; } // namespace Service::Audio diff --git a/src/core/hle/service/audio/audrec_a.cpp b/src/core/hle/service/audio/audrec_a.cpp index ce1bfb48d..c5ab7cad4 100644 --- a/src/core/hle/service/audio/audrec_a.cpp +++ b/src/core/hle/service/audio/audrec_a.cpp @@ -6,7 +6,7 @@ namespace Service::Audio { -AudRecA::AudRecA() : ServiceFramework{"audrec:a"} { +AudRecA::AudRecA(Core::System& system_) : ServiceFramework{system_, "audrec:a"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "RequestSuspendFinalOutputRecorders"}, diff --git a/src/core/hle/service/audio/audrec_a.h b/src/core/hle/service/audio/audrec_a.h index 384d24c69..2cce90b1d 100644 --- a/src/core/hle/service/audio/audrec_a.h +++ b/src/core/hle/service/audio/audrec_a.h @@ -6,11 +6,15 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::Audio { class AudRecA final : public ServiceFramework { public: - explicit AudRecA(); + explicit AudRecA(Core::System& system_); ~AudRecA() override; }; diff --git a/src/core/hle/service/audio/audrec_u.cpp b/src/core/hle/service/audio/audrec_u.cpp index 1a5aed9ed..eb5c63c62 100644 --- a/src/core/hle/service/audio/audrec_u.cpp +++ b/src/core/hle/service/audio/audrec_u.cpp @@ -8,7 +8,8 @@ namespace Service::Audio { class IFinalOutputRecorder final : public ServiceFramework { public: - IFinalOutputRecorder() : ServiceFramework("IFinalOutputRecorder") { + explicit IFinalOutputRecorder(Core::System& system_) + : ServiceFramework{system_, "IFinalOutputRecorder"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "GetFinalOutputRecorderState"}, @@ -29,7 +30,7 @@ public: } }; -AudRecU::AudRecU() : ServiceFramework("audrec:u") { +AudRecU::AudRecU(Core::System& system_) : ServiceFramework{system_, "audrec:u"} { static const FunctionInfo functions[] = { {0, nullptr, "OpenFinalOutputRecorder"}, }; diff --git a/src/core/hle/service/audio/audrec_u.h b/src/core/hle/service/audio/audrec_u.h index ca3d638e8..f79d49e5c 100644 --- a/src/core/hle/service/audio/audrec_u.h +++ b/src/core/hle/service/audio/audrec_u.h @@ -6,15 +6,15 @@ #include "core/hle/service/service.h" -namespace Kernel { -class HLERequestContext; +namespace Core { +class System; } namespace Service::Audio { class AudRecU final : public ServiceFramework { public: - explicit AudRecU(); + explicit AudRecU(Core::System& system_); ~AudRecU() override; }; diff --git a/src/core/hle/service/audio/audren_a.cpp b/src/core/hle/service/audio/audren_a.cpp index edb66d985..5e9f866f0 100644 --- a/src/core/hle/service/audio/audren_a.cpp +++ b/src/core/hle/service/audio/audren_a.cpp @@ -6,7 +6,7 @@ namespace Service::Audio { -AudRenA::AudRenA() : ServiceFramework{"audren:a"} { +AudRenA::AudRenA(Core::System& system_) : ServiceFramework{system_, "audren:a"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "RequestSuspendAudioRenderers"}, diff --git a/src/core/hle/service/audio/audren_a.h b/src/core/hle/service/audio/audren_a.h index 81fef0ffe..5d0a626ad 100644 --- a/src/core/hle/service/audio/audren_a.h +++ b/src/core/hle/service/audio/audren_a.h @@ -6,11 +6,15 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::Audio { class AudRenA final : public ServiceFramework { public: - explicit AudRenA(); + explicit AudRenA(Core::System& system_); ~AudRenA() override; }; diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index a2d3ded7b..6e7b7316c 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -28,7 +28,7 @@ class IAudioRenderer final : public ServiceFramework { public: explicit IAudioRenderer(Core::System& system, AudioCommon::AudioRendererParameter audren_params, const std::size_t instance_number) - : ServiceFramework("IAudioRenderer") { + : ServiceFramework{system, "IAudioRenderer"} { // clang-format off static const FunctionInfo functions[] = { {0, &IAudioRenderer::GetSampleRate, "GetSampleRate"}, @@ -167,8 +167,8 @@ private: class IAudioDevice final : public ServiceFramework { public: - explicit IAudioDevice(Core::System& system, u32_le revision_num) - : ServiceFramework("IAudioDevice"), revision{revision_num} { + explicit IAudioDevice(Core::System& system_, u32_le revision_num) + : ServiceFramework{system_, "IAudioDevice"}, revision{revision_num} { static const FunctionInfo functions[] = { {0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"}, {1, &IAudioDevice::SetAudioDeviceOutputVolume, "SetAudioDeviceOutputVolume"}, @@ -325,7 +325,7 @@ private: }; // namespace Audio -AudRenU::AudRenU(Core::System& system_) : ServiceFramework("audren:u"), system{system_} { +AudRenU::AudRenU(Core::System& system_) : ServiceFramework{system_, "audren:u"} { // clang-format off static const FunctionInfo functions[] = { {0, &AudRenU::OpenAudioRenderer, "OpenAudioRenderer"}, diff --git a/src/core/hle/service/audio/audren_u.h b/src/core/hle/service/audio/audren_u.h index 4e0ccc792..d693dc406 100644 --- a/src/core/hle/service/audio/audren_u.h +++ b/src/core/hle/service/audio/audren_u.h @@ -31,7 +31,6 @@ private: void OpenAudioRendererImpl(Kernel::HLERequestContext& ctx); std::size_t audren_instance_count = 0; - Core::System& system; }; // Describes a particular audio feature that may be supported in a particular revision. diff --git a/src/core/hle/service/audio/codecctl.cpp b/src/core/hle/service/audio/codecctl.cpp index c6864146d..94afec1b6 100644 --- a/src/core/hle/service/audio/codecctl.cpp +++ b/src/core/hle/service/audio/codecctl.cpp @@ -2,14 +2,11 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" -#include "core/hle/kernel/hle_ipc.h" #include "core/hle/service/audio/codecctl.h" namespace Service::Audio { -CodecCtl::CodecCtl() : ServiceFramework("codecctl") { +CodecCtl::CodecCtl(Core::System& system_) : ServiceFramework{system_, "codecctl"} { static const FunctionInfo functions[] = { {0, nullptr, "InitializeCodecController"}, {1, nullptr, "FinalizeCodecController"}, diff --git a/src/core/hle/service/audio/codecctl.h b/src/core/hle/service/audio/codecctl.h index 2fe75b6e2..58e53259e 100644 --- a/src/core/hle/service/audio/codecctl.h +++ b/src/core/hle/service/audio/codecctl.h @@ -6,15 +6,15 @@ #include "core/hle/service/service.h" -namespace Kernel { -class HLERequestContext; +namespace Core { +class System; } namespace Service::Audio { class CodecCtl final : public ServiceFramework { public: - explicit CodecCtl(); + explicit CodecCtl(Core::System& system_); ~CodecCtl() override; }; diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index f1d81602c..ea3414fd2 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp @@ -160,8 +160,9 @@ private: class IHardwareOpusDecoderManager final : public ServiceFramework { public: - explicit IHardwareOpusDecoderManager(OpusDecoderState decoder_state) - : ServiceFramework("IHardwareOpusDecoderManager"), decoder_state{std::move(decoder_state)} { + explicit IHardwareOpusDecoderManager(Core::System& system_, OpusDecoderState decoder_state) + : ServiceFramework{system_, "IHardwareOpusDecoderManager"}, decoder_state{ + std::move(decoder_state)} { // clang-format off static const FunctionInfo functions[] = { {0, &IHardwareOpusDecoderManager::DecodeInterleavedOld, "DecodeInterleavedOld"}, @@ -287,10 +288,10 @@ void HwOpus::OpenOpusDecoder(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); rb.PushIpcInterface( - OpusDecoderState{std::move(decoder), sample_rate, channel_count}); + system, OpusDecoderState{std::move(decoder), sample_rate, channel_count}); } -HwOpus::HwOpus() : ServiceFramework("hwopus") { +HwOpus::HwOpus(Core::System& system_) : ServiceFramework{system_, "hwopus"} { static const FunctionInfo functions[] = { {0, &HwOpus::OpenOpusDecoder, "OpenOpusDecoder"}, {1, &HwOpus::GetWorkBufferSize, "GetWorkBufferSize"}, diff --git a/src/core/hle/service/audio/hwopus.h b/src/core/hle/service/audio/hwopus.h index 602ede8ba..4f921f18e 100644 --- a/src/core/hle/service/audio/hwopus.h +++ b/src/core/hle/service/audio/hwopus.h @@ -6,11 +6,15 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::Audio { class HwOpus final : public ServiceFramework { public: - explicit HwOpus(); + explicit HwOpus(Core::System& system_); ~HwOpus() override; private: -- cgit v1.2.3