diff options
| author | 2021-09-28 23:42:50 -0400 | |
|---|---|---|
| committer | 2021-10-01 23:38:59 -0400 | |
| commit | fadcee14f8fca1b76b4ea48b1cfd136ccae8d182 (patch) | |
| tree | a5787938bc73ff1b0b539e0945d3544d06a7d6d2 /src/core/hle/service/ptm | |
| parent | Merge pull request #7102 from Morph1984/remove-boxcat (diff) | |
| download | yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.gz yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.xz yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.zip | |
service: Replace service event creation with ServiceContext::CreateEvent
The service context helps to manage all created events and allows us to close them upon destruction.
Diffstat (limited to 'src/core/hle/service/ptm')
| -rw-r--r-- | src/core/hle/service/ptm/psm.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/core/hle/service/ptm/psm.cpp b/src/core/hle/service/ptm/psm.cpp index d9897c5c5..22ff5269c 100644 --- a/src/core/hle/service/ptm/psm.cpp +++ b/src/core/hle/service/ptm/psm.cpp | |||
| @@ -8,9 +8,8 @@ | |||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/hle/ipc_helpers.h" | 9 | #include "core/hle/ipc_helpers.h" |
| 10 | #include "core/hle/kernel/k_event.h" | 10 | #include "core/hle/kernel/k_event.h" |
| 11 | #include "core/hle/kernel/k_readable_event.h" | ||
| 12 | #include "core/hle/kernel/k_writable_event.h" | ||
| 13 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/kernel.h" |
| 12 | #include "core/hle/service/kernel_helpers.h" | ||
| 14 | #include "core/hle/service/ptm/psm.h" | 13 | #include "core/hle/service/ptm/psm.h" |
| 15 | #include "core/hle/service/service.h" | 14 | #include "core/hle/service/service.h" |
| 16 | #include "core/hle/service/sm/sm.h" | 15 | #include "core/hle/service/sm/sm.h" |
| @@ -20,7 +19,7 @@ namespace Service::PSM { | |||
| 20 | class IPsmSession final : public ServiceFramework<IPsmSession> { | 19 | class IPsmSession final : public ServiceFramework<IPsmSession> { |
| 21 | public: | 20 | public: |
| 22 | explicit IPsmSession(Core::System& system_) | 21 | explicit IPsmSession(Core::System& system_) |
| 23 | : ServiceFramework{system_, "IPsmSession"}, state_change_event{system.Kernel()} { | 22 | : ServiceFramework{system_, "IPsmSession"}, service_context{system_, "IPsmSession"} { |
| 24 | // clang-format off | 23 | // clang-format off |
| 25 | static const FunctionInfo functions[] = { | 24 | static const FunctionInfo functions[] = { |
| 26 | {0, &IPsmSession::BindStateChangeEvent, "BindStateChangeEvent"}, | 25 | {0, &IPsmSession::BindStateChangeEvent, "BindStateChangeEvent"}, |
| @@ -33,27 +32,28 @@ public: | |||
| 33 | 32 | ||
| 34 | RegisterHandlers(functions); | 33 | RegisterHandlers(functions); |
| 35 | 34 | ||
| 36 | Kernel::KAutoObject::Create(std::addressof(state_change_event)); | 35 | state_change_event = service_context.CreateEvent("IPsmSession::state_change_event"); |
| 37 | state_change_event.Initialize("IPsmSession::state_change_event"); | ||
| 38 | } | 36 | } |
| 39 | 37 | ||
| 40 | ~IPsmSession() override = default; | 38 | ~IPsmSession() override { |
| 39 | service_context.CloseEvent(state_change_event); | ||
| 40 | } | ||
| 41 | 41 | ||
| 42 | void SignalChargerTypeChanged() { | 42 | void SignalChargerTypeChanged() { |
| 43 | if (should_signal && should_signal_charger_type) { | 43 | if (should_signal && should_signal_charger_type) { |
| 44 | state_change_event.GetWritableEvent().Signal(); | 44 | state_change_event->GetWritableEvent().Signal(); |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | void SignalPowerSupplyChanged() { | 48 | void SignalPowerSupplyChanged() { |
| 49 | if (should_signal && should_signal_power_supply) { | 49 | if (should_signal && should_signal_power_supply) { |
| 50 | state_change_event.GetWritableEvent().Signal(); | 50 | state_change_event->GetWritableEvent().Signal(); |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | void SignalBatteryVoltageStateChanged() { | 54 | void SignalBatteryVoltageStateChanged() { |
| 55 | if (should_signal && should_signal_battery_voltage) { | 55 | if (should_signal && should_signal_battery_voltage) { |
| 56 | state_change_event.GetWritableEvent().Signal(); | 56 | state_change_event->GetWritableEvent().Signal(); |
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| 59 | 59 | ||
| @@ -65,7 +65,7 @@ private: | |||
| 65 | 65 | ||
| 66 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 66 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 67 | rb.Push(ResultSuccess); | 67 | rb.Push(ResultSuccess); |
| 68 | rb.PushCopyObjects(state_change_event.GetReadableEvent()); | 68 | rb.PushCopyObjects(state_change_event->GetReadableEvent()); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | void UnbindStateChangeEvent(Kernel::HLERequestContext& ctx) { | 71 | void UnbindStateChangeEvent(Kernel::HLERequestContext& ctx) { |
| @@ -110,11 +110,13 @@ private: | |||
| 110 | rb.Push(ResultSuccess); | 110 | rb.Push(ResultSuccess); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | KernelHelpers::ServiceContext service_context; | ||
| 114 | |||
| 113 | bool should_signal_charger_type{}; | 115 | bool should_signal_charger_type{}; |
| 114 | bool should_signal_power_supply{}; | 116 | bool should_signal_power_supply{}; |
| 115 | bool should_signal_battery_voltage{}; | 117 | bool should_signal_battery_voltage{}; |
| 116 | bool should_signal{}; | 118 | bool should_signal{}; |
| 117 | Kernel::KEvent state_change_event; | 119 | Kernel::KEvent* state_change_event; |
| 118 | }; | 120 | }; |
| 119 | 121 | ||
| 120 | class PSM final : public ServiceFramework<PSM> { | 122 | class PSM final : public ServiceFramework<PSM> { |