From 7a2f3fdda962b4a7870af07b79e00456fb8b1fbc Mon Sep 17 00:00:00 2001 From: PabloMK7 Date: Sun, 21 Dec 2025 22:39:05 +0100 Subject: [PATCH] audio_core: Update teakra for new memory ownership --- externals/teakra | 2 +- src/audio_core/dsp_interface.cpp | 2 +- src/audio_core/dsp_interface.h | 2 +- src/audio_core/hle/hle.cpp | 4 ++-- src/audio_core/hle/hle.h | 2 +- src/audio_core/lle/lle.cpp | 18 ++++++++++-------- src/audio_core/lle/lle.h | 2 +- src/core/memory.cpp | 5 +++-- src/core/memory.h | 3 ++- .../merry_audio/service_fixture.cpp | 7 +++++-- 10 files changed, 27 insertions(+), 20 deletions(-) diff --git a/externals/teakra b/externals/teakra index 01db7cdd0..3d697a18d 160000 --- a/externals/teakra +++ b/externals/teakra @@ -1 +1 @@ -Subproject commit 01db7cdd00aabcce559a8dddce8798dabb71949b +Subproject commit 3d697a18df504f4677b65129d9ab14c7c597e3eb diff --git a/src/audio_core/dsp_interface.cpp b/src/audio_core/dsp_interface.cpp index 5f85b67e4..259459a5b 100644 --- a/src/audio_core/dsp_interface.cpp +++ b/src/audio_core/dsp_interface.cpp @@ -1,4 +1,4 @@ -// Copyright 2017 Citra Emulator Project +// Copyright Citra Emulator Project / Azahar Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. diff --git a/src/audio_core/dsp_interface.h b/src/audio_core/dsp_interface.h index 5ec41691a..6e7ded2c1 100644 --- a/src/audio_core/dsp_interface.h +++ b/src/audio_core/dsp_interface.h @@ -1,4 +1,4 @@ -// Copyright 2017 Citra Emulator Project +// Copyright Citra Emulator Project / Azahar Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. diff --git a/src/audio_core/hle/hle.cpp b/src/audio_core/hle/hle.cpp index 45165a2e8..fa3825ef6 100644 --- a/src/audio_core/hle/hle.cpp +++ b/src/audio_core/hle/hle.cpp @@ -1,4 +1,4 @@ -// Copyright 2017 Citra Emulator Project +// Copyright Citra Emulator Project / Azahar Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -113,7 +113,7 @@ private: DspHle::Impl::Impl(DspHle& parent_, Memory::MemorySystem& memory, Core::Timing& timing) : parent(parent_), core_timing(timing) { - dsp_memory = reinterpret_cast(memory.GetDspMemory().data()); + dsp_memory = reinterpret_cast(memory.GetDspMemory(0)); dsp_memory->raw_memory.fill(0); for (auto& source : sources) { diff --git a/src/audio_core/hle/hle.h b/src/audio_core/hle/hle.h index d1b34b455..1dba7450a 100644 --- a/src/audio_core/hle/hle.h +++ b/src/audio_core/hle/hle.h @@ -1,4 +1,4 @@ -// Copyright 2017 Citra Emulator Project +// Copyright Citra Emulator Project / Azahar Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. diff --git a/src/audio_core/lle/lle.cpp b/src/audio_core/lle/lle.cpp index 8a9377578..0e301f72d 100644 --- a/src/audio_core/lle/lle.cpp +++ b/src/audio_core/lle/lle.cpp @@ -1,4 +1,4 @@ -// Copyright 2018 Citra Emulator Project +// Copyright Citra Emulator Project / Azahar Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -121,7 +121,9 @@ static u8 PipeIndexToSlotIndex(u8 pipe_index, PipeDirection direction) { } struct DspLle::Impl final { - Impl(Core::Timing& timing, bool multithread) : core_timing(timing), multithread(multithread) { + Impl(Core::Timing& timing, Memory::MemorySystem& memory, bool multithread) + : teakra(Teakra::UserConfig{.dsp_memory = memory.GetDspMemory(0)}), core_timing(timing), + multithread(multithread) { teakra_slice_event = core_timing.RegisterEvent( "DSP slice", [this](u64, int late) { TeakraSliceEvent(static_cast(late)); }); } @@ -189,12 +191,12 @@ struct DspLle::Impl final { } u8* GetDspDataPointer(u32 baddr) { - auto& memory = teakra.GetDspMemory(); + uint8_t* memory = teakra.GetDspMemory(); return &memory[DspDataOffset + baddr]; } const u8* GetDspDataPointer(u32 baddr) const { - auto& memory = teakra.GetDspMemory(); + const uint8_t* memory = teakra.GetDspMemory(); return &memory[DspDataOffset + baddr]; } @@ -312,9 +314,9 @@ struct DspLle::Impl final { teakra.Reset(); Dsp1 dsp(buffer); - auto& dsp_memory = teakra.GetDspMemory(); - u8* program = dsp_memory.data(); - u8* data = dsp_memory.data() + DspDataOffset; + auto dsp_memory = teakra.GetDspMemory(); + u8* program = dsp_memory; + u8* data = dsp_memory + DspDataOffset; for (const auto& segment : dsp.segments) { if (segment.memory_type == SegmentType::ProgramA || segment.memory_type == SegmentType::ProgramB) { @@ -465,7 +467,7 @@ DspLle::DspLle(Core::System& system, bool multithread) DspLle::DspLle(Core::System& system, Memory::MemorySystem& memory, Core::Timing& timing, bool multithread) - : DspInterface(system), impl(std::make_unique(timing, multithread)) { + : DspInterface(system), impl(std::make_unique(timing, memory, multithread)) { Teakra::AHBMCallback ahbm; ahbm.read8 = [&memory](u32 address) -> u8 { return *memory.GetFCRAMPointer(address - Memory::FCRAM_PADDR); diff --git a/src/audio_core/lle/lle.h b/src/audio_core/lle/lle.h index d59973f71..7cfd62e29 100644 --- a/src/audio_core/lle/lle.h +++ b/src/audio_core/lle/lle.h @@ -1,4 +1,4 @@ -// Copyright 2018 Citra Emulator Project +// Copyright Citra Emulator Project / Azahar Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. diff --git a/src/core/memory.cpp b/src/core/memory.cpp index cfe6203e9..9ee5136c5 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -989,8 +989,9 @@ MemoryRef MemorySystem::GetFCRAMRef(std::size_t offset) const { return MemoryRef(impl->fcram_mem, offset); } -std::span MemorySystem::GetDspMemory() const { - return std::span{impl->dsp_ram.get(), DSP_RAM_SIZE}; +u8* MemorySystem::GetDspMemory(std::size_t offset) const { + ASSERT(offset <= Memory::DSP_RAM_SIZE); + return impl->dsp_ram.get() + offset; } } // namespace Memory diff --git a/src/core/memory.h b/src/core/memory.h index 4afdbfc70..ada5182b2 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -641,7 +641,8 @@ public: /// Unregisters page table for rasterizer cache marking void UnregisterPageTable(std::shared_ptr page_table); - std::span GetDspMemory() const; + /// Gets pointer to DSP shared memory with given offset + u8* GetDspMemory(std::size_t offset) const; void RasterizerFlushVirtualRegion(VAddr start, u32 size, FlushMode mode); diff --git a/src/tests/audio_core/merryhime_3ds_audio/merry_audio/service_fixture.cpp b/src/tests/audio_core/merryhime_3ds_audio/merry_audio/service_fixture.cpp index e8940100f..7b3169920 100644 --- a/src/tests/audio_core/merryhime_3ds_audio/merry_audio/service_fixture.cpp +++ b/src/tests/audio_core/merryhime_3ds_audio/merry_audio/service_fixture.cpp @@ -1,3 +1,7 @@ +// Copyright Citra Emulator Project / Azahar Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + #include "audio_core/hle/hle.h" #include "audio_core/lle/lle.h" #include "common/settings.h" @@ -85,8 +89,7 @@ Result ServiceFixture::DSP_ReadPipeIfPossible(u32 channel, u32 /*peer*/, void* o Result ServiceFixture::ServiceFixture::DSP_ConvertProcessAddressFromDspDram(u32 dsp_address, u16** host_address) { *host_address = reinterpret_cast( - (dsp_address << 1) + - (reinterpret_cast(memory.GetDspMemory().data()) + 0x40000u)); + (dsp_address << 1) + (reinterpret_cast(memory.GetDspMemory(0)) + 0x40000u)); return ResultSuccess; }