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/btm | |
| 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/btm')
| -rw-r--r-- | src/core/hle/service/btm/btm.cpp | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp index 3ab29036a..780a99c2d 100644 --- a/src/core/hle/service/btm/btm.cpp +++ b/src/core/hle/service/btm/btm.cpp | |||
| @@ -9,9 +9,9 @@ | |||
| 9 | #include "core/hle/ipc_helpers.h" | 9 | #include "core/hle/ipc_helpers.h" |
| 10 | #include "core/hle/kernel/hle_ipc.h" | 10 | #include "core/hle/kernel/hle_ipc.h" |
| 11 | #include "core/hle/kernel/k_event.h" | 11 | #include "core/hle/kernel/k_event.h" |
| 12 | #include "core/hle/kernel/k_readable_event.h" | ||
| 13 | #include "core/hle/kernel/kernel.h" | 12 | #include "core/hle/kernel/kernel.h" |
| 14 | #include "core/hle/service/btm/btm.h" | 13 | #include "core/hle/service/btm/btm.h" |
| 14 | #include "core/hle/service/kernel_helpers.h" | ||
| 15 | #include "core/hle/service/service.h" | 15 | #include "core/hle/service/service.h" |
| 16 | 16 | ||
| 17 | namespace Service::BTM { | 17 | namespace Service::BTM { |
| @@ -19,9 +19,7 @@ namespace Service::BTM { | |||
| 19 | class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { | 19 | class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { |
| 20 | public: | 20 | public: |
| 21 | explicit IBtmUserCore(Core::System& system_) | 21 | explicit IBtmUserCore(Core::System& system_) |
| 22 | : ServiceFramework{system_, "IBtmUserCore"}, scan_event{system.Kernel()}, | 22 | : ServiceFramework{system_, "IBtmUserCore"}, service_context{system_, "IBtmUserCore"} { |
| 23 | connection_event{system.Kernel()}, service_discovery{system.Kernel()}, | ||
| 24 | config_event{system.Kernel()} { | ||
| 25 | // clang-format off | 23 | // clang-format off |
| 26 | static const FunctionInfo functions[] = { | 24 | static const FunctionInfo functions[] = { |
| 27 | {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"}, | 25 | {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"}, |
| @@ -60,15 +58,17 @@ public: | |||
| 60 | // clang-format on | 58 | // clang-format on |
| 61 | RegisterHandlers(functions); | 59 | RegisterHandlers(functions); |
| 62 | 60 | ||
| 63 | Kernel::KAutoObject::Create(std::addressof(scan_event)); | 61 | scan_event = service_context.CreateEvent("IBtmUserCore:ScanEvent"); |
| 64 | Kernel::KAutoObject::Create(std::addressof(connection_event)); | 62 | connection_event = service_context.CreateEvent("IBtmUserCore:ConnectionEvent"); |
| 65 | Kernel::KAutoObject::Create(std::addressof(service_discovery)); | 63 | service_discovery_event = service_context.CreateEvent("IBtmUserCore:DiscoveryEvent"); |
| 66 | Kernel::KAutoObject::Create(std::addressof(config_event)); | 64 | config_event = service_context.CreateEvent("IBtmUserCore:ConfigEvent"); |
| 65 | } | ||
| 67 | 66 | ||
| 68 | scan_event.Initialize("IBtmUserCore:ScanEvent"); | 67 | ~IBtmUserCore() override { |
| 69 | connection_event.Initialize("IBtmUserCore:ConnectionEvent"); | 68 | service_context.CloseEvent(scan_event); |
| 70 | service_discovery.Initialize("IBtmUserCore:Discovery"); | 69 | service_context.CloseEvent(connection_event); |
| 71 | config_event.Initialize("IBtmUserCore:ConfigEvent"); | 70 | service_context.CloseEvent(service_discovery_event); |
| 71 | service_context.CloseEvent(config_event); | ||
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | private: | 74 | private: |
| @@ -77,7 +77,7 @@ private: | |||
| 77 | 77 | ||
| 78 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 78 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 79 | rb.Push(ResultSuccess); | 79 | rb.Push(ResultSuccess); |
| 80 | rb.PushCopyObjects(scan_event.GetReadableEvent()); | 80 | rb.PushCopyObjects(scan_event->GetReadableEvent()); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | void AcquireBleConnectionEvent(Kernel::HLERequestContext& ctx) { | 83 | void AcquireBleConnectionEvent(Kernel::HLERequestContext& ctx) { |
| @@ -85,7 +85,7 @@ private: | |||
| 85 | 85 | ||
| 86 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 86 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 87 | rb.Push(ResultSuccess); | 87 | rb.Push(ResultSuccess); |
| 88 | rb.PushCopyObjects(connection_event.GetReadableEvent()); | 88 | rb.PushCopyObjects(connection_event->GetReadableEvent()); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | void AcquireBleServiceDiscoveryEvent(Kernel::HLERequestContext& ctx) { | 91 | void AcquireBleServiceDiscoveryEvent(Kernel::HLERequestContext& ctx) { |
| @@ -93,7 +93,7 @@ private: | |||
| 93 | 93 | ||
| 94 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 94 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 95 | rb.Push(ResultSuccess); | 95 | rb.Push(ResultSuccess); |
| 96 | rb.PushCopyObjects(service_discovery.GetReadableEvent()); | 96 | rb.PushCopyObjects(service_discovery_event->GetReadableEvent()); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | void AcquireBleMtuConfigEvent(Kernel::HLERequestContext& ctx) { | 99 | void AcquireBleMtuConfigEvent(Kernel::HLERequestContext& ctx) { |
| @@ -101,13 +101,15 @@ private: | |||
| 101 | 101 | ||
| 102 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 102 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 103 | rb.Push(ResultSuccess); | 103 | rb.Push(ResultSuccess); |
| 104 | rb.PushCopyObjects(config_event.GetReadableEvent()); | 104 | rb.PushCopyObjects(config_event->GetReadableEvent()); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | Kernel::KEvent scan_event; | 107 | KernelHelpers::ServiceContext service_context; |
| 108 | Kernel::KEvent connection_event; | 108 | |
| 109 | Kernel::KEvent service_discovery; | 109 | Kernel::KEvent* scan_event; |
| 110 | Kernel::KEvent config_event; | 110 | Kernel::KEvent* connection_event; |
| 111 | Kernel::KEvent* service_discovery_event; | ||
| 112 | Kernel::KEvent* config_event; | ||
| 111 | }; | 113 | }; |
| 112 | 114 | ||
| 113 | class BTM_USR final : public ServiceFramework<BTM_USR> { | 115 | class BTM_USR final : public ServiceFramework<BTM_USR> { |