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/aoc | |
| 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/aoc')
| -rw-r--r-- | src/core/hle/service/aoc/aoc_u.cpp | 31 | ||||
| -rw-r--r-- | src/core/hle/service/aoc/aoc_u.h | 6 |
2 files changed, 23 insertions, 14 deletions
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index dd945e058..4c54066c6 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp | |||
| @@ -16,8 +16,8 @@ | |||
| 16 | #include "core/file_sys/patch_manager.h" | 16 | #include "core/file_sys/patch_manager.h" |
| 17 | #include "core/file_sys/registered_cache.h" | 17 | #include "core/file_sys/registered_cache.h" |
| 18 | #include "core/hle/ipc_helpers.h" | 18 | #include "core/hle/ipc_helpers.h" |
| 19 | #include "core/hle/kernel/k_event.h" | ||
| 19 | #include "core/hle/kernel/k_process.h" | 20 | #include "core/hle/kernel/k_process.h" |
| 20 | #include "core/hle/kernel/k_readable_event.h" | ||
| 21 | #include "core/hle/kernel/kernel.h" | 21 | #include "core/hle/kernel/kernel.h" |
| 22 | #include "core/hle/service/aoc/aoc_u.h" | 22 | #include "core/hle/service/aoc/aoc_u.h" |
| 23 | #include "core/loader/loader.h" | 23 | #include "core/loader/loader.h" |
| @@ -49,7 +49,8 @@ static std::vector<u64> AccumulateAOCTitleIDs(Core::System& system) { | |||
| 49 | class IPurchaseEventManager final : public ServiceFramework<IPurchaseEventManager> { | 49 | class IPurchaseEventManager final : public ServiceFramework<IPurchaseEventManager> { |
| 50 | public: | 50 | public: |
| 51 | explicit IPurchaseEventManager(Core::System& system_) | 51 | explicit IPurchaseEventManager(Core::System& system_) |
| 52 | : ServiceFramework{system_, "IPurchaseEventManager"}, purchased_event{system.Kernel()} { | 52 | : ServiceFramework{system_, "IPurchaseEventManager"}, service_context{ |
| 53 | system, "IPurchaseEventManager"} { | ||
| 53 | // clang-format off | 54 | // clang-format off |
| 54 | static const FunctionInfo functions[] = { | 55 | static const FunctionInfo functions[] = { |
| 55 | {0, &IPurchaseEventManager::SetDefaultDeliveryTarget, "SetDefaultDeliveryTarget"}, | 56 | {0, &IPurchaseEventManager::SetDefaultDeliveryTarget, "SetDefaultDeliveryTarget"}, |
| @@ -62,8 +63,11 @@ public: | |||
| 62 | 63 | ||
| 63 | RegisterHandlers(functions); | 64 | RegisterHandlers(functions); |
| 64 | 65 | ||
| 65 | Kernel::KAutoObject::Create(std::addressof(purchased_event)); | 66 | purchased_event = service_context.CreateEvent("IPurchaseEventManager:PurchasedEvent"); |
| 66 | purchased_event.Initialize("IPurchaseEventManager:PurchasedEvent"); | 67 | } |
| 68 | |||
| 69 | ~IPurchaseEventManager() override { | ||
| 70 | service_context.CloseEvent(purchased_event); | ||
| 67 | } | 71 | } |
| 68 | 72 | ||
| 69 | private: | 73 | private: |
| @@ -96,15 +100,17 @@ private: | |||
| 96 | 100 | ||
| 97 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 101 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 98 | rb.Push(ResultSuccess); | 102 | rb.Push(ResultSuccess); |
| 99 | rb.PushCopyObjects(purchased_event.GetReadableEvent()); | 103 | rb.PushCopyObjects(purchased_event->GetReadableEvent()); |
| 100 | } | 104 | } |
| 101 | 105 | ||
| 102 | Kernel::KEvent purchased_event; | 106 | KernelHelpers::ServiceContext service_context; |
| 107 | |||
| 108 | Kernel::KEvent* purchased_event; | ||
| 103 | }; | 109 | }; |
| 104 | 110 | ||
| 105 | AOC_U::AOC_U(Core::System& system_) | 111 | AOC_U::AOC_U(Core::System& system_) |
| 106 | : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)}, | 112 | : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)}, |
| 107 | aoc_change_event{system.Kernel()} { | 113 | service_context{system_, "aoc:u"} { |
| 108 | // clang-format off | 114 | // clang-format off |
| 109 | static const FunctionInfo functions[] = { | 115 | static const FunctionInfo functions[] = { |
| 110 | {0, nullptr, "CountAddOnContentByApplicationId"}, | 116 | {0, nullptr, "CountAddOnContentByApplicationId"}, |
| @@ -126,11 +132,12 @@ AOC_U::AOC_U(Core::System& system_) | |||
| 126 | 132 | ||
| 127 | RegisterHandlers(functions); | 133 | RegisterHandlers(functions); |
| 128 | 134 | ||
| 129 | Kernel::KAutoObject::Create(std::addressof(aoc_change_event)); | 135 | aoc_change_event = service_context.CreateEvent("GetAddOnContentListChanged:Event"); |
| 130 | aoc_change_event.Initialize("GetAddOnContentListChanged:Event"); | ||
| 131 | } | 136 | } |
| 132 | 137 | ||
| 133 | AOC_U::~AOC_U() = default; | 138 | AOC_U::~AOC_U() { |
| 139 | service_context.CloseEvent(aoc_change_event); | ||
| 140 | } | ||
| 134 | 141 | ||
| 135 | void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) { | 142 | void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) { |
| 136 | struct Parameters { | 143 | struct Parameters { |
| @@ -254,7 +261,7 @@ void AOC_U::GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx) { | |||
| 254 | 261 | ||
| 255 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 262 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 256 | rb.Push(ResultSuccess); | 263 | rb.Push(ResultSuccess); |
| 257 | rb.PushCopyObjects(aoc_change_event.GetReadableEvent()); | 264 | rb.PushCopyObjects(aoc_change_event->GetReadableEvent()); |
| 258 | } | 265 | } |
| 259 | 266 | ||
| 260 | void AOC_U::GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestContext& ctx) { | 267 | void AOC_U::GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestContext& ctx) { |
| @@ -262,7 +269,7 @@ void AOC_U::GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestConte | |||
| 262 | 269 | ||
| 263 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 270 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 264 | rb.Push(ResultSuccess); | 271 | rb.Push(ResultSuccess); |
| 265 | rb.PushCopyObjects(aoc_change_event.GetReadableEvent()); | 272 | rb.PushCopyObjects(aoc_change_event->GetReadableEvent()); |
| 266 | } | 273 | } |
| 267 | 274 | ||
| 268 | void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { | 275 | void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { |
diff --git a/src/core/hle/service/aoc/aoc_u.h b/src/core/hle/service/aoc/aoc_u.h index bb6ffb8eb..31d645be8 100644 --- a/src/core/hle/service/aoc/aoc_u.h +++ b/src/core/hle/service/aoc/aoc_u.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "core/hle/kernel/k_event.h" | 7 | #include "core/hle/service/kernel_helpers.h" |
| 8 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 9 | 9 | ||
| 10 | namespace Core { | 10 | namespace Core { |
| @@ -33,7 +33,9 @@ private: | |||
| 33 | void CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx); | 33 | void CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx); |
| 34 | 34 | ||
| 35 | std::vector<u64> add_on_content; | 35 | std::vector<u64> add_on_content; |
| 36 | Kernel::KEvent aoc_change_event; | 36 | KernelHelpers::ServiceContext service_context; |
| 37 | |||
| 38 | Kernel::KEvent* aoc_change_event; | ||
| 37 | }; | 39 | }; |
| 38 | 40 | ||
| 39 | /// Registers all AOC services with the specified service manager. | 41 | /// Registers all AOC services with the specified service manager. |