mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-01 16:05:07 +01:00
audiocore/{hle, lle}: remove dependence on static core timing
This commit is contained in:
parent
fa8c530e10
commit
975ee15635
@ -40,7 +40,7 @@ using Service::DSP::DSP_DSP;
|
||||
|
||||
namespace AudioCore {
|
||||
|
||||
DspHle::DspHle() : DspHle(Core::System::GetInstance().Memory()) {}
|
||||
DspHle::DspHle() : DspHle(Core::System::GetInstance().Memory(), Core::System::GetInstance().CoreTiming()) {}
|
||||
|
||||
template <class Archive>
|
||||
void DspHle::serialize(Archive& ar, const unsigned int) {
|
||||
@ -58,7 +58,7 @@ static constexpr u64 audio_frame_ticks = samples_per_frame * 4096 * 2ull; ///< U
|
||||
|
||||
struct DspHle::Impl final {
|
||||
public:
|
||||
explicit Impl(DspHle& parent, Memory::MemorySystem& memory);
|
||||
explicit Impl(DspHle& parent, Memory::MemorySystem& memory, Core::Timing& timing);
|
||||
~Impl();
|
||||
|
||||
DspState GetDspState() const;
|
||||
@ -100,6 +100,7 @@ private:
|
||||
HLE::Mixers mixers{};
|
||||
|
||||
DspHle& parent;
|
||||
Core::Timing& core_timing;
|
||||
Core::TimingEventType* tick_event{};
|
||||
|
||||
std::unique_ptr<HLE::DecoderBase> decoder{};
|
||||
@ -118,7 +119,8 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
|
||||
DspHle::Impl::Impl(DspHle& parent_, Memory::MemorySystem& memory) : parent(parent_) {
|
||||
DspHle::Impl::Impl(DspHle& parent_, Memory::MemorySystem& memory, Core::Timing& timing)
|
||||
: parent(parent_), core_timing(timing) {
|
||||
dsp_memory.raw_memory.fill(0);
|
||||
|
||||
for (auto& source : sources) {
|
||||
@ -152,17 +154,15 @@ DspHle::Impl::Impl(DspHle& parent_, Memory::MemorySystem& memory) : parent(paren
|
||||
decoder = std::make_unique<HLE::NullDecoder>();
|
||||
}
|
||||
|
||||
Core::Timing& timing = Core::System::GetInstance().CoreTiming();
|
||||
tick_event =
|
||||
timing.RegisterEvent("AudioCore::DspHle::tick_event", [this](u64, s64 cycles_late) {
|
||||
core_timing.RegisterEvent("AudioCore::DspHle::tick_event", [this](u64, s64 cycles_late) {
|
||||
this->AudioTickCallback(cycles_late);
|
||||
});
|
||||
timing.ScheduleEvent(audio_frame_ticks, tick_event);
|
||||
core_timing.ScheduleEvent(audio_frame_ticks, tick_event);
|
||||
}
|
||||
|
||||
DspHle::Impl::~Impl() {
|
||||
Core::Timing& timing = Core::System::GetInstance().CoreTiming();
|
||||
timing.UnscheduleEvent(tick_event, 0);
|
||||
core_timing.UnscheduleEvent(tick_event, 0);
|
||||
}
|
||||
|
||||
DspState DspHle::Impl::GetDspState() const {
|
||||
@ -457,11 +457,11 @@ void DspHle::Impl::AudioTickCallback(s64 cycles_late) {
|
||||
}
|
||||
|
||||
// Reschedule recurrent event
|
||||
Core::Timing& timing = Core::System::GetInstance().CoreTiming();
|
||||
timing.ScheduleEvent(audio_frame_ticks - cycles_late, tick_event);
|
||||
core_timing.ScheduleEvent(audio_frame_ticks - cycles_late, tick_event);
|
||||
}
|
||||
|
||||
DspHle::DspHle(Memory::MemorySystem& memory) : impl(std::make_unique<Impl>(*this, memory)) {}
|
||||
DspHle::DspHle(Memory::MemorySystem& memory, Core::Timing& timing)
|
||||
: impl(std::make_unique<Impl>(*this, memory, timing)) {}
|
||||
DspHle::~DspHle() = default;
|
||||
|
||||
u16 DspHle::RecvData(u32 register_number) {
|
||||
|
@ -22,7 +22,7 @@ namespace AudioCore {
|
||||
|
||||
class DspHle final : public DspInterface {
|
||||
public:
|
||||
explicit DspHle(Memory::MemorySystem& memory);
|
||||
explicit DspHle(Memory::MemorySystem& memory, Core::Timing& timing);
|
||||
~DspHle();
|
||||
|
||||
u16 RecvData(u32 register_number) override;
|
||||
|
@ -122,8 +122,8 @@ static u8 PipeIndexToSlotIndex(u8 pipe_index, PipeDirection direction) {
|
||||
}
|
||||
|
||||
struct DspLle::Impl final {
|
||||
Impl(bool multithread) : multithread(multithread) {
|
||||
teakra_slice_event = Core::System::GetInstance().CoreTiming().RegisterEvent(
|
||||
Impl(Core::Timing& timing, bool multithread) : core_timing(timing), multithread(multithread) {
|
||||
teakra_slice_event = core_timing.RegisterEvent(
|
||||
"DSP slice", [this](u64, int late) { TeakraSliceEvent(static_cast<u64>(late)); });
|
||||
}
|
||||
|
||||
@ -137,6 +137,7 @@ struct DspLle::Impl final {
|
||||
bool semaphore_signaled = false;
|
||||
bool data_signaled = false;
|
||||
|
||||
Core::Timing& core_timing;
|
||||
Core::TimingEventType* teakra_slice_event;
|
||||
std::atomic<bool> loaded = false;
|
||||
|
||||
@ -185,7 +186,7 @@ struct DspLle::Impl final {
|
||||
next = 0;
|
||||
else
|
||||
next -= late;
|
||||
Core::System::GetInstance().CoreTiming().ScheduleEvent(next, teakra_slice_event, 0);
|
||||
core_timing.ScheduleEvent(next, teakra_slice_event, 0);
|
||||
}
|
||||
|
||||
u8* GetDspDataPointer(u32 baddr) {
|
||||
@ -326,7 +327,7 @@ struct DspLle::Impl final {
|
||||
|
||||
// TODO: load special segment
|
||||
|
||||
Core::System::GetInstance().CoreTiming().ScheduleEvent(TeakraSlice, teakra_slice_event, 0);
|
||||
core_timing.ScheduleEvent(TeakraSlice, teakra_slice_event, 0);
|
||||
|
||||
if (multithread) {
|
||||
teakra_thread = std::thread(&Impl::TeakraThread, this);
|
||||
@ -371,7 +372,7 @@ struct DspLle::Impl final {
|
||||
|
||||
teakra.RecvData(2); // discard the value
|
||||
|
||||
Core::System::GetInstance().CoreTiming().UnscheduleEvent(teakra_slice_event, 0);
|
||||
core_timing.UnscheduleEvent(teakra_slice_event, 0);
|
||||
StopTeakraThread();
|
||||
}
|
||||
};
|
||||
@ -475,8 +476,8 @@ void DspLle::UnloadComponent() {
|
||||
impl->UnloadComponent();
|
||||
}
|
||||
|
||||
DspLle::DspLle(Memory::MemorySystem& memory, bool multithread)
|
||||
: impl(std::make_unique<Impl>(multithread)) {
|
||||
DspLle::DspLle(Memory::MemorySystem& memory,Core::Timing& timing, bool multithread)
|
||||
: impl(std::make_unique<Impl>(timing, multithread)) {
|
||||
Teakra::AHBMCallback ahbm;
|
||||
ahbm.read8 = [&memory](u32 address) -> u8 {
|
||||
return *memory.GetFCRAMPointer(address - Memory::FCRAM_PADDR);
|
||||
|
@ -6,11 +6,15 @@
|
||||
|
||||
#include "audio_core/dsp_interface.h"
|
||||
|
||||
namespace Core {
|
||||
class Timing;
|
||||
}
|
||||
|
||||
namespace AudioCore {
|
||||
|
||||
class DspLle final : public DspInterface {
|
||||
public:
|
||||
explicit DspLle(Memory::MemorySystem& memory, bool multithread);
|
||||
explicit DspLle(Memory::MemorySystem& memory, Core::Timing& timing, bool multithread);
|
||||
~DspLle() override;
|
||||
|
||||
u16 RecvData(u32 register_number) override;
|
||||
|
@ -400,10 +400,10 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window,
|
||||
|
||||
const auto audio_emulation = Settings::values.audio_emulation.GetValue();
|
||||
if (audio_emulation == Settings::AudioEmulation::HLE) {
|
||||
dsp_core = std::make_unique<AudioCore::DspHle>(*memory);
|
||||
dsp_core = std::make_unique<AudioCore::DspHle>(*memory, *timing);
|
||||
} else {
|
||||
const bool multithread = audio_emulation == Settings::AudioEmulation::LLEMultithreaded;
|
||||
dsp_core = std::make_unique<AudioCore::DspLle>(*memory, multithread);
|
||||
dsp_core = std::make_unique<AudioCore::DspLle>(*memory, *timing, multithread);
|
||||
}
|
||||
|
||||
memory->SetDSP(*dsp_core);
|
||||
|
Loading…
Reference in New Issue
Block a user