From 40c19a9085acaddec8104f837e822b1c05831e7f Mon Sep 17 00:00:00 2001 From: "Herman S." <429230+has207@users.noreply.github.com> Date: Mon, 3 Nov 2025 14:38:58 +0900 Subject: [PATCH] [XMA] Added SignalWork calls in XMASetInputBuffer{0,1}Valid This should wake up the XMA decoder worker thread when new audio data is provided instead of only when the contexts are initially enabled or decoder is shutting down. --- src/xenia/apu/xma_decoder.h | 6 ++++++ src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/xenia/apu/xma_decoder.h b/src/xenia/apu/xma_decoder.h index 753ebe703..ac9453a88 100644 --- a/src/xenia/apu/xma_decoder.h +++ b/src/xenia/apu/xma_decoder.h @@ -51,6 +51,12 @@ class XmaDecoder { void Pause(); void Resume(); + void SignalWork() { + if (work_event_) { + work_event_->Set(); + } + } + protected: int GetContextId(uint32_t guest_ptr); diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc index b529ffc41..dbd07cf54 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc @@ -260,6 +260,12 @@ dword_result_t XMASetInputBuffer0Valid_entry(lpvoid_t context_ptr) { context.input_buffer_0_valid = 1; context.Store(context_ptr); + // Wake up the worker thread so it can process the new input data. + auto audio_system = kernel_state()->emulator()->audio_system(); + if (audio_system) { + audio_system->xma_decoder()->SignalWork(); + } + return 0; } DECLARE_XBOXKRNL_EXPORT2(XMASetInputBuffer0Valid, kAudio, kImplemented, @@ -301,6 +307,12 @@ dword_result_t XMASetInputBuffer1Valid_entry(lpvoid_t context_ptr) { context.input_buffer_1_valid = 1; context.Store(context_ptr); + // Wake up the worker thread so it can process the new input data. + auto audio_system = kernel_state()->emulator()->audio_system(); + if (audio_system) { + audio_system->xma_decoder()->SignalWork(); + } + return 0; } DECLARE_XBOXKRNL_EXPORT2(XMASetInputBuffer1Valid, kAudio, kImplemented,