From 1acb03b5797f74cecdfebcfd7510965111b55dad Mon Sep 17 00:00:00 2001 From: SachinVin <26602104+SachinVin@users.noreply.github.com> Date: Wed, 11 Oct 2023 01:22:57 +0530 Subject: [PATCH] dsp_dsp.cpp: fix registering Interrupt handler on loading savestates (#7055) --- src/audio_core/hle/hle.cpp | 3 +-- src/core/hle/service/dsp/dsp_dsp.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/audio_core/hle/hle.cpp b/src/audio_core/hle/hle.cpp index 6b331b277..ecb2fb81c 100644 --- a/src/audio_core/hle/hle.cpp +++ b/src/audio_core/hle/hle.cpp @@ -114,8 +114,7 @@ private: ar& dsp_memory.raw_memory; ar& sources; ar& mixers; - // interrupt_handler is function pointer and cant be serialised, fortunately though, it - // should be registerd before the game has started + // interrupt_handler is reregistered when loading state from DSP_DSP } friend class boost::serialization::access; }; diff --git a/src/core/hle/service/dsp/dsp_dsp.cpp b/src/core/hle/service/dsp/dsp_dsp.cpp index fd28925a0..54cb58071 100644 --- a/src/core/hle/service/dsp/dsp_dsp.cpp +++ b/src/core/hle/service/dsp/dsp_dsp.cpp @@ -394,6 +394,12 @@ DSP_DSP::DSP_DSP(Core::System& system) semaphore_event->SetHLENotifier( [this]() { this->system.DSP().SetSemaphore(preset_semaphore); }); + + system.DSP().SetInterruptHandler([dsp_ref = this](InterruptType type, DspPipe pipe) { + if (dsp_ref) { + dsp_ref->SignalInterrupt(type, pipe); + } + }); } DSP_DSP::~DSP_DSP() { @@ -405,12 +411,6 @@ void InstallInterfaces(Core::System& system) { auto& service_manager = system.ServiceManager(); auto dsp = std::make_shared(system); dsp->InstallAsService(service_manager); - system.DSP().SetInterruptHandler( - [dsp_ref = std::weak_ptr(dsp)](InterruptType type, DspPipe pipe) { - if (auto locked = dsp_ref.lock()) { - locked->SignalInterrupt(type, pipe); - } - }); } } // namespace Service::DSP