diff --git a/rpcs3/Emu/Cell/lv2/sys_rsxaudio.cpp b/rpcs3/Emu/Cell/lv2/sys_rsxaudio.cpp index 6b846fcbcb..2116da6c88 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rsxaudio.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_rsxaudio.cpp @@ -103,6 +103,38 @@ namespace rsxaudio_ringbuf_reader } } +lv2_rsxaudio::lv2_rsxaudio(utils::serial& ar) noexcept + : lv2_obj{1} + , init(ar) +{ + if (init) + { + ar(shmem); + + for (const auto& port : event_queue) + { + lv2_event_queue::save_ptr(ar, port.get()); + } + } +} + +void lv2_rsxaudio::save(utils::serial& ar) +{ + USING_SERIALIZATION_VERSION(LLE); + + ar(init); + + if (init) + { + ar(shmem); + + for (auto& port : event_queue) + { + port = lv2_event_queue::load_ptr(ar, port); + } + } +} + error_code sys_rsxaudio_initialize(vm::ptr handle) { sys_rsxaudio.trace("sys_rsxaudio_initialize(handle=*0x%x)", handle); @@ -414,7 +446,7 @@ error_code sys_rsxaudio_start_process(u32 handle) for (u32 q_idx = 0; q_idx < SYS_RSXAUDIO_PORT_CNT; q_idx++) { - if (auto queue = rsxaudio_obj->event_queue[q_idx].lock(); queue && sh_page->ctrl.ringbuf[q_idx].active) + if (const auto& queue = rsxaudio_obj->event_queue[q_idx]; queue && sh_page->ctrl.ringbuf[q_idx].active) { queue->send(rsxaudio_obj->event_port_name[q_idx], q_idx, 0, 0); } @@ -823,7 +855,7 @@ void rsxaudio_data_thread::extract_audio_data() // Too late to recover reset_periods = true; - if (auto queue = rsxaudio_obj->event_queue[dst_raw].lock()) + if (const auto& queue = rsxaudio_obj->event_queue[dst_raw]) { queue->send(rsxaudio_obj->event_port_name[dst_raw], dst_raw, blk_idx, timestamp); } diff --git a/rpcs3/Emu/Cell/lv2/sys_rsxaudio.h b/rpcs3/Emu/Cell/lv2/sys_rsxaudio.h index 5a625728ac..c223793cd6 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rsxaudio.h +++ b/rpcs3/Emu/Cell/lv2/sys_rsxaudio.h @@ -161,14 +161,13 @@ struct lv2_rsxaudio final : lv2_obj vm::addr_t shmem{}; - std::array, SYS_RSXAUDIO_PORT_CNT> event_queue{}; + std::array, SYS_RSXAUDIO_PORT_CNT> event_queue{}; // lv2 uses port memory addresses for their names static constexpr std::array event_port_name{ 0x8000000000400100, 0x8000000000400200, 0x8000000000400300 }; - lv2_rsxaudio() - { - } + lv2_rsxaudio() noexcept = default; + lv2_rsxaudio(utils::serial& ar) noexcept; void save(utils::serial& ar); void page_lock() { diff --git a/rpcs3/rpcs3qt/kernel_explorer.cpp b/rpcs3/rpcs3qt/kernel_explorer.cpp index 727b39e2cc..d0ad360f36 100644 --- a/rpcs3/rpcs3qt/kernel_explorer.cpp +++ b/rpcs3/rpcs3qt/kernel_explorer.cpp @@ -586,11 +586,12 @@ void kernel_explorer::update() QTreeWidgetItem* rao_obj = add_solid_node(node, qstr(fmt::format(u8"RSXAudio 0x%08x: Shmem: 0x%08x", id, u32{rao.shmem}))); for (u64 q_idx = 0; q_idx < rao.event_queue.size(); q_idx++) { - if (const auto eq = rao.event_queue[q_idx].lock()) + if (const auto& eq = rao.event_queue[q_idx]) { add_leaf(rao_obj, qstr(fmt::format(u8"Event Queue %u: ID: 0x%08x", q_idx, eq->id))); } } + break; } default: