#include "stdafx.h" #include "Emu/Cell/PPUModule.h" #include "Emu/IdManager.h" #include "cellSysutil.h" LOG_CHANNEL(cellRec); enum { CELL_REC_STATUS_UNLOAD = 0, CELL_REC_STATUS_OPEN = 1, CELL_REC_STATUS_START = 2, CELL_REC_STATUS_STOP = 3, CELL_REC_STATUS_CLOSE = 4, CELL_REC_STATUS_ERR = 10 }; struct CellRecSpursParam { vm::bptr pSpurs; be_t spu_usage_rate; u8 priority[8]; }; struct CellRecOption { be_t option; union { be_t ppu_thread_priority; be_t spu_thread_priority; be_t capture_priority; be_t use_system_spu; be_t fit_to_youtube; be_t xmb_bgm; be_t mpeg4_fast_encode; be_t ring_sec; be_t video_input; be_t audio_input; be_t audio_input_mix_vol; be_t reduce_memsize; be_t show_xmb; vm::bptr metadata_filename; vm::bptr pSpursParam; be_t dummy; } value; }; struct CellRecParam { be_t videoFmt; be_t audioFmt; be_t numOfOpt; vm::bptr pOpt; }; using CellRecCallback = void(s32 recStatus, s32 recError, vm::ptr userdata); struct rec_info { vm::ptr cb{}; vm::ptr cbUserData{}; shared_mutex mutex; }; error_code cellRecOpen(vm::cptr pDirName, vm::cptr pFileName, vm::cptr pParam, u32 container, vm::ptr cb, vm::ptr cbUserData) { cellRec.todo("cellRecOpen(pDirName=%s, pFileName=%s, pParam=*0x%x, container=0x%x, cb=*0x%x, cbUserData=*0x%x)", pDirName, pFileName, pParam, container, cb, cbUserData); auto& rec = g_fxo->get(); rec.cb = cb; rec.cbUserData = cbUserData; sysutil_register_cb([=](ppu_thread& ppu) -> s32 { cb(ppu, CELL_REC_STATUS_OPEN, CELL_OK, cbUserData); return CELL_OK; }); return CELL_OK; } error_code cellRecClose(s32 isDiscard) { cellRec.todo("cellRecClose(isDiscard=0x%x)", isDiscard); auto& rec = g_fxo->get(); sysutil_register_cb([=, &rec](ppu_thread& ppu) -> s32 { rec.cb(ppu, CELL_REC_STATUS_CLOSE, CELL_OK, rec.cbUserData); return CELL_OK; }); return CELL_OK; } void cellRecGetInfo(s32 info, vm::ptr pValue) { cellRec.todo("cellRecGetInfo(info=0x%x, pValue=*0x%x)", info, pValue); } error_code cellRecStop() { cellRec.todo("cellRecStop()"); auto& rec = g_fxo->get(); sysutil_register_cb([=, &rec](ppu_thread& ppu) -> s32 { rec.cb(ppu, CELL_REC_STATUS_STOP, CELL_OK, rec.cbUserData); return CELL_OK; }); return CELL_OK; } error_code cellRecStart() { cellRec.todo("cellRecStart()"); auto& rec = g_fxo->get(); sysutil_register_cb([=, &rec](ppu_thread& ppu) -> s32 { rec.cb(ppu, CELL_REC_STATUS_START, CELL_OK, rec.cbUserData); return CELL_OK; }); return CELL_OK; } u32 cellRecQueryMemSize(vm::cptr pParam) { cellRec.todo("cellRecQueryMemSize(pParam=*0x%x)", pParam); return 1 * 1024 * 1024; // dummy memory size } error_code cellRecSetInfo(s32 setInfo, u64 value) { cellRec.todo("cellRecSetInfo(setInfo=0x%x, value=0x%x)", setInfo, value); return CELL_OK; } DECLARE(ppu_module_manager::cellRec)("cellRec", []() { REG_FUNC(cellRec, cellRecOpen); REG_FUNC(cellRec, cellRecClose); REG_FUNC(cellRec, cellRecGetInfo); REG_FUNC(cellRec, cellRecStop); REG_FUNC(cellRec, cellRecStart); REG_FUNC(cellRec, cellRecQueryMemSize); REG_FUNC(cellRec, cellRecSetInfo); });