am/applets: Make the applet data broker part of the applet itself.

The accessor should be doing just that, accessing, rather than retaining
the lifetime of the data broker as well.
This commit is contained in:
Lioncash
2018-11-20 12:02:16 -05:00
parent 8b4b560df5
commit 73b7748984
5 changed files with 36 additions and 31 deletions

View File

@ -532,8 +532,7 @@ void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> {
public:
explicit ILibraryAppletAccessor(std::shared_ptr<Applets::Applet> applet)
: ServiceFramework("ILibraryAppletAccessor"), applet(std::move(applet)),
broker(std::make_shared<Applets::AppletDataBroker>()) {
: ServiceFramework("ILibraryAppletAccessor"), applet(std::move(applet)) {
// clang-format off
static const FunctionInfo functions[] = {
{0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"},
@ -562,7 +561,7 @@ public:
private:
void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) {
const auto event = broker->GetStateChangedEvent();
const auto event = applet->GetBroker().GetStateChangedEvent();
event->Signal();
IPC::ResponseBuilder rb{ctx, 2, 1};
@ -590,7 +589,7 @@ private:
void Start(Kernel::HLERequestContext& ctx) {
ASSERT(applet != nullptr);
applet->Initialize(broker);
applet->Initialize();
applet->Execute();
IPC::ResponseBuilder rb{ctx, 2};
@ -601,7 +600,7 @@ private:
void PushInData(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
broker->PushNormalDataFromGame(*rp.PopIpcInterface<IStorage>());
applet->GetBroker().PushNormalDataFromGame(*rp.PopIpcInterface<IStorage>());
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
@ -612,7 +611,7 @@ private:
void PopOutData(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
const auto storage = broker->PopNormalDataToGame();
const auto storage = applet->GetBroker().PopNormalDataToGame();
if (storage == nullptr) {
rb.Push(ERR_NO_DATA_IN_CHANNEL);
return;
@ -626,7 +625,7 @@ private:
void PushInteractiveInData(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
broker->PushInteractiveDataFromGame(*rp.PopIpcInterface<IStorage>());
applet->GetBroker().PushInteractiveDataFromGame(*rp.PopIpcInterface<IStorage>());
ASSERT(applet->IsInitialized());
applet->ExecuteInteractive();
@ -641,7 +640,7 @@ private:
void PopInteractiveOutData(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
const auto storage = broker->PopInteractiveDataToGame();
const auto storage = applet->GetBroker().PopInteractiveDataToGame();
if (storage == nullptr) {
rb.Push(ERR_NO_DATA_IN_CHANNEL);
return;
@ -656,7 +655,7 @@ private:
void GetPopOutDataEvent(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
rb.PushCopyObjects(broker->GetNormalDataEvent());
rb.PushCopyObjects(applet->GetBroker().GetNormalDataEvent());
LOG_DEBUG(Service_AM, "called");
}
@ -664,13 +663,12 @@ private:
void GetPopInteractiveOutDataEvent(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
rb.PushCopyObjects(broker->GetInteractiveDataEvent());
rb.PushCopyObjects(applet->GetBroker().GetInteractiveDataEvent());
LOG_DEBUG(Service_AM, "called");
}
std::shared_ptr<Applets::Applet> applet;
std::shared_ptr<Applets::AppletDataBroker> broker;
};
void IStorage::Open(Kernel::HLERequestContext& ctx) {