audio_core/lle: link ahbm and audio callback

This commit is contained in:
Weiyi Wang 2018-12-06 12:19:58 -05:00
parent 21da135cc6
commit 67213ca855
5 changed files with 21 additions and 3 deletions

View file

@ -44,6 +44,13 @@ void DspInterface::OutputFrame(StereoFrame16& frame) {
fifo.Push(frame.data(), frame.size()); fifo.Push(frame.data(), frame.size());
} }
void DspInterface::OutputSample(std::array<s16, 2> sample) {
if (!sink)
return;
fifo.Push(&sample, 1);
}
void DspInterface::OutputCallback(s16* buffer, std::size_t num_frames) { void DspInterface::OutputCallback(s16* buffer, std::size_t num_frames) {
std::size_t frames_written; std::size_t frames_written;
if (perform_time_stretching) { if (perform_time_stretching) {

View file

@ -103,6 +103,7 @@ public:
protected: protected:
void OutputFrame(StereoFrame16& frame); void OutputFrame(StereoFrame16& frame);
void OutputSample(std::array<s16, 2> sample);
private: private:
void FlushResidualStretcherAudio(); void FlushResidualStretcherAudio();

View file

@ -392,7 +392,17 @@ void DspLle::UnloadComponent() {
impl->UnloadComponent(); impl->UnloadComponent();
} }
DspLle::DspLle() : impl(std::make_unique<Impl>()) {} DspLle::DspLle(Memory::MemorySystem& memory) : impl(std::make_unique<Impl>()) {
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<s16, 2> sample) { OutputSample(sample); });
}
DspLle::~DspLle() = default; DspLle::~DspLle() = default;
} // namespace AudioCore } // namespace AudioCore

View file

@ -10,7 +10,7 @@ namespace AudioCore {
class DspLle final : public DspInterface { class DspLle final : public DspInterface {
public: public:
DspLle(); explicit DspLle(Memory::MemorySystem& memory);
~DspLle(); ~DspLle();
u16 RecvData(u32 register_number) override; u16 RecvData(u32 register_number) override;

View file

@ -190,7 +190,7 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) {
} }
if (Settings::values.enable_dsp_lle) { if (Settings::values.enable_dsp_lle) {
dsp_core = std::make_unique<AudioCore::DspLle>(); dsp_core = std::make_unique<AudioCore::DspLle>(*memory);
} else { } else {
dsp_core = std::make_unique<AudioCore::DspHle>(*memory); dsp_core = std::make_unique<AudioCore::DspHle>(*memory);
} }