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.
This commit is contained in:
Lioncash 2020-11-26 15:19:08 -05:00
parent 322349e8cc
commit 1a954b2a59
222 changed files with 1221 additions and 907 deletions

View file

@ -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"},

View file

@ -6,11 +6,15 @@
#include "core/hle/service/service.h"
namespace Core {
class System;
}
namespace Service::Audio {
class AudCtl final : public ServiceFramework<AudCtl> {
public:
explicit AudCtl();
explicit AudCtl(Core::System& system_);
~AudCtl() override;
private:

View file

@ -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"},

View file

@ -6,11 +6,15 @@
#include "core/hle/service/service.h"
namespace Core {
class System;
}
namespace Service::Audio {
class AudDbg final : public ServiceFramework<AudDbg> {
public:
explicit AudDbg(const char* name);
explicit AudDbg(Core::System& system_, const char* name);
~AudDbg() override;
};

View file

@ -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"},

View file

@ -6,11 +6,15 @@
#include "core/hle/service/service.h"
namespace Core {
class System;
}
namespace Service::Audio {
class AudInA final : public ServiceFramework<AudInA> {
public:
explicit AudInA();
explicit AudInA(Core::System& system_);
~AudInA() override;
};

View file

@ -11,7 +11,7 @@ namespace Service::Audio {
class IAudioIn final : public ServiceFramework<IAudioIn> {
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<AudInOutParams>(params);
rb.PushIpcInterface<IAudioIn>();
rb.PushIpcInterface<IAudioIn>(system);
}
void AudInU::OpenAudioIn(Kernel::HLERequestContext& ctx) {

View file

@ -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<AudInU> {
public:
explicit AudInU();
explicit AudInU(Core::System& system_);
~AudInU() override;
private:

View file

@ -20,22 +20,22 @@
namespace Service::Audio {
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
std::make_shared<AudCtl>()->InstallAsService(service_manager);
std::make_shared<AudOutA>()->InstallAsService(service_manager);
std::make_shared<AudCtl>(system)->InstallAsService(service_manager);
std::make_shared<AudOutA>(system)->InstallAsService(service_manager);
std::make_shared<AudOutU>(system)->InstallAsService(service_manager);
std::make_shared<AudInA>()->InstallAsService(service_manager);
std::make_shared<AudInU>()->InstallAsService(service_manager);
std::make_shared<AudRecA>()->InstallAsService(service_manager);
std::make_shared<AudRecU>()->InstallAsService(service_manager);
std::make_shared<AudRenA>()->InstallAsService(service_manager);
std::make_shared<AudInA>(system)->InstallAsService(service_manager);
std::make_shared<AudInU>(system)->InstallAsService(service_manager);
std::make_shared<AudRecA>(system)->InstallAsService(service_manager);
std::make_shared<AudRecU>(system)->InstallAsService(service_manager);
std::make_shared<AudRenA>(system)->InstallAsService(service_manager);
std::make_shared<AudRenU>(system)->InstallAsService(service_manager);
std::make_shared<CodecCtl>()->InstallAsService(service_manager);
std::make_shared<HwOpus>()->InstallAsService(service_manager);
std::make_shared<CodecCtl>(system)->InstallAsService(service_manager);
std::make_shared<HwOpus>(system)->InstallAsService(service_manager);
std::make_shared<AudDbg>("audin:d")->InstallAsService(service_manager);
std::make_shared<AudDbg>("audout:d")->InstallAsService(service_manager);
std::make_shared<AudDbg>("audrec:d")->InstallAsService(service_manager);
std::make_shared<AudDbg>("audren:d")->InstallAsService(service_manager);
std::make_shared<AudDbg>(system, "audin:d")->InstallAsService(service_manager);
std::make_shared<AudDbg>(system, "audout:d")->InstallAsService(service_manager);
std::make_shared<AudDbg>(system, "audrec:d")->InstallAsService(service_manager);
std::make_shared<AudDbg>(system, "audren:d")->InstallAsService(service_manager);
}
} // namespace Service::Audio

View file

@ -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"},

View file

@ -6,11 +6,15 @@
#include "core/hle/service/service.h"
namespace Core {
class System;
}
namespace Service::Audio {
class AudOutA final : public ServiceFramework<AudOutA> {
public:
explicit AudOutA();
explicit AudOutA(Core::System& system_);
~AudOutA() override;
};

View file

@ -40,11 +40,11 @@ enum class AudioState : u32 {
class IAudioOut final : public ServiceFramework<IAudioOut> {
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"},

View file

@ -34,8 +34,6 @@ private:
std::vector<std::shared_ptr<IAudioOut>> audio_out_interfaces;
std::unique_ptr<AudioCore::AudioOut> audio_core;
Core::System& system;
};
} // namespace Service::Audio

View file

@ -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"},

View file

@ -6,11 +6,15 @@
#include "core/hle/service/service.h"
namespace Core {
class System;
}
namespace Service::Audio {
class AudRecA final : public ServiceFramework<AudRecA> {
public:
explicit AudRecA();
explicit AudRecA(Core::System& system_);
~AudRecA() override;
};

View file

@ -8,7 +8,8 @@ namespace Service::Audio {
class IFinalOutputRecorder final : public ServiceFramework<IFinalOutputRecorder> {
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"},
};

View file

@ -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<AudRecU> {
public:
explicit AudRecU();
explicit AudRecU(Core::System& system_);
~AudRecU() override;
};

View file

@ -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"},

View file

@ -6,11 +6,15 @@
#include "core/hle/service/service.h"
namespace Core {
class System;
}
namespace Service::Audio {
class AudRenA final : public ServiceFramework<AudRenA> {
public:
explicit AudRenA();
explicit AudRenA(Core::System& system_);
~AudRenA() override;
};

View file

@ -28,7 +28,7 @@ class IAudioRenderer final : public ServiceFramework<IAudioRenderer> {
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<IAudioDevice> {
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"},

View file

@ -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.

View file

@ -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"},

View file

@ -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<CodecCtl> {
public:
explicit CodecCtl();
explicit CodecCtl(Core::System& system_);
~CodecCtl() override;
};

View file

@ -160,8 +160,9 @@ private:
class IHardwareOpusDecoderManager final : public ServiceFramework<IHardwareOpusDecoderManager> {
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<IHardwareOpusDecoderManager>(
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"},

View file

@ -6,11 +6,15 @@
#include "core/hle/service/service.h"
namespace Core {
class System;
}
namespace Service::Audio {
class HwOpus final : public ServiceFramework<HwOpus> {
public:
explicit HwOpus();
explicit HwOpus(Core::System& system_);
~HwOpus() override;
private: