MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / _CellAdecCoreOpOpenExt_lpcm

Function _CellAdecCoreOpOpenExt_lpcm

ps3fw/cellAdec.cpp:878–935  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

876}
877
878error_code _CellAdecCoreOpOpenExt_lpcm(ppu_thread& ppu, vm::ptr<LpcmDecContext> handle, vm::ptr<AdecNotifyAuDone> notifyAuDone, vm::ptr<void> notifyAuDoneArg, vm::ptr<AdecNotifyPcmOut> notifyPcmOut, vm::ptr<void> notifyPcmOutArg,
879 vm::ptr<AdecNotifyError> notifyError, vm::ptr<void> notifyErrorArg, vm::ptr<AdecNotifySeqDone> notifySeqDone, vm::ptr<void> notifySeqDoneArg, vm::cptr<CellAdecResource> res, vm::cptr<CellAdecResourceSpurs> spursRes)
880{
881 cellAdec.notice("_CellAdecCoreOpOpenExt_lpcm(handle=*0x%x, notifyAuDone=*0x%x, notifyAuDoneArg=0x%x, notifyPcmOut=*0x%x, notifyPcmOutArg=0x%x, notifyError=*0x%x, notifyErrorArg=0x%x, notifySeqDone=*0x%x, notifySeqDoneArg=0x%x, res=*0x%x, spursRes=*0x%x)",
882 handle, notifyAuDone, notifyAuDoneArg, notifyPcmOut, notifyPcmOutArg, notifyError, notifyErrorArg, notifySeqDone, notifySeqDoneArg, res, spursRes);
883
884 ensure(!!handle && !!res); // Not checked on LLE
885 ensure(handle.aligned(0x80)); // LLE doesn't check the alignment or aligns the address itself
886 ensure(!!notifyAuDone && !!notifyAuDoneArg && !!notifyPcmOut && !!notifyPcmOutArg && !!notifyError && !!notifyErrorArg && !!notifySeqDone && !!notifySeqDoneArg); // These should always be set
887
888 const u32 end_of_context_addr = handle.addr() + rx::alignUp(static_cast<u32>(sizeof(LpcmDecContext)), 0x80);
889
890 handle->cmd_queue.front = 0;
891 handle->cmd_queue.back = 0;
892 handle->cmd_queue.size = 0;
893 handle->run_thread = true;
894 handle->notify_au_done = {notifyAuDone, notifyAuDoneArg};
895 handle->notify_pcm_out = {notifyPcmOut, notifyPcmOutArg};
896 handle->notify_error = {notifyError, notifyErrorArg};
897 handle->notify_seq_done = {notifySeqDone, notifySeqDoneArg};
898 handle->output = vm::bptr<f32>::make(end_of_context_addr + 0x180);
899 handle->lpcm_param.set(end_of_context_addr);
900 handle->error_occurred = false;
901
902 const vm::var<sys_mutex_attribute_t> mutex_attr{{SYS_SYNC_PRIORITY, SYS_SYNC_NOT_RECURSIVE, SYS_SYNC_NOT_PROCESS_SHARED, SYS_SYNC_NOT_ADAPTIVE, 0, 0, 0, {"_adem04"_u64}}};
903 const vm::var<sys_mutex_attribute_t> output_mutex_attr{{SYS_SYNC_PRIORITY, SYS_SYNC_NOT_RECURSIVE, SYS_SYNC_NOT_PROCESS_SHARED, SYS_SYNC_NOT_ADAPTIVE, 0, 0, 0, {"_adem05"_u64}}};
904 const vm::var<sys_mutex_attribute_t> queue_mutex_attr{{SYS_SYNC_PRIORITY, SYS_SYNC_NOT_RECURSIVE, SYS_SYNC_NOT_PROCESS_SHARED, SYS_SYNC_NOT_ADAPTIVE, 0, 0, 0, {"_adem06"_u64}}};
905 const vm::var<sys_cond_attribute_t> cond_attr{{SYS_SYNC_NOT_PROCESS_SHARED, 0, 0, {"_adec03"_u64}}};
906
907 error_code ret = sys_mutex_create(ppu, handle.ptr(&LpcmDecContext::queue_size_mutex), mutex_attr);
908 ret = ret ? ret : sys_cond_create(ppu, handle.ptr(&LpcmDecContext::queue_size_cond), handle->queue_size_mutex, cond_attr);
909 ret = ret ? ret : sys_mutex_create(ppu, handle.ptr(&LpcmDecContext::unk_mutex), mutex_attr);
910 ret = ret ? ret : sys_cond_create(ppu, handle.ptr(&LpcmDecContext::unk_cond), handle->unk_mutex, cond_attr);
911 ret = ret ? ret : sys_mutex_create(ppu, handle.ptr(&LpcmDecContext::output_mutex), output_mutex_attr);
912 ret = ret ? ret : sys_cond_create(ppu, handle.ptr(&LpcmDecContext::output_consumed), handle->output_mutex, cond_attr);
913 ret = ret ? ret : sys_mutex_create(ppu, handle.ptr(&LpcmDecContext::queue_mutex), queue_mutex_attr);
914 ret = ret ? ret : handle->release_output(ppu);
915 ret = ret ? ret : handle->cmd_available.init(ppu, handle.ptr(&LpcmDecContext::cmd_available), 0);
916 ret = ret ? ret : handle->reserved2.init(ppu, handle.ptr(&LpcmDecContext::reserved2), 0);
917
918 if (ret != CELL_OK)
919 {
920 return ret;
921 }
922
923 // HLE exclusive
924 handle->savestate = lpcm_dec_state::waiting_for_cmd_mutex_lock;
925 handle->cmd_counter = 0;
926
927 const vm::var<char[]> _name = vm::make_str("HLE LPCM decoder");
928 const auto entry = g_fxo->get<ppu_function_manager>().func_addr(FIND_FUNC(lpcmDecEntry));
929
930 ret = ppu_execute<&sys_ppu_thread_create>(ppu, handle.ptr(&LpcmDecContext::thread_id), entry, handle.addr(), +res->ppuThreadPriority, +res->ppuThreadStackSize, SYS_PPU_THREAD_CREATE_JOINABLE, +_name);
931 ret = ret ? ret : sys_mutex_create(ppu, handle.ptr(&LpcmDecContext::spurs_queue_pop_mutex), mutex_attr);
932 ret = ret ? ret : sys_mutex_create(ppu, handle.ptr(&LpcmDecContext::spurs_queue_push_mutex), mutex_attr);
933
934 return ret;
935}

Callers 1

_CellAdecCoreOpOpen_lpcmFunction · 0.85

Calls 12

alignUpFunction · 0.85
sys_mutex_createFunction · 0.85
sys_cond_createFunction · 0.85
make_strFunction · 0.85
alignedMethod · 0.80
release_outputMethod · 0.80
func_addrMethod · 0.80
ensureFunction · 0.50
addrMethod · 0.45
setMethod · 0.45
ptrMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected