Minor cleanup

This commit is contained in:
Hamish Milne 2020-03-28 09:59:45 +00:00
parent 3d1180ee21
commit 232b52a27d
4 changed files with 28 additions and 33 deletions

View file

@ -1,4 +1,3 @@
#pragma optimize("", off)
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -15,11 +14,7 @@
namespace AudioCore {
DspInterface::DspInterface() = default;
DspInterface::~DspInterface() {
LOG_WARNING(Audio_DSP, "c1");
sink.reset();
LOG_WARNING(Audio_DSP, "c2");
}
DspInterface::~DspInterface() = default;
void DspInterface::SetSink(const std::string& sink_id, const std::string& audio_device) {
sink = CreateSinkFromID(Settings::values.sink_id, Settings::values.audio_device_id);

View file

@ -1,4 +1,3 @@
#pragma optimize("", off)
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -149,11 +148,8 @@ DspHle::Impl::Impl(DspHle& parent_, Memory::MemorySystem& memory) : parent(paren
}
DspHle::Impl::~Impl() {
LOG_WARNING(Audio_DSP, "b1");
Core::Timing& timing = Core::System::GetInstance().CoreTiming();
LOG_WARNING(Audio_DSP, "b2");
timing.UnscheduleEvent(tick_event, 0);
LOG_WARNING(Audio_DSP, "b3");
}
DspState DspHle::Impl::GetDspState() const {
@ -452,12 +448,7 @@ void DspHle::Impl::AudioTickCallback(s64 cycles_late) {
}
DspHle::DspHle(Memory::MemorySystem& memory) : impl(std::make_unique<Impl>(*this, memory)) {}
DspHle::~DspHle() {
LOG_WARNING(Audio_DSP, "a1");
impl.reset();
LOG_WARNING(Audio_DSP, "a2");
}
DspHle::~DspHle() = default;
u16 DspHle::RecvData(u32 register_number) {
return impl->RecvData(register_number);

View file

@ -1,4 +1,3 @@
#pragma optimize("", off)
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -313,7 +312,7 @@ void System::Reschedule() {
System::ResultStatus System::Init(Frontend::EmuWindow& emu_window, u32 system_mode, u8 n3ds_mode) {
LOG_DEBUG(HW_Memory, "initialized OK");
std::size_t num_cores = 2;
u32 num_cores = 2;
if (Settings::values.is_new_3ds) {
num_cores = 4;
}
@ -327,19 +326,19 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window, u32 system_mo
if (Settings::values.use_cpu_jit) {
#ifdef ARCHITECTURE_x86_64
for (std::size_t i = 0; i < num_cores; ++i) {
for (u32 i = 0; i < num_cores; ++i) {
cpu_cores.push_back(
std::make_shared<ARM_Dynarmic>(this, *memory, USER32MODE, i, timing->GetTimer(i)));
}
#else
for (std::size_t i = 0; i < num_cores; ++i) {
for (u32 i = 0; i < num_cores; ++i) {
cpu_cores.push_back(
std::make_shared<ARM_DynCom>(this, *memory, USER32MODE, i, timing->GetTimer(i)));
}
LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available");
#endif
} else {
for (std::size_t i = 0; i < num_cores; ++i) {
for (u32 i = 0; i < num_cores; ++i) {
cpu_cores.push_back(
std::make_shared<ARM_DynCom>(this, *memory, USER32MODE, i, timing->GetTimer(i)));
}
@ -541,26 +540,36 @@ void System::serialize(Archive& ar, const unsigned int file_version) {
bool should_flush = !Archive::is_loading::value;
Memory::RasterizerClearAll(should_flush);
ar&* timing.get();
for (int i = 0; i < num_cores; i++) {
for (u32 i = 0; i < num_cores; i++) {
ar&* cpu_cores[i].get();
}
ar&* service_manager.get();
ar& GPU::g_regs;
ar& LCD::g_regs;
if (!dynamic_cast<AudioCore::DspHle*>(dsp_core.get())) {
throw std::runtime_error("Only HLE audio supported");
// NOTE: DSP doesn't like being destroyed and recreated. So instead we do an inline
// serialization; this means that the DSP Settings need to match for loading to work.
bool dsp_type = Settings::values.enable_dsp_lle;
ar& dsp_type;
if (dsp_type != Settings::values.enable_dsp_lle) {
throw std::runtime_error(
"Incorrect DSP type - please change this in Settings before loading");
}
ar&* dynamic_cast<AudioCore::DspHle*>(dsp_core.get());
auto dsp_hle = dynamic_cast<AudioCore::DspHle*>(dsp_core.get());
if (dsp_hle) {
ar&* dsp_hle;
}
auto dsp_lle = dynamic_cast<AudioCore::DspLle*>(dsp_core.get());
if (dsp_lle) {
ar&* dsp_lle;
}
ar&* memory.get();
ar&* kernel.get();
// This needs to be set from somewhere - might as well be here!
if (Archive::is_loading::value) {
Service::GSP::SetGlobalModule(*this);
memory->SetDSP(*dsp_core);
// dsp_core->SetSink(Settings::values.sink_id, Settings::values.audio_device_id);
dsp_core->EnableStretching(Settings::values.enable_audio_stretching);
}
}

View file

@ -281,7 +281,7 @@ std::size_t GetNameSize(const std::string& name) {
}
void LayeredFS::PrepareBuildDirectory(Directory& current) {
directory_metadata_offset_map.emplace(&current, current_directory_offset);
directory_metadata_offset_map.emplace(&current, static_cast<u32>(current_directory_offset));
directory_list.emplace_back(&current);
current_directory_offset += sizeof(DirectoryMetadata) + GetNameSize(current.name);
}
@ -290,7 +290,7 @@ void LayeredFS::PrepareBuildFile(File& current) {
if (current.relocation.type == 3) { // Deleted files are not counted
return;
}
file_metadata_offset_map.emplace(&current, current_file_offset);
file_metadata_offset_map.emplace(&current, static_cast<u32>(current_file_offset));
file_list.emplace_back(&current);
current_file_offset += sizeof(FileMetadata) + GetNameSize(current.name);
}
@ -369,7 +369,7 @@ void LayeredFS::BuildDirectories() {
// Write metadata and name
std::u16string u16name = Common::UTF8ToUTF16(directory->name);
metadata.name_length = u16name.size() * 2;
metadata.name_length = static_cast<u32_le>(u16name.size() * 2);
std::memcpy(directory_metadata_table.data() + written, &metadata, sizeof(metadata));
written += sizeof(metadata);
@ -418,7 +418,7 @@ void LayeredFS::BuildFiles() {
// Write metadata and name
std::u16string u16name = Common::UTF8ToUTF16(file->name);
metadata.name_length = u16name.size() * 2;
metadata.name_length = static_cast<u32_le>(u16name.size() * 2);
std::memcpy(file_metadata_table.data() + written, &metadata, sizeof(metadata));
written += sizeof(metadata);