diff --git a/rpcs3/Emu/Cell/Modules/cellDmuxPamf.cpp b/rpcs3/Emu/Cell/Modules/cellDmuxPamf.cpp index 7281b0edf9..ba621ac3bd 100644 --- a/rpcs3/Emu/Cell/Modules/cellDmuxPamf.cpp +++ b/rpcs3/Emu/Cell/Modules/cellDmuxPamf.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "Emu/Cell/PPUModule.h" #include "Emu/Cell/lv2/sys_cond.h" +#include "Emu/Cell/lv2/sys_memory.h" #include "Emu/Cell/lv2/sys_mutex.h" #include "Emu/Cell/lv2/sys_ppu_thread.h" #include "Emu/Cell/lv2/sys_sync.h" @@ -1916,8 +1917,8 @@ error_code _CellDmuxCoreOpQueryAttr(vm::cptr pamfSpeci return CELL_OK; } -error_code DmuxPamfContext::open(ppu_thread& ppu, const CellDmuxPamfResource& res, const DmuxCb& notify_dmux_done, const DmuxCb& notify_prog_end_code, - const DmuxCb& notify_fatal_err, vm::bptr& handle) +error_code DmuxPamfContext::open(ppu_thread& ppu, const CellDmuxPamfResource& res, vm::cptr res_spurs, const DmuxCb& notify_dmux_done, + const DmuxCb& notify_prog_end_code, const DmuxCb& notify_fatal_err, vm::bptr& handle) { if (res.ppuThreadPriority >= 0xc00u || res.ppuThreadStackSize < 0x1000u || res.spuThreadPriority >= 0x100u || res.numOfSpus != 1u || !res.memAddr || res.memSize < sizeof(DmuxPamfContext) + 0xe7b) { @@ -1967,6 +1968,13 @@ error_code DmuxPamfContext::open(ppu_thread& ppu, const CellDmuxPamfResource& re ensure(std::snprintf(_this->spurs_taskset_name, sizeof(_this->spurs_taskset_name), "_libdmux_pamf_%08x", _this.addr()) == 22); + _this->use_existing_spurs = !!res_spurs; + + if (!res_spurs && g_fxo->get().take(0x40000) != 0x40000) + { + return CELL_DMUX_PAMF_ERROR_FATAL; + } + _this->cmd_queue.init(_this->cmd_queue_buffer); _this->cmd_result_queue.init(_this->cmd_result_queue_buffer); _this->stream_info_queue.init(_this->stream_info_queue_buffer); @@ -2032,7 +2040,7 @@ error_code _CellDmuxCoreOpOpen(ppu_thread& ppu, vm::cptr::make(g_fxo->get().func_addr(FIND_FUNC(dmuxPamfNotifyProgEndCode))); const auto fatal_err_func = vm::bptr::make(g_fxo->get().func_addr(FIND_FUNC(dmuxPamfNotifyFatalErr))); - const error_code ret = DmuxPamfContext::open(ppu, res, { demux_done_func, _handle }, { prog_end_code_func, _handle }, { fatal_err_func, _handle }, _handle->demuxer); + const error_code ret = DmuxPamfContext::open(ppu, res, demuxerResourceSpurs, { demux_done_func, _handle }, { prog_end_code_func, _handle }, { fatal_err_func, _handle }, _handle->demuxer); *handle = _handle; @@ -2048,6 +2056,11 @@ error_code DmuxPamfContext::close(ppu_thread& ppu) ensure(idm::remove(hle_spu_thread_id)); + if (!use_existing_spurs) + { + g_fxo->get().free(0x40000); + } + if (sys_cond_destroy(ppu, cond) != CELL_OK || sys_mutex_destroy(ppu, mutex) != CELL_OK) { diff --git a/rpcs3/Emu/Cell/Modules/cellDmuxPamf.h b/rpcs3/Emu/Cell/Modules/cellDmuxPamf.h index e04b618785..5b42103ca7 100644 --- a/rpcs3/Emu/Cell/Modules/cellDmuxPamf.h +++ b/rpcs3/Emu/Cell/Modules/cellDmuxPamf.h @@ -961,7 +961,8 @@ public: void exec(ppu_thread& ppu); - static error_code open(ppu_thread& ppu, const CellDmuxPamfResource& res, const DmuxCb& notify_dmux_done, const DmuxCb& notify_prog_end_code, const DmuxCb& notify_fatal_err, vm::bptr& handle); + static error_code open(ppu_thread& ppu, const CellDmuxPamfResource& res, vm::cptr res_spurs, const DmuxCb& notify_dmux_done, + const DmuxCb& notify_prog_end_code, const DmuxCb& notify_fatal_err, vm::bptr& handle); error_code create_thread(ppu_thread& ppu); error_code close(ppu_thread& ppu); error_code reset_stream(ppu_thread& ppu);