2016-02-21 13:13:52 +00:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2017-05-01 04:36:00 +00:00
|
|
|
#include <array>
|
2016-04-27 12:53:23 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
2016-09-21 06:52:38 +00:00
|
|
|
#include "audio_core/audio_core.h"
|
2016-02-21 13:13:52 +00:00
|
|
|
#include "audio_core/hle/dsp.h"
|
2016-04-24 09:21:10 +00:00
|
|
|
#include "audio_core/hle/pipe.h"
|
2016-04-27 12:53:23 +00:00
|
|
|
#include "audio_core/null_sink.h"
|
|
|
|
#include "audio_core/sink.h"
|
|
|
|
#include "audio_core/sink_details.h"
|
2017-05-01 04:36:00 +00:00
|
|
|
#include "common/common_types.h"
|
2016-02-21 13:13:52 +00:00
|
|
|
#include "core/core_timing.h"
|
|
|
|
#include "core/hle/service/dsp_dsp.h"
|
|
|
|
|
|
|
|
namespace AudioCore {
|
|
|
|
|
|
|
|
// Audio Ticks occur about every 5 miliseconds.
|
|
|
|
static int tick_event; ///< CoreTiming event
|
|
|
|
static constexpr u64 audio_frame_ticks = 1310252ull; ///< Units: ARM11 cycles
|
|
|
|
|
|
|
|
static void AudioTickCallback(u64 /*userdata*/, int cycles_late) {
|
|
|
|
if (DSP::HLE::Tick()) {
|
2016-04-24 09:21:10 +00:00
|
|
|
// TODO(merry): Signal all the other interrupts as appropriate.
|
2016-12-10 12:51:50 +00:00
|
|
|
Service::DSP_DSP::SignalPipeInterrupt(DSP::HLE::DspPipe::Audio);
|
2016-04-24 12:36:44 +00:00
|
|
|
// HACK(merry): Added to prevent regressions. Will remove soon.
|
2016-12-10 12:51:50 +00:00
|
|
|
Service::DSP_DSP::SignalPipeInterrupt(DSP::HLE::DspPipe::Binary);
|
2016-02-21 13:13:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reschedule recurrent event
|
|
|
|
CoreTiming::ScheduleEvent(audio_frame_ticks - cycles_late, tick_event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Init() {
|
|
|
|
DSP::HLE::Init();
|
|
|
|
|
|
|
|
tick_event = CoreTiming::RegisterEvent("AudioCore::tick_event", AudioTickCallback);
|
|
|
|
CoreTiming::ScheduleEvent(audio_frame_ticks, tick_event);
|
|
|
|
}
|
|
|
|
|
2017-05-01 04:36:00 +00:00
|
|
|
std::array<u8, Memory::DSP_RAM_SIZE>& GetDspMemory() {
|
|
|
|
return DSP::HLE::g_dsp_memory.raw_memory;
|
2016-02-21 13:13:52 +00:00
|
|
|
}
|
|
|
|
|
2016-04-27 12:53:23 +00:00
|
|
|
void SelectSink(std::string sink_id) {
|
2017-01-26 03:33:26 +00:00
|
|
|
const SinkDetails& sink_details = GetSinkDetails(sink_id);
|
|
|
|
DSP::HLE::SetSink(sink_details.factory());
|
2016-04-27 12:53:23 +00:00
|
|
|
}
|
|
|
|
|
2016-08-31 15:56:30 +00:00
|
|
|
void EnableStretching(bool enable) {
|
|
|
|
DSP::HLE::EnableStretching(enable);
|
|
|
|
}
|
|
|
|
|
2016-02-21 13:13:52 +00:00
|
|
|
void Shutdown() {
|
|
|
|
CoreTiming::UnscheduleEvent(tick_event, 0);
|
|
|
|
DSP::HLE::Shutdown();
|
|
|
|
}
|
|
|
|
|
2016-04-27 12:53:23 +00:00
|
|
|
} // namespace AudioCore
|