diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp index 7c3b60c706..017dd66c4b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp @@ -509,11 +509,14 @@ bool adecCheckType(AudioCodecType type) return true; } -int cellAdecQueryAttr(vm::ptr type, vm::ptr attr) +s32 cellAdecQueryAttr(vm::ptr type, vm::ptr attr) { - cellAdec.Warning("cellAdecQueryAttr(type_addr=0x%x, attr_addr=0x%x)", type.addr(), attr.addr()); + cellAdec.Warning("cellAdecQueryAttr(type=*0x%x, attr=*0x%x)", type, attr); - if (!adecCheckType(type->audioCodecType)) return CELL_ADEC_ERROR_ARG; + if (!adecCheckType(type->audioCodecType)) + { + return CELL_ADEC_ERROR_ARG; + } // TODO: check values attr->adecVerLower = 0x280000; // from dmux @@ -523,36 +526,41 @@ int cellAdecQueryAttr(vm::ptr type, vm::ptr attr) return CELL_OK; } -int cellAdecOpen(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) +s32 cellAdecOpen(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) { - cellAdec.Warning("cellAdecOpen(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)", - type.addr(), res.addr(), cb.addr(), handle.addr()); + cellAdec.Warning("cellAdecOpen(type=*0x%x, res=*0x%x, cb=*0x%x, handle=*0x%x)", type, res, cb, handle); - if (!adecCheckType(type->audioCodecType)) return CELL_ADEC_ERROR_ARG; + if (!adecCheckType(type->audioCodecType)) + { + return CELL_ADEC_ERROR_ARG; + } *handle = adecOpen(new AudioDecoder(type->audioCodecType, res->startAddr, res->totalMemSize, cb->cbFunc, cb->cbArg)); return CELL_OK; } -int cellAdecOpenEx(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) +s32 cellAdecOpenEx(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) { - cellAdec.Warning("cellAdecOpenEx(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)", - type.addr(), res.addr(), cb.addr(), handle.addr()); + cellAdec.Warning("cellAdecOpenEx(type=*0x%x, res=*0x%x, cb=*0x%x, handle=*0x%x)", type, res, cb, handle); - if (!adecCheckType(type->audioCodecType)) return CELL_ADEC_ERROR_ARG; + if (!adecCheckType(type->audioCodecType)) + { + return CELL_ADEC_ERROR_ARG; + } *handle = adecOpen(new AudioDecoder(type->audioCodecType, res->startAddr, res->totalMemSize, cb->cbFunc, cb->cbArg)); return CELL_OK; } -int cellAdecClose(u32 handle) +s32 cellAdecClose(u32 handle) { cellAdec.Warning("cellAdecClose(handle=%d)", handle); - std::shared_ptr adec; - if (!Emu.GetIdManager().GetIDData(handle, adec)) + const auto adec = Emu.GetIdManager().GetIDData(handle); + + if (!adec) { return CELL_ADEC_ERROR_ARG; } @@ -575,12 +583,13 @@ int cellAdecClose(u32 handle) return CELL_OK; } -int cellAdecStartSeq(u32 handle, u32 param_addr) +s32 cellAdecStartSeq(u32 handle, u32 param) { - cellAdec.Warning("cellAdecStartSeq(handle=%d, param_addr=0x%x)", handle, param_addr); + cellAdec.Warning("cellAdecStartSeq(handle=%d, param=*0x%x)", handle, param); - std::shared_ptr adec; - if (!Emu.GetIdManager().GetIDData(handle, adec)) + const auto adec = Emu.GetIdManager().GetIDData(handle); + + if (!adec) { return CELL_ADEC_ERROR_ARG; } @@ -594,25 +603,25 @@ int cellAdecStartSeq(u32 handle, u32 param_addr) case CELL_ADEC_TYPE_ATRACX_6CH: case CELL_ADEC_TYPE_ATRACX_8CH: { - auto param = vm::ptr::make(param_addr); + const auto atx = vm::ptr::make(param); - task.at3p.sample_rate = param->sampling_freq; - task.at3p.channel_config = param->ch_config_idx; - task.at3p.channels = param->nch_out; - task.at3p.frame_size = param->nbytes; - task.at3p.extra_config = param->extra_config_data; - task.at3p.output = param->bw_pcm; - task.at3p.downmix = param->downmix_flag; - task.at3p.ats_header = param->au_includes_ats_hdr_flg; + task.at3p.sample_rate = atx->sampling_freq; + task.at3p.channel_config = atx->ch_config_idx; + task.at3p.channels = atx->nch_out; + task.at3p.frame_size = atx->nbytes; + task.at3p.extra_config = atx->extra_config_data; + task.at3p.output = atx->bw_pcm; + task.at3p.downmix = atx->downmix_flag; + task.at3p.ats_header = atx->au_includes_ats_hdr_flg; cellAdec.Todo("*** CellAdecParamAtracX: sr=%d, ch_cfg=%d(%d), frame_size=0x%x, extra=0x%x, output=%d, downmix=%d, ats_header=%d", task.at3p.sample_rate, task.at3p.channel_config, task.at3p.channels, task.at3p.frame_size, (u32&)task.at3p.extra_config, task.at3p.output, task.at3p.downmix, task.at3p.ats_header); break; } case CELL_ADEC_TYPE_MP3: { - auto param = vm::ptr::make(param_addr); + const auto mp3 = vm::ptr::make(param); - cellAdec.Todo("*** CellAdecParamMP3: bw_pcm=%d", param->bw_pcm); + cellAdec.Todo("*** CellAdecParamMP3: bw_pcm=%d", mp3->bw_pcm); break; } default: @@ -627,12 +636,13 @@ int cellAdecStartSeq(u32 handle, u32 param_addr) return CELL_OK; } -int cellAdecEndSeq(u32 handle) +s32 cellAdecEndSeq(u32 handle) { cellAdec.Warning("cellAdecEndSeq(handle=%d)", handle); - std::shared_ptr adec; - if (!Emu.GetIdManager().GetIDData(handle, adec)) + const auto adec = Emu.GetIdManager().GetIDData(handle); + + if (!adec) { return CELL_ADEC_ERROR_ARG; } @@ -641,12 +651,13 @@ int cellAdecEndSeq(u32 handle) return CELL_OK; } -int cellAdecDecodeAu(u32 handle, vm::ptr auInfo) +s32 cellAdecDecodeAu(u32 handle, vm::ptr auInfo) { - cellAdec.Log("cellAdecDecodeAu(handle=%d, auInfo_addr=0x%x)", handle, auInfo.addr()); + cellAdec.Log("cellAdecDecodeAu(handle=%d, auInfo=*0x%x)", handle, auInfo); - std::shared_ptr adec; - if (!Emu.GetIdManager().GetIDData(handle, adec)) + const auto adec = Emu.GetIdManager().GetIDData(handle); + + if (!adec) { return CELL_ADEC_ERROR_ARG; } @@ -663,12 +674,13 @@ int cellAdecDecodeAu(u32 handle, vm::ptr auInfo) return CELL_OK; } -int cellAdecGetPcm(u32 handle, vm::ptr outBuffer) +s32 cellAdecGetPcm(u32 handle, vm::ptr outBuffer) { - cellAdec.Log("cellAdecGetPcm(handle=%d, outBuffer_addr=0x%x)", handle, outBuffer.addr()); + cellAdec.Log("cellAdecGetPcm(handle=%d, outBuffer=*0x%x)", handle, outBuffer); - std::shared_ptr adec; - if (!Emu.GetIdManager().GetIDData(handle, adec)) + const auto adec = Emu.GetIdManager().GetIDData(handle); + + if (!adec) { return CELL_ADEC_ERROR_ARG; } @@ -778,12 +790,13 @@ int cellAdecGetPcm(u32 handle, vm::ptr outBuffer) return CELL_OK; } -int cellAdecGetPcmItem(u32 handle, vm::ptr pcmItem_ptr) +s32 cellAdecGetPcmItem(u32 handle, vm::ptr> pcmItem) { - cellAdec.Log("cellAdecGetPcmItem(handle=%d, pcmItem_ptr_addr=0x%x)", handle, pcmItem_ptr.addr()); + cellAdec.Log("cellAdecGetPcmItem(handle=%d, pcmItem=**0x%x)", handle, pcmItem); - std::shared_ptr adec; - if (!Emu.GetIdManager().GetIDData(handle, adec)) + const auto adec = Emu.GetIdManager().GetIDData(handle); + + if (!adec) { return CELL_ADEC_ERROR_ARG; } @@ -797,7 +810,7 @@ int cellAdecGetPcmItem(u32 handle, vm::ptr pcmItem_ptr) AVFrame* frame = af.data; - auto pcm = vm::ptr::make(adec->memAddr + adec->memBias); + const auto pcm = vm::ptr::make(adec->memAddr + adec->memBias); adec->memBias += 512; if (adec->memBias + 512 > adec->memSize) @@ -852,7 +865,7 @@ int cellAdecGetPcmItem(u32 handle, vm::ptr pcmItem_ptr) memset(mp3.get_ptr(), 0, sizeof(CellAdecMP3Info)); } - *pcmItem_ptr = pcm.addr(); + *pcmItem = pcm; return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp index 47e7e9543c..4ca9b72cb0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp @@ -389,7 +389,7 @@ s32 cellAudioInit() for (auto key : g_audio.keys) { - if (std::shared_ptr queue = Emu.GetEventManager().GetEventQueue(key)) + if (const auto queue = Emu.GetEventManager().GetEventQueue(key)) { queue->push(0, 0, 0, 0); // TODO: check arguments } diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp index b949c5534e..528a3d6384 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp @@ -285,16 +285,18 @@ void dmuxQueryAttr(u32 info_addr /* may be 0 */, vm::ptr attr) attr->memSize = 0x10000; // 0x3e8e6 from ps3 } -void dmuxQueryEsAttr(u32 info_addr /* may be 0 */, vm::ptr esFilterId, - const u32 esSpecificInfo_addr, vm::ptr attr) +void dmuxQueryEsAttr(u32 info /* may be 0 */, vm::ptr esFilterId, u32 esSpecificInfo, vm::ptr attr) { if (esFilterId->filterIdMajor >= 0xe0) + { attr->memSize = 0x500000; // 0x45fa49 from ps3 + } else + { attr->memSize = 0x7000; // 0x73d9 from ps3 + } - cellDmux.Warning("*** filter(0x%x, 0x%x, 0x%x, 0x%x)", (u32)esFilterId->filterIdMajor, (u32)esFilterId->filterIdMinor, - (u32)esFilterId->supplementalInfo1, (u32)esFilterId->supplementalInfo2); + cellDmux.Warning("*** filter(0x%x, 0x%x, 0x%x, 0x%x)", esFilterId->filterIdMajor, esFilterId->filterIdMinor, esFilterId->supplementalInfo1, esFilterId->supplementalInfo2); } u32 dmuxOpen(Demuxer* dmux_ptr) @@ -775,92 +777,87 @@ u32 dmuxOpen(Demuxer* dmux_ptr) return dmux_id; } -int cellDmuxQueryAttr(vm::ptr demuxerType, vm::ptr demuxerAttr) +s32 cellDmuxQueryAttr(vm::ptr type, vm::ptr attr) { - cellDmux.Warning("cellDmuxQueryAttr(demuxerType_addr=0x%x, demuxerAttr_addr=0x%x)", demuxerType.addr(), demuxerAttr.addr()); + cellDmux.Warning("cellDmuxQueryAttr(type=*0x%x, attr=*0x%x)", type, attr); - if (demuxerType->streamType != CELL_DMUX_STREAM_TYPE_PAMF) + if (type->streamType != CELL_DMUX_STREAM_TYPE_PAMF) { return CELL_DMUX_ERROR_ARG; } - dmuxQueryAttr(0, demuxerAttr); + dmuxQueryAttr(0, attr); return CELL_OK; } -int cellDmuxQueryAttr2(vm::ptr demuxerType2, vm::ptr demuxerAttr) +s32 cellDmuxQueryAttr2(vm::ptr type2, vm::ptr attr) { - cellDmux.Warning("cellDmuxQueryAttr2(demuxerType2_addr=0x%x, demuxerAttr_addr=0x%x)", demuxerType2.addr(), demuxerAttr.addr()); + cellDmux.Warning("cellDmuxQueryAttr2(demuxerType2=*0x%x, demuxerAttr=*0x%x)", type2, attr); - if (demuxerType2->streamType != CELL_DMUX_STREAM_TYPE_PAMF) + if (type2->streamType != CELL_DMUX_STREAM_TYPE_PAMF) { return CELL_DMUX_ERROR_ARG; } - dmuxQueryAttr(demuxerType2->streamSpecificInfo_addr, demuxerAttr); + dmuxQueryAttr(type2->streamSpecificInfo, attr); return CELL_OK; } -int cellDmuxOpen(vm::ptr demuxerType, vm::ptr demuxerResource, - vm::ptr demuxerCb, vm::ptr demuxerHandle) +s32 cellDmuxOpen(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) { - cellDmux.Warning("cellDmuxOpen(demuxerType_addr=0x%x, demuxerResource_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)", - demuxerType.addr(), demuxerResource.addr(), demuxerCb.addr(), demuxerHandle.addr()); + cellDmux.Warning("cellDmuxOpen(type=*0x%x, res=*0x%x, cb=*0x%x, handle=*0x%x)", type, res, cb, handle); - if (demuxerType->streamType != CELL_DMUX_STREAM_TYPE_PAMF) + if (type->streamType != CELL_DMUX_STREAM_TYPE_PAMF) { return CELL_DMUX_ERROR_ARG; } // TODO: check demuxerResource and demuxerCb arguments - *demuxerHandle = dmuxOpen(new Demuxer(demuxerResource->memAddr, demuxerResource->memSize, demuxerCb->cbMsgFunc, demuxerCb->cbArg)); + *handle = dmuxOpen(new Demuxer(res->memAddr, res->memSize, cb->cbMsgFunc, cb->cbArg)); return CELL_OK; } -int cellDmuxOpenEx(vm::ptr demuxerType, vm::ptr demuxerResourceEx, - vm::ptr demuxerCb, vm::ptr demuxerHandle) +s32 cellDmuxOpenEx(vm::ptr type, vm::ptr resEx, vm::ptr cb, vm::ptr handle) { - cellDmux.Warning("cellDmuxOpenEx(demuxerType_addr=0x%x, demuxerResourceEx_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)", - demuxerType.addr(), demuxerResourceEx.addr(), demuxerCb.addr(), demuxerHandle.addr()); + cellDmux.Warning("cellDmuxOpenEx(type=*0x%x, resEx=*0x%x, cb=*0x%x, handle=*0x%x)", type, resEx, cb, handle); - if (demuxerType->streamType != CELL_DMUX_STREAM_TYPE_PAMF) + if (type->streamType != CELL_DMUX_STREAM_TYPE_PAMF) { return CELL_DMUX_ERROR_ARG; } // TODO: check demuxerResourceEx and demuxerCb arguments - *demuxerHandle = dmuxOpen(new Demuxer(demuxerResourceEx->memAddr, demuxerResourceEx->memSize, demuxerCb->cbMsgFunc, demuxerCb->cbArg)); + *handle = dmuxOpen(new Demuxer(resEx->memAddr, resEx->memSize, cb->cbMsgFunc, cb->cbArg)); return CELL_OK; } -int cellDmuxOpen2(vm::ptr demuxerType2, vm::ptr demuxerResource2, - vm::ptr demuxerCb, vm::ptr demuxerHandle) +s32 cellDmuxOpen2(vm::ptr type2, vm::ptr res2, vm::ptr cb, vm::ptr handle) { - cellDmux.Warning("cellDmuxOpen2(demuxerType2_addr=0x%x, demuxerResource2_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)", - demuxerType2.addr(), demuxerResource2.addr(), demuxerCb.addr(), demuxerHandle.addr()); + cellDmux.Warning("cellDmuxOpen2(type2=*0x%x, res2=*0x%x, cb=*0x%x, handle=*0x%x)", type2, res2, cb, handle); - if (demuxerType2->streamType != CELL_DMUX_STREAM_TYPE_PAMF) + if (type2->streamType != CELL_DMUX_STREAM_TYPE_PAMF) { return CELL_DMUX_ERROR_ARG; } // TODO: check demuxerType2, demuxerResource2 and demuxerCb arguments - *demuxerHandle = dmuxOpen(new Demuxer(demuxerResource2->memAddr, demuxerResource2->memSize, demuxerCb->cbMsgFunc, demuxerCb->cbArg)); + *handle = dmuxOpen(new Demuxer(res2->memAddr, res2->memSize, cb->cbMsgFunc, cb->cbArg)); return CELL_OK; } -int cellDmuxClose(u32 demuxerHandle) +s32 cellDmuxClose(u32 handle) { - cellDmux.Warning("cellDmuxClose(demuxerHandle=%d)", demuxerHandle); + cellDmux.Warning("cellDmuxClose(handle=%d)", handle); - std::shared_ptr dmux; - if (!Emu.GetIdManager().GetIDData(demuxerHandle, dmux)) + const auto dmux = Emu.GetIdManager().GetIDData(handle); + + if (!dmux) { return CELL_DMUX_ERROR_ARG; } @@ -872,7 +869,7 @@ int cellDmuxClose(u32 demuxerHandle) { if (Emu.IsStopped()) { - cellDmux.Warning("cellDmuxClose(%d) aborted", demuxerHandle); + cellDmux.Warning("cellDmuxClose(%d) aborted", handle); return CELL_OK; } @@ -880,17 +877,17 @@ int cellDmuxClose(u32 demuxerHandle) } if (dmux->dmuxCb) Emu.GetCPU().RemoveThread(dmux->dmuxCb->GetId()); - Emu.GetIdManager().RemoveID(demuxerHandle); + Emu.GetIdManager().RemoveID(handle); return CELL_OK; } -int cellDmuxSetStream(u32 demuxerHandle, const u32 streamAddress, u32 streamSize, bool discontinuity, u64 userData) +s32 cellDmuxSetStream(u32 handle, u32 streamAddress, u32 streamSize, bool discontinuity, u64 userData) { - cellDmux.Log("cellDmuxSetStream(demuxerHandle=%d, streamAddress=0x%x, streamSize=%d, discontinuity=%d, userData=0x%llx", - demuxerHandle, streamAddress, streamSize, discontinuity, userData); + cellDmux.Log("cellDmuxSetStream(handle=%d, streamAddress=0x%x, streamSize=%d, discontinuity=%d, userData=0x%llx)", handle, streamAddress, streamSize, discontinuity, userData); - std::shared_ptr dmux; - if (!Emu.GetIdManager().GetIDData(demuxerHandle, dmux)) + const auto dmux = Emu.GetIdManager().GetIDData(handle); + + if (!dmux) { return CELL_DMUX_ERROR_ARG; } @@ -912,12 +909,13 @@ int cellDmuxSetStream(u32 demuxerHandle, const u32 streamAddress, u32 streamSize return CELL_OK; } -int cellDmuxResetStream(u32 demuxerHandle) +s32 cellDmuxResetStream(u32 handle) { - cellDmux.Warning("cellDmuxResetStream(demuxerHandle=%d)", demuxerHandle); + cellDmux.Warning("cellDmuxResetStream(handle=%d)", handle); - std::shared_ptr dmux; - if (!Emu.GetIdManager().GetIDData(demuxerHandle, dmux)) + const auto dmux = Emu.GetIdManager().GetIDData(handle); + + if (!dmux) { return CELL_DMUX_ERROR_ARG; } @@ -926,12 +924,13 @@ int cellDmuxResetStream(u32 demuxerHandle) return CELL_OK; } -int cellDmuxResetStreamAndWaitDone(u32 demuxerHandle) +s32 cellDmuxResetStreamAndWaitDone(u32 handle) { - cellDmux.Warning("cellDmuxResetStreamAndWaitDone(demuxerHandle=%d)", demuxerHandle); + cellDmux.Warning("cellDmuxResetStreamAndWaitDone(handle=%d)", handle); - std::shared_ptr dmux; - if (!Emu.GetIdManager().GetIDData(demuxerHandle, dmux)) + const auto dmux = Emu.GetIdManager().GetIDData(handle); + + if (!dmux) { return CELL_DMUX_ERROR_ARG; } @@ -949,7 +948,7 @@ int cellDmuxResetStreamAndWaitDone(u32 demuxerHandle) { if (Emu.IsStopped()) { - cellDmux.Warning("cellDmuxResetStreamAndWaitDone(%d) aborted", demuxerHandle); + cellDmux.Warning("cellDmuxResetStreamAndWaitDone(%d) aborted", handle); return CELL_OK; } std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack @@ -958,48 +957,41 @@ int cellDmuxResetStreamAndWaitDone(u32 demuxerHandle) return CELL_OK; } -int cellDmuxQueryEsAttr(vm::ptr demuxerType, vm::ptr esFilterId, - const u32 esSpecificInfo_addr, vm::ptr esAttr) +s32 cellDmuxQueryEsAttr(vm::ptr type, vm::ptr esFilterId, u32 esSpecificInfo, vm::ptr esAttr) { - cellDmux.Warning("cellDmuxQueryEsAttr(demuxerType_addr=0x%x, esFilterId_addr=0x%x, esSpecificInfo_addr=0x%x, esAttr_addr=0x%x)", - demuxerType.addr(), esFilterId.addr(), esSpecificInfo_addr, esAttr.addr()); + cellDmux.Warning("cellDmuxQueryEsAttr(demuxerType=*0x%x, esFilterId=*0x%x, esSpecificInfo=*0x%x, esAttr=*0x%x)", type, esFilterId, esSpecificInfo, esAttr); - if (demuxerType->streamType != CELL_DMUX_STREAM_TYPE_PAMF) + if (type->streamType != CELL_DMUX_STREAM_TYPE_PAMF) { return CELL_DMUX_ERROR_ARG; } // TODO: check esFilterId and esSpecificInfo correctly - dmuxQueryEsAttr(0, esFilterId, esSpecificInfo_addr, esAttr); + dmuxQueryEsAttr(0, esFilterId, esSpecificInfo, esAttr); return CELL_OK; } -int cellDmuxQueryEsAttr2(vm::ptr demuxerType2, vm::ptr esFilterId, - const u32 esSpecificInfo_addr, vm::ptr esAttr) +s32 cellDmuxQueryEsAttr2(vm::ptr type2, vm::ptr esFilterId, u32 esSpecificInfo, vm::ptr esAttr) { - cellDmux.Warning("cellDmuxQueryEsAttr2(demuxerType2_addr=0x%x, esFilterId_addr=0x%x, esSpecificInfo_addr=0x%x, esAttr_addr=0x%x)", - demuxerType2.addr(), esFilterId.addr(), esSpecificInfo_addr, esAttr.addr()); + cellDmux.Warning("cellDmuxQueryEsAttr2(type2=*0x%x, esFilterId=*0x%x, esSpecificInfo=*0x%x, esAttr=*0x%x)", type2, esFilterId, esSpecificInfo, esAttr); - if (demuxerType2->streamType != CELL_DMUX_STREAM_TYPE_PAMF) + if (type2->streamType != CELL_DMUX_STREAM_TYPE_PAMF) { return CELL_DMUX_ERROR_ARG; } // TODO: check demuxerType2, esFilterId and esSpecificInfo correctly - dmuxQueryEsAttr(demuxerType2->streamSpecificInfo_addr, esFilterId, esSpecificInfo_addr, esAttr); + dmuxQueryEsAttr(type2->streamSpecificInfo, esFilterId, esSpecificInfo, esAttr); return CELL_OK; } -int cellDmuxEnableEs(u32 demuxerHandle, vm::ptr esFilterId, - vm::ptr esResourceInfo, vm::ptr esCb, - const u32 esSpecificInfo_addr, vm::ptr esHandle) +s32 cellDmuxEnableEs(u32 handle, vm::ptr esFilterId, vm::ptr esResourceInfo, vm::ptr esCb, u32 esSpecificInfo, vm::ptr esHandle) { - cellDmux.Warning("cellDmuxEnableEs(demuxerHandle=%d, esFilterId_addr=0x%x, esResourceInfo_addr=0x%x, esCb_addr=0x%x, " - "esSpecificInfo_addr=0x%x, esHandle_addr=0x%x)", demuxerHandle, esFilterId.addr(), esResourceInfo.addr(), - esCb.addr(), esSpecificInfo_addr, esHandle.addr()); + cellDmux.Warning("cellDmuxEnableEs(handle=%d, esFilterId=*0x%x, esResourceInfo=*0x%x, esCb=*0x%x, esSpecificInfo=*0x%x, esHandle=*0x%x)", handle, esFilterId, esResourceInfo, esCb, esSpecificInfo, esHandle); - std::shared_ptr dmux; - if (!Emu.GetIdManager().GetIDData(demuxerHandle, dmux)) + const auto dmux = Emu.GetIdManager().GetIDData(handle); + + if (!dmux) { return CELL_DMUX_ERROR_ARG; } @@ -1008,14 +1000,14 @@ int cellDmuxEnableEs(u32 demuxerHandle, vm::ptr esFil std::shared_ptr es(new ElementaryStream(dmux.get(), esResourceInfo->memAddr, esResourceInfo->memSize, esFilterId->filterIdMajor, esFilterId->filterIdMinor, esFilterId->supplementalInfo1, esFilterId->supplementalInfo2, - esCb->cbEsMsgFunc, esCb->cbArg, esSpecificInfo_addr)); + esCb->cbEsMsgFunc, esCb->cbArg, esSpecificInfo)); u32 id = Emu.GetIdManager().GetNewID(es); es->id = id; *esHandle = id; - cellDmux.Warning("*** New ES(dmux=%d, addr=0x%x, size=0x%x, filter(0x%x, 0x%x, 0x%x, 0x%x), cb=0x%x(arg=0x%x), spec=0x%x): id = %d", - demuxerHandle, es->memAddr, es->memSize, es->fidMajor, es->fidMinor, es->sup1, es->sup2, es->cbFunc, es->cbArg, es->spec, id); + cellDmux.Warning("*** New ES(dmux=%d, addr=0x%x, size=0x%x, filter={0x%x, 0x%x, 0x%x, 0x%x}, cb=0x%x, arg=0x%x, spec=0x%x): id = %d", + handle, es->memAddr, es->memSize, es->fidMajor, es->fidMinor, es->sup1, es->sup2, es->cbFunc, es->cbArg, es->spec, id); DemuxerTask task(dmuxEnableEs); task.es.es = id; @@ -1025,12 +1017,13 @@ int cellDmuxEnableEs(u32 demuxerHandle, vm::ptr esFil return CELL_OK; } -int cellDmuxDisableEs(u32 esHandle) +s32 cellDmuxDisableEs(u32 esHandle) { - cellDmux.Warning("cellDmuxDisableEs(esHandle=0x%x)", esHandle); + cellDmux.Warning("cellDmuxDisableEs(esHandle=%d)", esHandle); - std::shared_ptr es; - if (!Emu.GetIdManager().GetIDData(esHandle, es)) + const auto es = Emu.GetIdManager().GetIDData(esHandle); + + if (!es) { return CELL_DMUX_ERROR_ARG; } @@ -1043,12 +1036,13 @@ int cellDmuxDisableEs(u32 esHandle) return CELL_OK; } -int cellDmuxResetEs(u32 esHandle) +s32 cellDmuxResetEs(u32 esHandle) { - cellDmux.Log("cellDmuxResetEs(esHandle=0x%x)", esHandle); + cellDmux.Log("cellDmuxResetEs(esHandle=%d)", esHandle); - std::shared_ptr es; - if (!Emu.GetIdManager().GetIDData(esHandle, es)) + const auto es = Emu.GetIdManager().GetIDData(esHandle); + + if (!es) { return CELL_DMUX_ERROR_ARG; } @@ -1061,13 +1055,13 @@ int cellDmuxResetEs(u32 esHandle) return CELL_OK; } -int cellDmuxGetAu(u32 esHandle, vm::ptr auInfo_ptr, vm::ptr auSpecificInfo_ptr) +s32 cellDmuxGetAu(u32 esHandle, vm::ptr auInfo, vm::ptr auSpecificInfo) { - cellDmux.Log("cellDmuxGetAu(esHandle=0x%x, auInfo_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", - esHandle, auInfo_ptr.addr(), auSpecificInfo_ptr.addr()); + cellDmux.Log("cellDmuxGetAu(esHandle=%d, auInfo=**0x%x, auSpecificInfo=**0x%x)", esHandle, auInfo, auSpecificInfo); - std::shared_ptr es; - if (!Emu.GetIdManager().GetIDData(esHandle, es)) + const auto es = Emu.GetIdManager().GetIDData(esHandle); + + if (!es) { return CELL_DMUX_ERROR_ARG; } @@ -1079,18 +1073,18 @@ int cellDmuxGetAu(u32 esHandle, vm::ptr auInfo_ptr, vm::ptr auSpecific return CELL_DMUX_ERROR_EMPTY; } - *auInfo_ptr = info; - *auSpecificInfo_ptr = spec; + *auInfo = info; + *auSpecificInfo = spec; return CELL_OK; } -int cellDmuxPeekAu(u32 esHandle, vm::ptr auInfo_ptr, vm::ptr auSpecificInfo_ptr) +s32 cellDmuxPeekAu(u32 esHandle, vm::ptr auInfo, vm::ptr auSpecificInfo) { - cellDmux.Log("cellDmuxPeekAu(esHandle=0x%x, auInfo_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", - esHandle, auInfo_ptr.addr(), auSpecificInfo_ptr.addr()); + cellDmux.Log("cellDmuxPeekAu(esHandle=%d, auInfo=**0x%x, auSpecificInfo=**0x%x)", esHandle, auInfo, auSpecificInfo); - std::shared_ptr es; - if (!Emu.GetIdManager().GetIDData(esHandle, es)) + const auto es = Emu.GetIdManager().GetIDData(esHandle); + + if (!es) { return CELL_DMUX_ERROR_ARG; } @@ -1102,18 +1096,18 @@ int cellDmuxPeekAu(u32 esHandle, vm::ptr auInfo_ptr, vm::ptr auSpecifi return CELL_DMUX_ERROR_EMPTY; } - *auInfo_ptr = info; - *auSpecificInfo_ptr = spec; + *auInfo = info; + *auSpecificInfo = spec; return CELL_OK; } -int cellDmuxGetAuEx(u32 esHandle, vm::ptr auInfoEx_ptr, vm::ptr auSpecificInfo_ptr) +s32 cellDmuxGetAuEx(u32 esHandle, vm::ptr auInfoEx, vm::ptr auSpecificInfo) { - cellDmux.Log("cellDmuxGetAuEx(esHandle=0x%x, auInfoEx_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", - esHandle, auInfoEx_ptr.addr(), auSpecificInfo_ptr.addr()); + cellDmux.Log("cellDmuxGetAuEx(esHandle=%d, auInfoEx=**0x%x, auSpecificInfo=**0x%x)", esHandle, auInfoEx, auSpecificInfo); - std::shared_ptr es; - if (!Emu.GetIdManager().GetIDData(esHandle, es)) + const auto es = Emu.GetIdManager().GetIDData(esHandle); + + if (!es) { return CELL_DMUX_ERROR_ARG; } @@ -1125,18 +1119,18 @@ int cellDmuxGetAuEx(u32 esHandle, vm::ptr auInfoEx_ptr, vm::ptr auSpec return CELL_DMUX_ERROR_EMPTY; } - *auInfoEx_ptr = info; - *auSpecificInfo_ptr = spec; + *auInfoEx = info; + *auSpecificInfo = spec; return CELL_OK; } -int cellDmuxPeekAuEx(u32 esHandle, vm::ptr auInfoEx_ptr, vm::ptr auSpecificInfo_ptr) +s32 cellDmuxPeekAuEx(u32 esHandle, vm::ptr auInfoEx, vm::ptr auSpecificInfo) { - cellDmux.Log("cellDmuxPeekAuEx(esHandle=0x%x, auInfoEx_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", - esHandle, auInfoEx_ptr.addr(), auSpecificInfo_ptr.addr()); + cellDmux.Log("cellDmuxPeekAuEx(esHandle=%d, auInfoEx=**0x%x, auSpecificInfo=**0x%x)", esHandle, auInfoEx, auSpecificInfo); - std::shared_ptr es; - if (!Emu.GetIdManager().GetIDData(esHandle, es)) + const auto es = Emu.GetIdManager().GetIDData(esHandle); + + if (!es) { return CELL_DMUX_ERROR_ARG; } @@ -1148,17 +1142,18 @@ int cellDmuxPeekAuEx(u32 esHandle, vm::ptr auInfoEx_ptr, vm::ptr auSpe return CELL_DMUX_ERROR_EMPTY; } - *auInfoEx_ptr = info; - *auSpecificInfo_ptr = spec; + *auInfoEx = info; + *auSpecificInfo = spec; return CELL_OK; } -int cellDmuxReleaseAu(u32 esHandle) +s32 cellDmuxReleaseAu(u32 esHandle) { - cellDmux.Log("cellDmuxReleaseAu(esHandle=0x%x)", esHandle); + cellDmux.Log("cellDmuxReleaseAu(esHandle=%d)", esHandle); - std::shared_ptr es; - if (!Emu.GetIdManager().GetIDData(esHandle, es)) + const auto es = Emu.GetIdManager().GetIDData(esHandle); + + if (!es) { return CELL_DMUX_ERROR_ARG; } @@ -1170,12 +1165,13 @@ int cellDmuxReleaseAu(u32 esHandle) return CELL_OK; } -int cellDmuxFlushEs(u32 esHandle) +s32 cellDmuxFlushEs(u32 esHandle) { - cellDmux.Warning("cellDmuxFlushEs(esHandle=0x%x)", esHandle); + cellDmux.Warning("cellDmuxFlushEs(esHandle=%d)", esHandle); - std::shared_ptr es; - if (!Emu.GetIdManager().GetIDData(esHandle, es)) + const auto es = Emu.GetIdManager().GetIDData(esHandle); + + if (!es) { return CELL_DMUX_ERROR_ARG; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.h b/rpcs3/Emu/SysCalls/Modules/cellDmux.h index 5456db607f..69ca3645d0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.h +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.h @@ -169,7 +169,7 @@ struct CellDmuxPamfSpecificInfo struct CellDmuxType2 { be_t streamType; - be_t streamSpecificInfo_addr; + be_t streamSpecificInfo; }; struct CellDmuxResource diff --git a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp index d24a129d62..3245e167a5 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp @@ -210,9 +210,9 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr entries, u32 { cellFs.Warning("cellFsGetDirectoryEntries(fd=0x%x, entries=*0x%x, entries_size=0x%x, data_count=*0x%x)", fd, entries, entries_size, data_count); - std::shared_ptr directory; + const auto directory = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, directory)) + if (!directory) { return CELL_FS_EBADF; } @@ -251,9 +251,9 @@ s32 cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr buf, u64 buffer_size, // TODO: use single sys_fs_fcntl syscall - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file) || file->flags & CELL_FS_O_WRONLY) + if (!file || file->flags & CELL_FS_O_WRONLY) { return CELL_FS_EBADF; } @@ -282,9 +282,9 @@ s32 cellFsWriteWithOffset(u32 fd, u64 offset, vm::ptr buf, u64 data_ // TODO: use single sys_fs_fcntl syscall - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file) || !(file->flags & CELL_FS_O_ACCMODE)) + if (!file || !(file->flags & CELL_FS_O_ACCMODE)) { return CELL_FS_EBADF; } @@ -326,9 +326,9 @@ s32 cellFsStReadInit(u32 fd, vm::ptr ringbuf) return CELL_FS_EINVAL; } - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { return CELL_FS_EBADF; } @@ -364,9 +364,9 @@ s32 cellFsStReadFinish(u32 fd) { cellFs.Warning("cellFsStReadFinish(fd=0x%x)", fd); - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { return CELL_FS_EBADF; // ??? } @@ -387,9 +387,9 @@ s32 cellFsStReadGetRingBuf(u32 fd, vm::ptr ringbuf) { cellFs.Warning("cellFsStReadGetRingBuf(fd=0x%x, ringbuf=*0x%x)", fd, ringbuf); - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { return CELL_FS_EBADF; } @@ -411,9 +411,9 @@ s32 cellFsStReadGetStatus(u32 fd, vm::ptr status) { cellFs.Warning("cellFsStReadGetRingBuf(fd=0x%x, status=*0x%x)", fd, status); - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { return CELL_FS_EBADF; } @@ -445,9 +445,9 @@ s32 cellFsStReadGetRegid(u32 fd, vm::ptr regid) { cellFs.Warning("cellFsStReadGetRingBuf(fd=0x%x, regid=*0x%x)", fd, regid); - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { return CELL_FS_EBADF; } @@ -466,9 +466,9 @@ s32 cellFsStReadStart(u32 fd, u64 offset, u64 size) { cellFs.Warning("cellFsStReadStart(fd=0x%x, offset=0x%llx, size=0x%llx)", fd, offset, size); - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { return CELL_FS_EBADF; } @@ -548,9 +548,9 @@ s32 cellFsStReadStop(u32 fd) { cellFs.Warning("cellFsStReadStop(fd=0x%x)", fd); - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { return CELL_FS_EBADF; } @@ -579,9 +579,9 @@ s32 cellFsStRead(u32 fd, vm::ptr buf, u64 size, vm::ptr rsize) { cellFs.Warning("cellFsStRead(fd=0x%x, buf=*0x%x, size=0x%llx, rsize=*0x%x)", fd, buf, size, rsize); - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { return CELL_FS_EBADF; } @@ -613,9 +613,9 @@ s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr addr, vm::ptr size) { cellFs.Warning("cellFsStReadGetCurrentAddr(fd=0x%x, addr=*0x%x, size=*0x%x)", fd, addr, size); - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { return CELL_FS_EBADF; } @@ -646,9 +646,9 @@ s32 cellFsStReadPutCurrentAddr(u32 fd, vm::ptr addr, u64 size) { cellFs.Warning("cellFsStReadPutCurrentAddr(fd=0x%x, addr=*0x%x, size=0x%llx)", fd, addr, size); - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { return CELL_FS_EBADF; } @@ -673,9 +673,9 @@ s32 cellFsStReadWait(u32 fd, u64 size) { cellFs.Warning("cellFsStReadWait(fd=0x%x, size=0x%llx)", fd, size); - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { return CELL_FS_EBADF; } @@ -707,9 +707,9 @@ s32 cellFsStReadWaitCallback(u32 fd, u64 size, fs_st_cb_t func) { cellFs.Warning("cellFsStReadWaitCallback(fd=0x%x, size=0x%llx, func=*0x%x)", fd, size, func); - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { return CELL_FS_EBADF; } @@ -875,9 +875,9 @@ void fsAio(vm::ptr aio, bool write, s32 xid, fs_aio_cb_t func) s32 error = CELL_OK; u64 result = 0; - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(aio->fd); - if (!Emu.GetIdManager().GetIDData(aio->fd, file) || (!write && file->flags & CELL_FS_O_WRONLY) || (write && !(file->flags & CELL_FS_O_ACCMODE))) + if (!file || (!write && file->flags & CELL_FS_O_WRONLY) || (write && !(file->flags & CELL_FS_O_ACCMODE))) { error = CELL_FS_EBADF; } @@ -979,11 +979,11 @@ s32 cellFsSetIoBufferFromDefaultContainer(u32 fd, u32 buffer_size, u32 page_type { cellFs.Todo("cellFsSetIoBufferFromDefaultContainer(fd=%d, buffer_size=%d, page_type=%d)", fd, buffer_size, page_type); - std::shared_ptr file; + const auto file = Emu.GetIdManager().GetIDData(fd); - if (!Emu.GetIdManager().GetIDData(fd, file)) + if (!file) { - CELL_FS_EBADF; + return CELL_FS_EBADF; } return CELL_OK; diff --git a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp index 1ce25e3082..daa5d80bde 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp @@ -4,8 +4,11 @@ #include "Emu/IdManager.h" #include "Emu/SysCalls/Modules.h" +extern "C" +{ #include "stblib/stb_image.h" -#include "stblib/stb_image.c" // (TODO: Should we put this elsewhere?) +#include "stblib/stb_image.c" +} #include "Emu/FS/VFS.h" #include "Emu/FS/vfsFileBase.h" diff --git a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp index 600f58bb40..f08f977357 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp @@ -4,7 +4,10 @@ #include "Emu/IdManager.h" #include "Emu/SysCalls/Modules.h" +extern "C" +{ #include "stblib/stb_image.h" +} #include "Emu/FS/VFS.h" #include "Emu/FS/vfsFileBase.h" diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp index 162e7a6ee9..518ea3c6e5 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp @@ -4,7 +4,10 @@ #include "Emu/IdManager.h" #include "Emu/SysCalls/Modules.h" +extern "C" +{ #include "stblib/stb_image.h" +} #include "Emu/FS/VFS.h" #include "Emu/FS/vfsFileBase.h" diff --git a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp index 7b289e13b0..f95429c8b7 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp @@ -268,12 +268,6 @@ u32 vdecOpen(VideoDecoder* vdec_ptr) { int err; - if (task.mode != CELL_VDEC_DEC_MODE_NORMAL) - { - cellVdec.Error("vdecDecodeAu: unsupported decoding mode(%d)", task.mode); - break; - } - vdec.reader.addr = task.addr; vdec.reader.size = task.size; //LOG_NOTICE(HLE, "Video AU: size = 0x%x, pts = 0x%llx, dts = 0x%llx", task.size, task.pts, task.dts); @@ -557,46 +551,45 @@ u32 vdecOpen(VideoDecoder* vdec_ptr) return vdec_id; } -int cellVdecQueryAttr(vm::ptr type, vm::ptr attr) +s32 cellVdecQueryAttr(vm::ptr type, vm::ptr attr) { - cellVdec.Warning("cellVdecQueryAttr(type_addr=0x%x, attr_addr=0x%x)", type.addr(), attr.addr()); + cellVdec.Warning("cellVdecQueryAttr(type=*0x%x, attr=*0x%x)", type, attr); return vdecQueryAttr(type->codecType, type->profileLevel, 0, attr); } -int cellVdecQueryAttrEx(vm::ptr type, vm::ptr attr) +s32 cellVdecQueryAttrEx(vm::ptr type, vm::ptr attr) { - cellVdec.Warning("cellVdecQueryAttrEx(type_addr=0x%x, attr_addr=0x%x)", type.addr(), attr.addr()); + cellVdec.Warning("cellVdecQueryAttrEx(type=*0x%x, attr=*0x%x)", type, attr); return vdecQueryAttr(type->codecType, type->profileLevel, type->codecSpecificInfo_addr, attr); } -int cellVdecOpen(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) +s32 cellVdecOpen(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) { - cellVdec.Warning("cellVdecOpen(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)", - type.addr(), res.addr(), cb.addr(), handle.addr()); + cellVdec.Warning("cellVdecOpen(type=*0x%x, res=*0x%x, cb=*0x%x, handle=*0x%x)", type, res, cb, handle); *handle = vdecOpen(new VideoDecoder(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg)); return CELL_OK; } -int cellVdecOpenEx(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) +s32 cellVdecOpenEx(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) { - cellVdec.Warning("cellVdecOpenEx(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)", - type.addr(), res.addr(), cb.addr(), handle.addr()); + cellVdec.Warning("cellVdecOpenEx(type=*0x%x, res=*0x%x, cb=*0x%x, handle=*0x%x)", type, res, cb, handle); *handle = vdecOpen(new VideoDecoder(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg)); return CELL_OK; } -int cellVdecClose(u32 handle) +s32 cellVdecClose(u32 handle) { cellVdec.Warning("cellVdecClose(handle=%d)", handle); - std::shared_ptr vdec; - if (!Emu.GetIdManager().GetIDData(handle, vdec)) + const auto vdec = Emu.GetIdManager().GetIDData(handle); + + if (!vdec) { return CELL_VDEC_ERROR_ARG; } @@ -619,12 +612,13 @@ int cellVdecClose(u32 handle) return CELL_OK; } -int cellVdecStartSeq(u32 handle) +s32 cellVdecStartSeq(u32 handle) { cellVdec.Log("cellVdecStartSeq(handle=%d)", handle); - std::shared_ptr vdec; - if (!Emu.GetIdManager().GetIDData(handle, vdec)) + const auto vdec = Emu.GetIdManager().GetIDData(handle); + + if (!vdec) { return CELL_VDEC_ERROR_ARG; } @@ -633,12 +627,13 @@ int cellVdecStartSeq(u32 handle) return CELL_OK; } -int cellVdecEndSeq(u32 handle) +s32 cellVdecEndSeq(u32 handle) { cellVdec.Warning("cellVdecEndSeq(handle=%d)", handle); - std::shared_ptr vdec; - if (!Emu.GetIdManager().GetIDData(handle, vdec)) + const auto vdec = Emu.GetIdManager().GetIDData(handle); + + if (!vdec) { return CELL_VDEC_ERROR_ARG; } @@ -647,16 +642,22 @@ int cellVdecEndSeq(u32 handle) return CELL_OK; } -int cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, vm::ptr auInfo) +s32 cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, vm::ptr auInfo) { - cellVdec.Log("cellVdecDecodeAu(handle=%d, mode=0x%x, auInfo_addr=0x%x)", handle, mode, auInfo.addr()); + cellVdec.Log("cellVdecDecodeAu(handle=%d, mode=%d, auInfo=*0x%x)", handle, mode, auInfo); - std::shared_ptr vdec; - if (!Emu.GetIdManager().GetIDData(handle, vdec)) + const auto vdec = Emu.GetIdManager().GetIDData(handle); + + if (!vdec || mode > CELL_VDEC_DEC_MODE_PB_SKIP) { return CELL_VDEC_ERROR_ARG; } + if (mode != CELL_VDEC_DEC_MODE_NORMAL) + { + cellVdec.Fatal("cellVdecDecodeAu(): unsupported decoding mode (%d)", mode); + } + // TODO: check info VdecTask task(vdecDecodeAu); task.mode = mode; @@ -671,12 +672,13 @@ int cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, vm::ptr format, vm::ptr outBuff) +s32 cellVdecGetPicture(u32 handle, vm::ptr format, vm::ptr outBuff) { - cellVdec.Log("cellVdecGetPicture(handle=%d, format_addr=0x%x, outBuff_addr=0x%x)", handle, format.addr(), outBuff.addr()); + cellVdec.Log("cellVdecGetPicture(handle=%d, format=*0x%x, outBuff=*0x%x)", handle, format, outBuff); - std::shared_ptr vdec; - if (!Emu.GetIdManager().GetIDData(handle, vdec)) + const auto vdec = Emu.GetIdManager().GetIDData(handle); + + if (!vdec) { return CELL_VDEC_ERROR_ARG; } @@ -726,12 +728,13 @@ int cellVdecGetPicture(u32 handle, vm::ptr format, vm:: return CELL_OK; } -int cellVdecGetPicItem(u32 handle, vm::ptr picItem_ptr) +s32 cellVdecGetPicItem(u32 handle, vm::ptr> picItem) { - cellVdec.Log("cellVdecGetPicItem(handle=%d, picItem_ptr_addr=0x%x)", handle, picItem_ptr.addr()); + cellVdec.Log("cellVdecGetPicItem(handle=%d, picItem=**0x%x)", handle, picItem); - std::shared_ptr vdec; - if (!Emu.GetIdManager().GetIDData(handle, vdec)) + const auto vdec = Emu.GetIdManager().GetIDData(handle); + + if (!vdec) { return CELL_VDEC_ERROR_ARG; } @@ -745,7 +748,7 @@ int cellVdecGetPicItem(u32 handle, vm::ptr picItem_ptr) AVFrame& frame = *vf.data; - auto info = vm::ptr::make(vdec->memAddr + vdec->memBias); + const auto info = vm::ptr::make(vdec->memAddr + vdec->memBias); vdec->memBias += 512; if (vdec->memBias + 512 > vdec->memSize) @@ -866,16 +869,17 @@ int cellVdecGetPicItem(u32 handle, vm::ptr picItem_ptr) cellVdec.Fatal("cellVdecGetPicItem(MPEG2)"); } - *picItem_ptr = info.addr(); + *picItem = info; return CELL_OK; } -int cellVdecSetFrameRate(u32 handle, CellVdecFrameRate frc) +s32 cellVdecSetFrameRate(u32 handle, CellVdecFrameRate frc) { cellVdec.Log("cellVdecSetFrameRate(handle=%d, frc=0x%x)", handle, frc); - std::shared_ptr vdec; - if (!Emu.GetIdManager().GetIDData(handle, vdec)) + const auto vdec = Emu.GetIdManager().GetIDData(handle); + + if (!vdec) { return CELL_VDEC_ERROR_ARG; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp index 910b1c731e..88e0bdd990 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp @@ -13,9 +13,9 @@ extern "C" extern Module cellVpost; -int cellVpostQueryAttr(vm::ptr cfgParam, vm::ptr attr) +s32 cellVpostQueryAttr(vm::ptr cfgParam, vm::ptr attr) { - cellVpost.Warning("cellVpostQueryAttr(cfgParam_addr=0x%x, attr_addr=0x%x)", cfgParam.addr(), attr.addr()); + cellVpost.Warning("cellVpostQueryAttr(cfgParam=*0x%x, attr=*0x%x)", cfgParam, attr); // TODO: check cfgParam and output values @@ -37,32 +37,31 @@ u32 vpostOpen(VpostInstance* data) return id; } -int cellVpostOpen(vm::ptr cfgParam, vm::ptr resource, vm::ptr handle) +s32 cellVpostOpen(vm::ptr cfgParam, vm::ptr resource, vm::ptr handle) { - cellVpost.Warning("cellVpostOpen(cfgParam_addr=0x%x, resource_addr=0x%x, handle_addr=0x%x)", - cfgParam.addr(), resource.addr(), handle.addr()); + cellVpost.Warning("cellVpostOpen(cfgParam=*0x%x, resource=*0x%x, handle=*0x%x)", cfgParam, resource, handle); // TODO: check values *handle = vpostOpen(new VpostInstance(cfgParam->outPicFmt == CELL_VPOST_PIC_FMT_OUT_RGBA_ILV)); return CELL_OK; } -int cellVpostOpenEx(vm::ptr cfgParam, vm::ptr resource, vm::ptr handle) +s32 cellVpostOpenEx(vm::ptr cfgParam, vm::ptr resource, vm::ptr handle) { - cellVpost.Warning("cellVpostOpenEx(cfgParam_addr=0x%x, resource_addr=0x%x, handle_addr=0x%x)", - cfgParam.addr(), resource.addr(), handle.addr()); + cellVpost.Warning("cellVpostOpenEx(cfgParam=*0x%x, resource=*0x%x, handle=*0x%x)", cfgParam, resource, handle); // TODO: check values *handle = vpostOpen(new VpostInstance(cfgParam->outPicFmt == CELL_VPOST_PIC_FMT_OUT_RGBA_ILV)); return CELL_OK; } -int cellVpostClose(u32 handle) +s32 cellVpostClose(u32 handle) { - cellVpost.Warning("cellVpostClose(handle=0x%x)", handle); + cellVpost.Warning("cellVpostClose(handle=%d)", handle); - std::shared_ptr vpost; - if (!Emu.GetIdManager().GetIDData(handle, vpost)) + const auto vpost = Emu.GetIdManager().GetIDData(handle); + + if (!vpost) { return CELL_VPOST_ERROR_C_ARG_HDL_INVALID; } @@ -71,14 +70,13 @@ int cellVpostClose(u32 handle) return CELL_OK; } -int cellVpostExec(u32 handle, vm::ptr inPicBuff, vm::ptr ctrlParam, - vm::ptr outPicBuff, vm::ptr picInfo) +s32 cellVpostExec(u32 handle, vm::ptr inPicBuff, vm::ptr ctrlParam, vm::ptr outPicBuff, vm::ptr picInfo) { - cellVpost.Log("cellVpostExec(handle=0x%x, inPicBuff_addr=0x%x, ctrlParam_addr=0x%x, outPicBuff_addr=0x%x, picInfo_addr=0x%x)", - handle, inPicBuff.addr(), ctrlParam.addr(), outPicBuff.addr(), picInfo.addr()); + cellVpost.Log("cellVpostExec(handle=%d, inPicBuff=*0x%x, ctrlParam=*0x%x, outPicBuff=*0x%x, picInfo=*0x%x)", handle, inPicBuff, ctrlParam, outPicBuff, picInfo); - std::shared_ptr vpost; - if (!Emu.GetIdManager().GetIDData(handle, vpost)) + const auto vpost = Emu.GetIdManager().GetIDData(handle); + + if (!vpost) { return CELL_VPOST_ERROR_E_ARG_HDL_INVALID; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h index ae7057bbef..8aeb276359 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h @@ -17,14 +17,14 @@ enum : u64 struct sys_ppu_thread_stack_t { - u32 pst_addr; - u32 pst_size; + be_t pst_addr; + be_t pst_size; }; struct ppu_thread_param_t { - u32 entry; - u32 tls; + be_t entry; // vm::bptr + be_t tls; // vm::bptr }; // Aux diff --git a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp index 81c79aacf4..020de0a723 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp @@ -49,9 +49,9 @@ s32 sys_rwlock_destroy(u32 rw_lock_id) LV2_LOCK; - std::shared_ptr rwlock; + const auto rwlock = Emu.GetIdManager().GetIDData(rw_lock_id); - if (!Emu.GetIdManager().GetIDData(rw_lock_id, rwlock)) + if (!rwlock) { return CELL_ESRCH; } @@ -74,9 +74,9 @@ s32 sys_rwlock_rlock(u32 rw_lock_id, u64 timeout) LV2_LOCK; - std::shared_ptr rwlock; + const auto rwlock = Emu.GetIdManager().GetIDData(rw_lock_id); - if (!Emu.GetIdManager().GetIDData(rw_lock_id, rwlock)) + if (!rwlock) { return CELL_ESRCH; } @@ -113,9 +113,9 @@ s32 sys_rwlock_tryrlock(u32 rw_lock_id) LV2_LOCK; - std::shared_ptr rwlock; + const auto rwlock = Emu.GetIdManager().GetIDData(rw_lock_id); - if (!Emu.GetIdManager().GetIDData(rw_lock_id, rwlock)) + if (!rwlock) { return CELL_ESRCH; } @@ -136,9 +136,9 @@ s32 sys_rwlock_runlock(u32 rw_lock_id) LV2_LOCK; - std::shared_ptr rwlock; + const auto rwlock = Emu.GetIdManager().GetIDData(rw_lock_id); - if (!Emu.GetIdManager().GetIDData(rw_lock_id, rwlock)) + if (!rwlock) { return CELL_ESRCH; } @@ -164,9 +164,9 @@ s32 sys_rwlock_wlock(PPUThread& CPU, u32 rw_lock_id, u64 timeout) LV2_LOCK; - std::shared_ptr rwlock; + const auto rwlock = Emu.GetIdManager().GetIDData(rw_lock_id); - if (!Emu.GetIdManager().GetIDData(rw_lock_id, rwlock)) + if (!rwlock) { return CELL_ESRCH; } @@ -208,9 +208,9 @@ s32 sys_rwlock_trywlock(PPUThread& CPU, u32 rw_lock_id) LV2_LOCK; - std::shared_ptr rwlock; + const auto rwlock = Emu.GetIdManager().GetIDData(rw_lock_id); - if (!Emu.GetIdManager().GetIDData(rw_lock_id, rwlock)) + if (!rwlock) { return CELL_ESRCH; } @@ -236,9 +236,9 @@ s32 sys_rwlock_wunlock(PPUThread& CPU, u32 rw_lock_id) LV2_LOCK; - std::shared_ptr rwlock; + const auto rwlock = Emu.GetIdManager().GetIDData(rw_lock_id); - if (!Emu.GetIdManager().GetIDData(rw_lock_id, rwlock)) + if (!rwlock) { return CELL_ESRCH; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp index 72b7fd7bd0..2c7f95e87a 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp @@ -61,9 +61,9 @@ s32 sys_semaphore_destroy(u32 sem) LV2_LOCK; - std::shared_ptr semaphore; + const auto semaphore = Emu.GetIdManager().GetIDData(sem); - if (!Emu.GetIdManager().GetIDData(sem, semaphore)) + if (!semaphore) { return CELL_ESRCH; } @@ -86,9 +86,9 @@ s32 sys_semaphore_wait(u32 sem, u64 timeout) LV2_LOCK; - std::shared_ptr semaphore; + const auto semaphore = Emu.GetIdManager().GetIDData(sem); - if (!Emu.GetIdManager().GetIDData(sem, semaphore)) + if (!semaphore) { return CELL_ESRCH; } @@ -125,9 +125,9 @@ s32 sys_semaphore_trywait(u32 sem) LV2_LOCK; - std::shared_ptr semaphore; + const auto semaphore = Emu.GetIdManager().GetIDData(sem); - if (!Emu.GetIdManager().GetIDData(sem, semaphore)) + if (!semaphore) { return CELL_ESRCH; } @@ -148,9 +148,9 @@ s32 sys_semaphore_post(u32 sem, s32 count) LV2_LOCK; - std::shared_ptr semaphore; + const auto semaphore = Emu.GetIdManager().GetIDData(sem); - if (!Emu.GetIdManager().GetIDData(sem, semaphore)) + if (!semaphore) { return CELL_ESRCH; } @@ -189,9 +189,9 @@ s32 sys_semaphore_get_value(u32 sem, vm::ptr count) LV2_LOCK; - std::shared_ptr semaphore; + const auto semaphore = Emu.GetIdManager().GetIDData(sem); - if (!Emu.GetIdManager().GetIDData(sem, semaphore)) + if (!semaphore) { return CELL_ESRCH; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp b/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp index 823199a827..d0d45c19c8 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp @@ -28,7 +28,7 @@ s32 sys_timer_create(vm::ptr timer_id) { if (get_system_time() >= timer->start) { - std::shared_ptr queue = timer->port.lock(); + const auto queue = timer->port.lock(); if (queue) { @@ -62,9 +62,9 @@ s32 sys_timer_destroy(u32 timer_id) LV2_LOCK; - std::shared_ptr timer; + const auto timer = Emu.GetIdManager().GetIDData(timer_id); - if (!Emu.GetIdManager().GetIDData(timer_id, timer)) + if (!timer) { return CELL_ESRCH; } @@ -85,9 +85,9 @@ s32 sys_timer_get_information(u32 timer_id, vm::ptr inf LV2_LOCK; - std::shared_ptr timer; + const auto timer = Emu.GetIdManager().GetIDData(timer_id); - if (!Emu.GetIdManager().GetIDData(timer_id, timer)) + if (!timer) { return CELL_ESRCH; } @@ -108,9 +108,9 @@ s32 _sys_timer_start(u32 timer_id, u64 base_time, u64 period) LV2_LOCK; - std::shared_ptr timer; + const auto timer = Emu.GetIdManager().GetIDData(timer_id); - if (!Emu.GetIdManager().GetIDData(timer_id, timer)) + if (!timer) { return CELL_ESRCH; } @@ -160,9 +160,9 @@ s32 sys_timer_stop(u32 timer_id) LV2_LOCK; - std::shared_ptr timer; + const auto timer = Emu.GetIdManager().GetIDData(timer_id); - if (!Emu.GetIdManager().GetIDData(timer_id, timer)) + if (!timer) { return CELL_ESRCH; } @@ -178,10 +178,10 @@ s32 sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data LV2_LOCK; - std::shared_ptr timer; - std::shared_ptr queue; + const auto timer = Emu.GetIdManager().GetIDData(timer_id); + const auto queue = Emu.GetIdManager().GetIDData(queue_id); - if (!Emu.GetIdManager().GetIDData(timer_id, timer) || !Emu.GetIdManager().GetIDData(queue_id, queue)) + if (!timer || !queue) { return CELL_ESRCH; } @@ -205,9 +205,9 @@ s32 sys_timer_disconnect_event_queue(u32 timer_id) LV2_LOCK; - std::shared_ptr timer; + const auto timer = Emu.GetIdManager().GetIDData(timer_id); - if (!Emu.GetIdManager().GetIDData(timer_id, timer)) + if (!timer) { return CELL_ESRCH; }