From 67213ca855198290b689545039a7ba561ec2c3ab Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Thu, 6 Dec 2018 12:19:58 -0500 Subject: [PATCH] audio_core/lle: link ahbm and audio callback --- src/audio_core/dsp_interface.cpp | 7 +++++++ src/audio_core/dsp_interface.h | 1 + src/audio_core/lle/lle.cpp | 12 +++++++++++- src/audio_core/lle/lle.h | 2 +- src/core/core.cpp | 2 +- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/audio_core/dsp_interface.cpp b/src/audio_core/dsp_interface.cpp index d6343d332..f99b3538a 100644 --- a/src/audio_core/dsp_interface.cpp +++ b/src/audio_core/dsp_interface.cpp @@ -44,6 +44,13 @@ void DspInterface::OutputFrame(StereoFrame16& frame) { fifo.Push(frame.data(), frame.size()); } +void DspInterface::OutputSample(std::array sample) { + if (!sink) + return; + + fifo.Push(&sample, 1); +} + void DspInterface::OutputCallback(s16* buffer, std::size_t num_frames) { std::size_t frames_written; if (perform_time_stretching) { diff --git a/src/audio_core/dsp_interface.h b/src/audio_core/dsp_interface.h index 7a16dea0f..e7f996bb6 100644 --- a/src/audio_core/dsp_interface.h +++ b/src/audio_core/dsp_interface.h @@ -103,6 +103,7 @@ public: protected: void OutputFrame(StereoFrame16& frame); + void OutputSample(std::array sample); private: void FlushResidualStretcherAudio(); diff --git a/src/audio_core/lle/lle.cpp b/src/audio_core/lle/lle.cpp index 36ad0c20e..91c68546a 100644 --- a/src/audio_core/lle/lle.cpp +++ b/src/audio_core/lle/lle.cpp @@ -392,7 +392,17 @@ void DspLle::UnloadComponent() { impl->UnloadComponent(); } -DspLle::DspLle() : impl(std::make_unique()) {} +DspLle::DspLle(Memory::MemorySystem& memory) : impl(std::make_unique()) { + Teakra::AHBMCallback ahbm; + ahbm.read8 = [&memory](u32 address) -> u8 { + return *memory.GetFCRAMPointer(address - Memory::FCRAM_PADDR); + }; + ahbm.write8 = [&memory](u32 address, u8 value) { + *memory.GetFCRAMPointer(address - Memory::FCRAM_PADDR) = value; + }; + impl->teakra.SetAHBMCallback(ahbm); + impl->teakra.SetAudioCallback([this](std::array sample) { OutputSample(sample); }); +} DspLle::~DspLle() = default; } // namespace AudioCore diff --git a/src/audio_core/lle/lle.h b/src/audio_core/lle/lle.h index 002de8aa7..c8a6d007b 100644 --- a/src/audio_core/lle/lle.h +++ b/src/audio_core/lle/lle.h @@ -10,7 +10,7 @@ namespace AudioCore { class DspLle final : public DspInterface { public: - DspLle(); + explicit DspLle(Memory::MemorySystem& memory); ~DspLle(); u16 RecvData(u32 register_number) override; diff --git a/src/core/core.cpp b/src/core/core.cpp index f2da40704..b1b2ec138 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -190,7 +190,7 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) { } if (Settings::values.enable_dsp_lle) { - dsp_core = std::make_unique(); + dsp_core = std::make_unique(*memory); } else { dsp_core = std::make_unique(*memory); }