diff --git a/src/core/hle/kernel/wait_object.cpp b/src/core/hle/kernel/wait_object.cpp index d64b7def76..51d929d123 100644 --- a/src/core/hle/kernel/wait_object.cpp +++ b/src/core/hle/kernel/wait_object.cpp @@ -86,10 +86,17 @@ void WaitObject::WakeupAllWaitingThreads() { thread->ResumeFromWait(); } + + if (hle_notifier) + hle_notifier(); } const std::vector>& WaitObject::GetWaitingThreads() const { return waiting_threads; } +void WaitObject::SetHLENotifier(std::function callback) { + hle_notifier = callback; +} + } // namespace Kernel diff --git a/src/core/hle/kernel/wait_object.h b/src/core/hle/kernel/wait_object.h index 01fc40a0d4..693ae21866 100644 --- a/src/core/hle/kernel/wait_object.h +++ b/src/core/hle/kernel/wait_object.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include "common/common_types.h" @@ -52,9 +53,15 @@ public: /// Get a const reference to the waiting threads list for debug use const std::vector>& GetWaitingThreads() const; + /// Sets a callback which is called when the object becomes available + void SetHLENotifier(std::function callback); + private: /// Threads waiting for this object to become available std::vector> waiting_threads; + + /// Function to call when this object becomes available + std::function hle_notifier; }; // Specialization of DynamicObjectCast for WaitObjects diff --git a/src/core/hle/service/dsp/dsp_dsp.cpp b/src/core/hle/service/dsp/dsp_dsp.cpp index c885b73fae..062ce85655 100644 --- a/src/core/hle/service/dsp/dsp_dsp.cpp +++ b/src/core/hle/service/dsp/dsp_dsp.cpp @@ -268,12 +268,12 @@ void DSP_DSP::GetSemaphoreEventHandle(Kernel::HLERequestContext& ctx) { void DSP_DSP::SetSemaphoreMask(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x17, 1, 0); - const u32 mask = rp.Pop(); + preset_semaphore = rp.Pop(); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); - LOG_WARNING(Service_DSP, "(STUBBED) called mask=0x{:08X}", mask); + LOG_WARNING(Service_DSP, "(STUBBED) called mask=0x{:04X}", preset_semaphore); } void DSP_DSP::GetHeadphoneStatus(Kernel::HLERequestContext& ctx) { @@ -380,6 +380,9 @@ DSP_DSP::DSP_DSP(Core::System& system) semaphore_event = system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "DSP_DSP::semaphore_event"); + + semaphore_event->SetHLENotifier( + [this]() { this->system.DSP().SetSemaphore(preset_semaphore); }); } DSP_DSP::~DSP_DSP() { diff --git a/src/core/hle/service/dsp/dsp_dsp.h b/src/core/hle/service/dsp/dsp_dsp.h index 2bc601511d..5bf00334b5 100644 --- a/src/core/hle/service/dsp/dsp_dsp.h +++ b/src/core/hle/service/dsp/dsp_dsp.h @@ -257,6 +257,7 @@ private: Core::System& system; Kernel::SharedPtr semaphore_event; + u16 preset_semaphore = 0; Kernel::SharedPtr interrupt_zero = nullptr; /// Currently unknown purpose Kernel::SharedPtr interrupt_one = nullptr; /// Currently unknown purpose