Merge pull request #20209 from hrydgard/more-hle-work

More HLE cleanup, fix MP3 in sceAudiocodec
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2025-04-04 01:21:56 +02:00
commit 8734df7cba
17 files changed
+369 -401

No files matched your search

-1
View File
@@ -30,7 +30,6 @@ public:
uint32_t m_z;
};
// Data must consist only of the index and the twister array. This matches the PSP
// MT context exactly.
class MersenneTwister {
+1
View File
@@ -67,6 +67,7 @@ enum class Log {
sceSas,
sceUtility,
sceMisc,
sceReg,
NUMBER_OF_LOGS, // Must be last
};
+1
View File
@@ -105,6 +105,7 @@ static const char * const g_logTypeNames[] = {
"SCESAS",
"SCEUTIL",
"SCEMISC",
"SCEREG",
};
const char *LogManager::GetLogTypeName(Log type) {
+9
View File
@@ -503,4 +503,13 @@ enum PSPErrorCode : u32 {
SCE_REG_ERROR_CATEGORY_NOT_FOUND = 0x80082718,
SCE_REG_ERROR_INVALID_NAME = 0x80082738,
SCE_REG_ERROR_PERMISSION_FAILURE = 0x8008273b,
SCE_MP3_ERROR_INVALID_HANDLE = 0x80671001,
SCE_MP3_ERROR_UNRESERVED_HANDLE = 0x80671102,
SCE_MP3_ERROR_NOT_YET_INIT_HANDLE = 0x80671103,
SCE_MP3_ERROR_NO_RESOURCE_AVAIL = 0x80671201,
SCE_MP3_ERROR_BAD_SAMPLE_RATE = 0x80671302,
SCE_MP3_ERROR_BAD_RESET_FRAME = 0x80671501,
SCE_MP3_ERROR_BAD_ADDR = 0x80671002,
SCE_MP3_ERROR_BAD_SIZE = 0x80671003,
};
+16 -12
View File
@@ -144,15 +144,10 @@ static int __AudioCodecInitCommon(u32 ctxPtr, int codec, bool mono) {
}
// Create audio decoder for given audio codec and push it into AudioList
if (inFrameBytes) {
INFO_LOG(Log::ME, "sceAudioDecoder: Creating codec with %04x frame size and %d channels, codec %04x", inFrameBytes, channels, codec);
AudioDecoder *decoder = CreateAudioDecoder(audioType, 44100, channels, inFrameBytes);
decoder->SetCtxPtr(ctxPtr);
g_audioDecoderContexts[ctxPtr] = decoder;
} else {
ERROR_LOG(Log::ME, "sceAudioDecoder: Unsupported codec %08x", codec);
g_audioDecoderContexts[ctxPtr] = nullptr;
}
INFO_LOG(Log::ME, "sceAudioDecoder: Creating codec with %04x frame size and %d channels, codec %04x", inFrameBytes, channels, codec);
AudioDecoder *decoder = CreateAudioDecoder(audioType, 44100, channels, inFrameBytes);
decoder->SetCtxPtr(ctxPtr);
g_audioDecoderContexts[ctxPtr] = decoder;
return hleLogDebug(Log::ME, 0);
}
@@ -178,9 +173,18 @@ static int sceAudiocodecDecode(u32 ctxPtr, int codec) {
// TODO: Should check that codec corresponds to the currently used codec in the context, I guess..
auto ctx = PSPPointer<SceAudiocodecCodec>::Create(ctxPtr); // On game-owned heap, no need to allocate.
int inFrameBytes;
int channels;
CalculateInputBytesAndChannelsAt3Plus(ctx, &inFrameBytes, &channels);
int inFrameBytes = 0;
int channels = 2;
switch (codec) {
case PSP_CODEC_AT3PLUS:
CalculateInputBytesAndChannelsAt3Plus(ctx, &inFrameBytes, &channels);
break;
case PSP_CODEC_MP3:
inFrameBytes = ctx->srcBytesRead;
break;
}
// find a decoder in audioList
auto decoder = findDecoder(ctxPtr);
+8 -16
View File
@@ -19,28 +19,20 @@
#include "Core/HLE/FunctionWrappers.h"
#include "Core/HLE/sceGameUpdate.h"
static u32 sceGameUpdateInit()
{
ERROR_LOG(Log::sceUtility, "UNIMPL sceGameUpdateInit()");
return 0;
static u32 sceGameUpdateInit() {
return hleLogError(Log::sceUtility, 0, "UNIMPL");
}
static u32 sceGameUpdateTerm()
{
ERROR_LOG(Log::sceUtility, "UNIMPL sceGameUpdateTerm()");
return 0;
static u32 sceGameUpdateTerm() {
return hleLogError(Log::sceUtility, 0, "UNIMPL");
}
static u32 sceGameUpdateRun()
{
ERROR_LOG(Log::sceUtility, "UNIMPL sceGameUpdateRun()");
return 0;
static u32 sceGameUpdateRun() {
return hleLogError(Log::sceUtility, 0, "UNIMPL");
}
static u32 sceGameUpdateAbort()
{
ERROR_LOG(Log::sceUtility, "UNIMPL sceGameUpdateAbort()");
return 0;
static u32 sceGameUpdateAbort() {
return hleLogError(Log::sceUtility, 0, "UNIMPL");
}
const HLEFunction sceGameUpdate[] =
+24 -40
View File
@@ -83,52 +83,48 @@ void __HeapShutdown() {
static int sceHeapReallocHeapMemory(u32 heapAddr, u32 memPtr, int memSize) {
ERROR_LOG_REPORT(Log::HLE,"UNIMPL sceHeapReallocHeapMemory(%08x, %08x, %08x)", heapAddr, memPtr, memSize);
return 0;
return hleNoLog(0);
}
static int sceHeapReallocHeapMemoryWithOption(u32 heapPtr, u32 memPtr, int memSize, u32 paramsPtr) {
ERROR_LOG_REPORT(Log::HLE,"UNIMPL sceHeapReallocHeapMemoryWithOption(%08x, %08x, %08x, %08x)", heapPtr, memPtr, memSize, paramsPtr);
return 0;
return hleNoLog(0);
}
static int sceHeapFreeHeapMemory(u32 heapAddr, u32 memAddr) {
Heap *heap = getHeap(heapAddr);
if (!heap) {
ERROR_LOG(Log::HLE, "sceHeapFreeHeapMemory(%08x, %08x): invalid heap", heapAddr, memAddr);
return SCE_KERNEL_ERROR_INVALID_ID;
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_INVALID_ID, "invalid heap");
}
DEBUG_LOG(Log::HLE, "sceHeapFreeHeapMemory(%08x, %08x)", heapAddr, memAddr);
// An invalid address will crash the PSP, but 0 is always returns success.
if (memAddr == 0) {
return 0;
return hleLogDebug(Log::HLE, 0);
}
if (!heap->alloc.FreeExact(memAddr)) {
return SCE_KERNEL_ERROR_INVALID_POINTER;
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_INVALID_POINTER);
}
return 0;
return hleLogDebug(Log::HLE, 0);
}
static int sceHeapGetMallinfo(u32 heapAddr, u32 infoPtr) {
ERROR_LOG_REPORT(Log::HLE,"UNIMPL sceHeapGetMallinfo(%08x, %08x)", heapAddr, infoPtr);
return 0;
return hleNoLog(0);
}
static u32 sceHeapAllocHeapMemoryWithOption(u32 heapAddr, u32 memSize, u32 paramsPtr) {
Heap *heap = getHeap(heapAddr);
u32 grain = 4;
if (!heap) {
ERROR_LOG(Log::HLE, "sceHeapAllocHeapMemoryWithOption(%08x, %08x, %08x): invalid heap", heapAddr, memSize, paramsPtr);
return 0;
return hleLogError(Log::HLE, 0, "invalid heap");
}
u32 grain = 4;
// 0 is ignored.
if (paramsPtr != 0) {
u32 size = Memory::Read_U32(paramsPtr);
if (size < 8) {
ERROR_LOG(Log::HLE, "sceHeapAllocHeapMemoryWithOption(%08x, %08x, %08x): invalid param size", heapAddr, memSize, paramsPtr);
return 0;
return hleLogError(Log::HLE, 0, "invalid param size");
}
if (size > 8) {
WARN_LOG_REPORT(Log::HLE, "sceHeapAllocHeapMemoryWithOption(): unexpected param size %d", size);
@@ -136,56 +132,48 @@ static u32 sceHeapAllocHeapMemoryWithOption(u32 heapAddr, u32 memSize, u32 param
grain = Memory::Read_U32(paramsPtr + 4);
}
DEBUG_LOG(Log::HLE,"sceHeapAllocHeapMemoryWithOption(%08x, %08x, %08x)", heapAddr, memSize, paramsPtr);
// There's 8 bytes at the end of every block, reserved.
memSize += 8;
u32 addr = heap->alloc.AllocAligned(memSize, grain, grain, true);
return addr;
return hleLogDebug(Log::HLE, addr);
}
static int sceHeapGetTotalFreeSize(u32 heapAddr) {
Heap *heap = getHeap(heapAddr);
if (!heap) {
ERROR_LOG(Log::HLE, "sceHeapGetTotalFreeSize(%08x): invalid heap", heapAddr);
return SCE_KERNEL_ERROR_INVALID_ID;
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_INVALID_ID, "invalid heap");
}
DEBUG_LOG(Log::HLE, "sceHeapGetTotalFreeSize(%08x)", heapAddr);
u32 free = heap->alloc.GetTotalFreeBytes();
if (free >= 8) {
// Every allocation requires an extra 8 bytes.
free -= 8;
}
return free;
return hleLogDebug(Log::HLE, free);
}
static int sceHeapIsAllocatedHeapMemory(u32 heapPtr, u32 memPtr) {
if (!Memory::IsValidAddress(memPtr)) {
ERROR_LOG(Log::HLE, "sceHeapIsAllocatedHeapMemory(%08x, %08x): invalid address", heapPtr, memPtr);
return SCE_KERNEL_ERROR_INVALID_POINTER;
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_INVALID_POINTER, "invalid address");
}
DEBUG_LOG(Log::HLE, "sceHeapIsAllocatedHeapMemory(%08x, %08x)", heapPtr, memPtr);
Heap *heap = getHeap(heapPtr);
// An invalid heap is fine, it's not a member of this heap one way or another.
// Only an exact address matches. Off by one crashes, and off by 4 says no.
if (heap && heap->alloc.GetBlockStartFromAddress(memPtr) == memPtr) {
return 1;
return hleLogDebug(Log::HLE, 1);
}
return 0;
return hleLogDebug(Log::HLE, 0);
}
static int sceHeapDeleteHeap(u32 heapAddr) {
Heap *heap = getHeap(heapAddr);
if (!heap) {
ERROR_LOG(Log::HLE, "sceHeapDeleteHeap(%08x): invalid heap", heapAddr);
return SCE_KERNEL_ERROR_INVALID_ID;
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_INVALID_ID, "invalid heap");
}
DEBUG_LOG(Log::HLE, "sceHeapDeleteHeap(%08x)", heapAddr);
heapList.erase(heapAddr);
delete heap;
return 0;
return hleLogDebug(Log::HLE, 0);
}
static int sceHeapCreateHeap(const char* name, u32 heapSize, int attr, u32 paramsPtr) {
@@ -193,9 +181,9 @@ static int sceHeapCreateHeap(const char* name, u32 heapSize, int attr, u32 param
u32 size = Memory::Read_U32(paramsPtr);
WARN_LOG_REPORT(Log::HLE, "sceHeapCreateHeap(): unsupported options parameter, size = %d", size);
}
if (name == NULL) {
if (!name) {
WARN_LOG_REPORT(Log::HLE, "sceHeapCreateHeap(): name is NULL");
return 0;
return hleNoLog(0);
}
int allocSize = (heapSize + 3) & ~3;
@@ -204,33 +192,29 @@ static int sceHeapCreateHeap(const char* name, u32 heapSize, int attr, u32 param
heap->fromtop = (attr & PSP_HEAP_ATTR_HIGHMEM) != 0;
u32 addr = userMemory.Alloc(heap->size, heap->fromtop, StringFromFormat("Heap/%s", name).c_str());
if (addr == (u32)-1) {
ERROR_LOG(Log::HLE, "sceHeapCreateHeap(): Failed to allocate %i bytes memory", allocSize);
delete heap;
return 0;
return hleLogError(Log::HLE, 0, "Failed to allocate %i bytes memory", allocSize);
}
heap->address = addr;
// Some of the heap is reserved by the implementation (the first 128 bytes, and 8 after each block.)
heap->alloc.Init(heap->address + 128, heap->size - 128, true);
heapList[heap->address] = heap;
DEBUG_LOG(Log::HLE, "%08x=sceHeapCreateHeap(%s, %08x, %08x, %08x)", heap->address, name, heapSize, attr, paramsPtr);
return heap->address;
return hleLogDebug(Log::HLE, heap->address);
}
static u32 sceHeapAllocHeapMemory(u32 heapAddr, u32 memSize) {
Heap *heap = getHeap(heapAddr);
if (!heap) {
ERROR_LOG(Log::HLE, "sceHeapAllocHeapMemory(%08x, %08x): invalid heap", heapAddr, memSize);
// Yes, not 0 (returns a pointer), but an error code. Strange.
return SCE_KERNEL_ERROR_INVALID_ID;
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_INVALID_ID, "invalid heap");
}
DEBUG_LOG(Log::HLE, "sceHeapAllocHeapMemory(%08x, %08x)", heapAddr, memSize);
// There's 8 bytes at the end of every block, reserved.
memSize += 8;
// Always goes down, regardless of whether the heap is high or low.
u32 addr = heap->alloc.Alloc(memSize, true);
return addr;
return hleLogDebug(Log::HLE, addr);
}
+9
View File
@@ -1503,6 +1503,15 @@ const char *KernelErrorToString(u32 err) {
case SCE_REG_ERROR_INVALID_NAME: return "SCE_REG_ERROR_INVALID_NAME";
case SCE_REG_ERROR_PERMISSION_FAILURE: return "SCE_REG_ERROR_PERMISSION_FAILURE";
case SCE_MP3_ERROR_INVALID_HANDLE: return "SCE_MP3_ERROR_INVALID_HANDLE";
case SCE_MP3_ERROR_UNRESERVED_HANDLE: return "SCE_MP3_ERROR_UNRESERVED_HANDLE";
case SCE_MP3_ERROR_NOT_YET_INIT_HANDLE: return "SCE_MP3_ERROR_NOT_YET_INIT_HANDLE";
case SCE_MP3_ERROR_NO_RESOURCE_AVAIL: return "SCE_MP3_ERROR_NO_RESOURCE_AVAIL";
case SCE_MP3_ERROR_BAD_SAMPLE_RATE: return "SCE_MP3_ERROR_BAD_SAMPLE_RATE";
case SCE_MP3_ERROR_BAD_RESET_FRAME: return "SCE_MP3_ERROR_BAD_RESET_FRAME";
case SCE_MP3_ERROR_BAD_ADDR: return "SCE_MP3_ERROR_BAD_ADDR";
case SCE_MP3_ERROR_BAD_SIZE: return "SCE_MP3_ERROR_BAD_SIZE";
default:
return nullptr;
}
-4
View File
@@ -184,10 +184,6 @@ public:
template <class T>
T* Get(SceUID handle, u32 &outError) {
if (handle < handleOffset || handle >= handleOffset+maxCount || !occupied[handle-handleOffset]) {
// Tekken 6 spams 0x80020001 gets wrong with no ill effects, also on the real PSP
if (handle != 0 && (u32)handle != 0x80020001) {
WARN_LOG(Log::sceKernel, "Kernel: Bad %s handle %d (%08x)", T::GetStaticTypeName(), handle, handle);
}
outError = T::GetMissingErrorCode();
return nullptr;
} else {
+23 -12
View File
@@ -523,25 +523,30 @@ int sceKernelCancelMutex(SceUID uid, int count, u32 numWaitThreadsPtr)
// int sceKernelLockMutex(SceUID id, int count, int *timeout)
int sceKernelLockMutex(SceUID id, int count, u32 timeoutPtr)
{
// Tekken 6 hack: Let's avoid the unnecessary logspam. It does this on hardware too.
// This ID is always invalid.
if (id == 0x80020001 && timeoutPtr == 0) {
return hleNoLog(0);
}
u32 error;
PSPMutex *mutex = kernelObjects.Get<PSPMutex>(id, error);
if (__KernelLockMutex(mutex, count, error))
return hleLogDebug(Log::sceKernel, 0);
else if (error)
else if (error) {
return hleLogError(Log::sceKernel, error);
else
{
SceUID threadID = __KernelGetCurThread();
// May be in a tight loop timing out (where we don't remove from waitingThreads yet), don't want to add duplicates.
if (std::find(mutex->waitingThreads.begin(), mutex->waitingThreads.end(), threadID) == mutex->waitingThreads.end())
mutex->waitingThreads.push_back(threadID);
__KernelWaitMutex(mutex, timeoutPtr);
__KernelWaitCurThread(WAITTYPE_MUTEX, id, count, timeoutPtr, false, "mutex waited");
// Return value will be overwritten by wait.
return hleLogDebug(Log::sceKernel, 0);
}
SceUID threadID = __KernelGetCurThread();
// May be in a tight loop timing out (where we don't remove from waitingThreads yet), don't want to add duplicates.
if (std::find(mutex->waitingThreads.begin(), mutex->waitingThreads.end(), threadID) == mutex->waitingThreads.end())
mutex->waitingThreads.push_back(threadID);
__KernelWaitMutex(mutex, timeoutPtr);
__KernelWaitCurThread(WAITTYPE_MUTEX, id, count, timeoutPtr, false, "mutex waited");
// Return value will be overwritten by wait.
return hleLogDebug(Log::sceKernel, 0);
}
// int sceKernelLockMutexCB(SceUID id, int count, int *timeout)
@@ -598,6 +603,12 @@ int sceKernelTryLockMutex(SceUID id, int count) {
// int sceKernelUnlockMutex(SceUID id, int count)
int sceKernelUnlockMutex(SceUID id, int count)
{
// Tekken 6 hack: Let's avoid the unnecessary logspam. It does this on hardware too.
// This ID is always invalid.
if (id == 0x80020001) {
return hleNoLog(0);
}
u32 error;
PSPMutex *mutex = kernelObjects.Get<PSPMutex>(id, error);
+5 -2
View File
@@ -199,10 +199,13 @@ int sceKernelCancelSema(SceUID id, int newCount, u32 numWaitThreadsPtr)
}
int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32 optionPtr) {
if (!name)
if (!name) {
// This is strangely quite common! Some shared library must be doing this.
return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ERROR, "invalid name");
if (attr >= 0x200)
}
if (attr >= 0x200) {
return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ATTR, "invalid attr parameter %08x", attr);
}
PSPSemaphore *s = new PSPSemaphore();
SceUID id = kernelObjects.Create(s);
+56 -64
View File
@@ -83,14 +83,6 @@
#include "Common/Serialize/SerializeFuncs.h"
#include "Common/Serialize/SerializeMap.h"
static const u32 ERROR_MP3_INVALID_HANDLE = 0x80671001;
static const u32 ERROR_MP3_UNRESERVED_HANDLE = 0x80671102;
static const u32 ERROR_MP3_NOT_YET_INIT_HANDLE = 0x80671103;
static const u32 ERROR_MP3_NO_RESOURCE_AVAIL = 0x80671201;
static const u32 ERROR_MP3_BAD_SAMPLE_RATE = 0x80671302;
static const u32 ERROR_MP3_BAD_RESET_FRAME = 0x80671501;
static const u32 ERROR_MP3_BAD_ADDR = 0x80671002;
static const u32 ERROR_MP3_BAD_SIZE = 0x80671003;
static const int AU_BUF_MIN_SIZE = 8192;
static const int PCM_BUF_MIN_SIZE = 9216;
static const size_t MP3_MAX_HANDLES = 2;
@@ -215,10 +207,10 @@ static int sceMp3Decode(u32 mp3, u32 outPcmPtr) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "unreserved handle");
} else if (ctx->Version < 0 || ctx->AuBuf == 0) {
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "not yet init");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "not yet init");
}
int pcmBytes = ctx->AuDecode(outPcmPtr);
@@ -236,10 +228,10 @@ static int sceMp3ResetPlayPosition(u32 mp3) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "unreserved handle");
} else if (ctx->Version < 0 || ctx->AuBuf == 0) {
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "not yet init");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "not yet init");
}
return hleLogDebug(Log::ME, ctx->AuResetPlayPosition());
@@ -249,10 +241,10 @@ static int sceMp3CheckStreamDataNeeded(u32 mp3) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "unreserved handle");
} else if (ctx->AuBuf == 0) {
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "incorrect handle type");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "incorrect handle type");
}
return hleLogDebug(Log::ME, ctx->AuCheckStreamDataNeeded());
@@ -260,10 +252,10 @@ static int sceMp3CheckStreamDataNeeded(u32 mp3) {
static u32 sceMp3ReserveMp3Handle(u32 mp3Addr) {
if (!resourceInited) {
return hleLogError(Log::ME, ERROR_MP3_NO_RESOURCE_AVAIL, "sceMp3InitResource must be called first");
return hleLogError(Log::ME, SCE_MP3_ERROR_NO_RESOURCE_AVAIL, "sceMp3InitResource must be called first");
}
if (mp3Map.size() >= MP3_MAX_HANDLES) {
return hleLogError(Log::ME, ERROR_MP3_NO_RESOURCE_AVAIL, "no free handles");
return hleLogError(Log::ME, SCE_MP3_ERROR_NO_RESOURCE_AVAIL, "no free handles");
}
if (mp3Addr != 0 && !Memory::IsValidRange(mp3Addr, 32)) {
// The PSP would crash, but might as well return a proper error.
@@ -281,15 +273,15 @@ static u32 sceMp3ReserveMp3Handle(u32 mp3Addr) {
if (Au->startPos >= Au->endPos) {
delete Au;
return hleLogError(Log::ME, ERROR_MP3_BAD_SIZE, "start must be before end");
return hleLogError(Log::ME, SCE_MP3_ERROR_BAD_SIZE, "start must be before end");
}
if (!Au->AuBuf || !Au->PCMBuf) {
delete Au;
return hleLogError(Log::ME, ERROR_MP3_BAD_ADDR, "invalid buffer addresses");
return hleLogError(Log::ME, SCE_MP3_ERROR_BAD_ADDR, "invalid buffer addresses");
}
if ((int)Au->AuBufSize < AU_BUF_MIN_SIZE || (int)Au->PCMBufSize < PCM_BUF_MIN_SIZE) {
delete Au;
return hleLogError(Log::ME, ERROR_MP3_BAD_SIZE, "buffers too small");
return hleLogError(Log::ME, SCE_MP3_ERROR_BAD_SIZE, "buffers too small");
}
DEBUG_LOG(Log::ME, "startPos %llx endPos %llx mp3buf %08x mp3bufSize %08x PCMbuf %08x PCMbufSize %08x",
@@ -435,10 +427,10 @@ static int sceMp3Init(u32 mp3) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "unreserved handle");
} else if (ctx->AuBuf == 0) {
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "incorrect handle type");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "incorrect handle type");
}
static const int PARSE_DELAY_MS = 500;
@@ -486,7 +478,7 @@ static int sceMp3Init(u32 mp3) {
WARN_LOG_REPORT(Log::ME, "sceMp3Init: invalid data: not MPEG v1");
}
if (samplerate != 44100 && sdkver < 3090500) {
return hleDelayResult(hleLogError(Log::ME, ERROR_MP3_BAD_SAMPLE_RATE, "invalid data: not 44.1kHz"), "mp3 init", PARSE_DELAY_MS);
return hleDelayResult(hleLogError(Log::ME, SCE_MP3_ERROR_BAD_SAMPLE_RATE, "invalid data: not 44.1kHz"), "mp3 init", PARSE_DELAY_MS);
}
// Based on bitrate, we can calculate the frame size in bytes.
@@ -505,10 +497,10 @@ static int sceMp3GetLoopNum(u32 mp3) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "unreserved handle");
} else if (ctx->AuBuf == 0) {
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "incorrect handle type");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "incorrect handle type");
}
return hleLogDebug(Log::ME, ctx->LoopNum);
@@ -518,10 +510,10 @@ static int sceMp3GetMaxOutputSample(u32 mp3) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "unreserved handle");
} else if (ctx->Version < 0) {
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "not yet init");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "not yet init");
} else if (ctx->AuBuf == 0) {
return hleLogWarning(Log::ME, 0, "no channel available for low level");
}
@@ -533,10 +525,10 @@ static int sceMp3GetSumDecodedSample(u32 mp3) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "unreserved handle");
} else if (ctx->AuBuf == 0) {
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "incorrect handle type");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "incorrect handle type");
}
return hleLogDebug(Log::ME, ctx->SumDecodedSamples);
@@ -546,10 +538,10 @@ static int sceMp3SetLoopNum(u32 mp3, int loop) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "unreserved handle");
} else if (ctx->AuBuf == 0) {
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "incorrect handle type");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "incorrect handle type");
}
if (loop < 0)
@@ -563,10 +555,10 @@ static int sceMp3GetMp3ChannelNum(u32 mp3) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "unreserved handle");
} else if (ctx->Version < 0) {
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "not yet init");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "not yet init");
} else if (ctx->AuBuf == 0) {
return hleLogWarning(Log::ME, 0, "no channel available for low level");
}
@@ -578,10 +570,10 @@ static int sceMp3GetBitRate(u32 mp3) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "unreserved handle");
} else if (ctx->Version < 0) {
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "not yet init");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "not yet init");
} else if (ctx->AuBuf == 0) {
return hleLogWarning(Log::ME, 0, "no bitrate available for low level");
}
@@ -593,10 +585,10 @@ static int sceMp3GetSamplingRate(u32 mp3) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "unreserved handle");
} else if (ctx->Version < 0) {
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "not yet init");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "not yet init");
} else if (ctx->AuBuf == 0) {
return hleLogWarning(Log::ME, 0, "no sample rate available for low level");
}
@@ -608,10 +600,10 @@ static int sceMp3GetInfoToAddStreamData(u32 mp3, u32 dstPtr, u32 towritePtr, u32
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "unreserved handle");
} else if (ctx->AuBuf == 0) {
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "incorrect handle type");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "incorrect handle type");
}
return hleLogDebug(Log::ME, ctx->AuGetInfoToAddStreamData(dstPtr, towritePtr, srcposPtr));
@@ -621,10 +613,10 @@ static int sceMp3NotifyAddStreamData(u32 mp3, int size) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "unreserved handle");
} else if (ctx->AuBuf == 0) {
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "incorrect handle type");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "incorrect handle type");
}
return hleLogDebug(Log::ME, ctx->AuNotifyAddStreamData(size));
@@ -637,7 +629,7 @@ static int sceMp3ReleaseMp3Handle(u32 mp3) {
mp3Map.erase(mp3);
return hleLogDebug(Log::ME, 0);
} else if (mp3 >= MP3_MAX_HANDLES) {
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
}
// Intentionally a zero result.
@@ -658,10 +650,10 @@ static u32 sceMp3GetFrameNum(u32 mp3) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "unreserved handle");
} else if (ctx->Version < 0 || ctx->AuBuf == 0) {
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "not yet init");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "not yet init");
}
return hleLogDebug(Log::ME, ctx->FrameNum);
@@ -671,11 +663,11 @@ static u32 sceMp3GetMPEGVersion(u32 mp3) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "unreserved handle");
} else if (ctx->Version < 0) {
// Seems to be the wrong error code.
return hleLogError(Log::ME, ERROR_MP3_UNRESERVED_HANDLE, "not yet init");
return hleLogError(Log::ME, SCE_MP3_ERROR_UNRESERVED_HANDLE, "not yet init");
} else if (ctx->AuBuf == 0) {
return hleLogWarning(Log::ME, 0, "no MPEG version available for low level");
}
@@ -688,14 +680,14 @@ static u32 sceMp3ResetPlayPositionByFrame(u32 mp3, u32 frame) {
AuCtx *ctx = getMp3Ctx(mp3);
if (!ctx) {
if (mp3 >= MP3_MAX_HANDLES)
return hleLogError(Log::ME, ERROR_MP3_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "unreserved handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "unreserved handle");
} else if (ctx->Version < 0 || ctx->AuBuf == 0) {
return hleLogError(Log::ME, ERROR_MP3_NOT_YET_INIT_HANDLE, "not yet init");
return hleLogError(Log::ME, SCE_MP3_ERROR_NOT_YET_INIT_HANDLE, "not yet init");
}
if (frame >= (u32)ctx->FrameNum) {
return hleLogError(Log::ME, ERROR_MP3_BAD_RESET_FRAME, "bad frame position");
return hleLogError(Log::ME, SCE_MP3_ERROR_BAD_RESET_FRAME, "bad frame position");
}
return hleLogDebug(Log::ME, ctx->AuResetPlayPositionByFrame(frame));
+108 -207
View File
@@ -49,7 +49,6 @@ static const int MPEG_PCM_ES_OUTPUT_SIZE = 320;
// MPEG Userdata elementary stream.
static const int MPEG_DATA_ES_SIZE = 0xA0000;
static const int MPEG_DATA_ES_OUTPUT_SIZE = 0xA0000;
static const int MPEG_DATA_ES_BUFFERS = 2;
// MPEG analysis results.
static const int MPEG_VERSION_0012 = 0;
@@ -145,7 +144,8 @@ static int getMaxAheadTimestamp(const SceMpegRingBuffer &ringbuf) {
}
*/
const u8 defaultMpegheader[2048] = {0x50,0x53,0x4d,0x46,0x30,0x30,0x31,0x35,0x00,0x00,0x08,0x00,0x00,
const u8 defaultMpegheader[2048] = {
0x50,0x53,0x4d,0x46,0x30,0x30,0x31,0x35,0x00,0x00,0x08,0x00,0x00,
0x10,0xc8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@@ -154,109 +154,7 @@ const u8 defaultMpegheader[2048] = {0x50,0x53,0x4d,0x46,0x30,0x30,0x31,0x35,0x00
0x90,0x02,0x01,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x01,0x5f,0x90,0x00,0x00,0x00,0x0d,0xbe,
0xca,0x00,0x01,0x00,0x00,0x00,0x22,0x00,0x02,0xe0,0x00,0x20,0xfb,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1e,0x11,0x00,0x00,0xbd,0x00,0x20,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x02};
// Internal structure
struct AvcContext {
int avcDetailFrameWidth;
int avcDetailFrameHeight;
int avcDecodeResult;
int avcFrameStatus;
};
struct StreamInfo {
int type;
int num;
int sid;
bool needsReset;
};
typedef std::map<u32, StreamInfo> StreamInfoMap;
// Internal structure
struct MpegContext {
MpegContext() : ringbufferNeedsReverse(false), mediaengine(nullptr) {
memcpy(mpegheader, defaultMpegheader, 2048);
}
~MpegContext() {
delete mediaengine;
}
void DoState(PointerWrap &p) {
auto s = p.Section("MpegContext", 1, 3);
if (!s)
return;
if (s >= 3)
Do(p, mpegwarmUp);
else
mpegwarmUp = 1000;
DoArray(p, mpegheader, 2048);
Do(p, defaultFrameWidth);
Do(p, videoFrameCount);
Do(p, audioFrameCount);
Do(p, endOfAudioReached);
Do(p, endOfVideoReached);
Do(p, videoPixelMode);
Do(p, mpegMagic);
Do(p, mpegVersion);
Do(p, mpegRawVersion);
Do(p, mpegOffset);
Do(p, mpegStreamSize);
Do(p, mpegFirstTimestamp);
Do(p, mpegLastTimestamp);
Do(p, mpegFirstDate);
Do(p, mpegLastDate);
Do(p, mpegRingbufferAddr);
DoArray(p, esBuffers, MPEG_DATA_ES_BUFFERS);
Do(p, avc);
Do(p, avcRegistered);
Do(p, atracRegistered);
Do(p, pcmRegistered);
Do(p, dataRegistered);
Do(p, ignoreAtrac);
Do(p, ignorePcm);
Do(p, ignoreAvc);
Do(p, isAnalyzed);
Do<u32, StreamInfo>(p, streamMap);
DoClass(p, mediaengine);
ringbufferNeedsReverse = s < 2;
}
u8 mpegheader[2048];
u32 defaultFrameWidth;
int videoFrameCount;
int audioFrameCount;
bool endOfAudioReached;
bool endOfVideoReached;
int videoPixelMode;
u32 mpegMagic;
int mpegVersion;
u32 mpegRawVersion;
u32 mpegOffset;
u32 mpegStreamSize;
s64 mpegFirstTimestamp;
s64 mpegLastTimestamp;
u32 mpegFirstDate;
u32 mpegLastDate;
u32 mpegRingbufferAddr;
int mpegwarmUp;
bool esBuffers[MPEG_DATA_ES_BUFFERS];
AvcContext avc;
bool avcRegistered;
bool atracRegistered;
bool pcmRegistered;
bool dataRegistered;
bool ignoreAtrac;
bool ignorePcm;
bool ignoreAvc;
bool isAnalyzed;
bool ringbufferNeedsReverse;
StreamInfoMap streamMap;
MediaEngine *mediaengine;
0x00,0x00,0x00,0x02,0x02
};
static bool isMpegInit;
@@ -266,6 +164,52 @@ static u32 streamIdGen;
static int actionPostPut;
static std::map<u32, MpegContext *> mpegMap;
MpegContext::MpegContext() {
memcpy(mpegheader, defaultMpegheader, 2048);
}
MpegContext::~MpegContext() {
delete mediaengine;
}
void MpegContext::DoState(PointerWrap &p) {
auto s = p.Section("MpegContext", 1, 3);
if (!s)
return;
if (s >= 3)
Do(p, mpegwarmUp);
else
mpegwarmUp = 1000;
DoArray(p, mpegheader, 2048);
Do(p, defaultFrameWidth);
Do(p, videoFrameCount);
Do(p, audioFrameCount);
Do(p, endOfAudioReached);
Do(p, endOfVideoReached);
Do(p, videoPixelMode);
Do(p, mpegMagic);
Do(p, mpegVersion);
Do(p, mpegRawVersion);
Do(p, mpegOffset);
Do(p, mpegStreamSize);
Do(p, mpegFirstTimestamp);
Do(p, mpegLastTimestamp);
Do(p, mpegFirstDate);
Do(p, mpegLastDate);
Do(p, mpegRingbufferAddr);
DoArray(p, esBuffers, MPEG_DATA_ES_BUFFERS);
Do(p, avc);
Do(p, avcRegistered);
Do(p, atracRegistered);
Do(p, pcmRegistered);
Do(p, dataRegistered);
Do(p, ignoreAtrac);
Do(p, ignorePcm);
Do(p, ignoreAvc);
Do(p, isAnalyzed);
Do<u32, StreamInfo>(p, streamMap);
DoClass(p, mediaengine);
ringbufferNeedsReverse = s < 2;
}
static MpegContext *getMpegCtx(u32 mpegAddr) {
if (!Memory::IsValidAddress(mpegAddr))
return nullptr;
@@ -369,7 +313,7 @@ public:
}
void run(MipsCall &call) override;
private:
u32 ringAddr_;
u32 ringAddr_ = 0;
};
void __MpegInit() {
@@ -1748,14 +1692,12 @@ static u32 sceMpegChangeGetAuMode(u32 mpeg, int streamUid, int mode)
return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "bad mpeg handle");
}
if (mode != MPEG_AU_MODE_DECODE && mode != MPEG_AU_MODE_SKIP) {
ERROR_LOG(Log::ME, "UNIMPL sceMpegChangeGetAuMode(%08x, %i, %i): bad mode", mpeg, streamUid, mode);
return SCE_MPEG_ERROR_INVALID_VALUE;
return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "UNIMPL / bad mode");
}
auto stream = ctx->streamMap.find(streamUid);
if (stream == ctx->streamMap.end()) {
ERROR_LOG(Log::ME, "UNIMPL sceMpegChangeGetAuMode(%08x, %i, %i): unknown streamID", mpeg, streamUid, mode);
return SCE_MPEG_ERROR_INVALID_VALUE;
return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "UNIMPL / unknown streamID");
} else {
StreamInfo &info = stream->second;
DEBUG_LOG(Log::ME, "UNIMPL sceMpegChangeGetAuMode(%08x, %i, %i): changing type=%d", mpeg, streamUid, mode, info.type);
@@ -1787,7 +1729,7 @@ static u32 sceMpegChangeGetAuMode(u32 mpeg, int streamUid, int mode)
break;
}
}
return 0;
return hleNoLog(0);
}
static u32 sceMpegChangeGetAvcAuMode(u32 mpeg, u32 stream_addr, int mode) {
@@ -1808,35 +1750,32 @@ static u32 sceMpegGetPcmAu(u32 mpeg, int streamUid, u32 auAddr, u32 attrAddr)
{
MpegContext *ctx = getMpegCtx(mpeg);
if (!ctx) {
WARN_LOG(Log::ME, "UNIMPL sceMpegGetPcmAu(%08x, %i, %08x, %08x): bad mpeg handle", mpeg, streamUid, auAddr, attrAddr);
return -1;
return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle");
}
auto ringbuffer = PSPPointer<SceMpegRingBuffer>::Create(ctx->mpegRingbufferAddr);
if (!ringbuffer.IsValid()) {
// Would have crashed before, TODO test behavior
WARN_LOG(Log::ME, "sceMpegGetPcmAu(%08x, %08x, %08x, %08x): invalid ringbuffer address", mpeg, streamUid, auAddr, attrAddr);
return -1;
return hleLogWarning(Log::ME, -1, "invalid ringbuffer address");
}
if (!Memory::IsValidAddress(streamUid)) {
WARN_LOG(Log::ME, "sceMpegGetPcmAu(%08x, %08x, %08x, %08x): didn't get a fake stream", mpeg, streamUid, auAddr, attrAddr);
return SCE_MPEG_ERROR_INVALID_ADDR;
return hleLogWarning(Log::ME, SCE_MPEG_ERROR_INVALID_ADDR, "didn't get a fake stream, bad streamUid address");
}
SceMpegAu atracAu;
atracAu.read(auAddr);
auto streamInfo = ctx->streamMap.find(streamUid);
if (streamInfo == ctx->streamMap.end()) {
WARN_LOG(Log::ME, "sceMpegGetPcmAu(%08x, %08x, %08x, %08x): bad streamUid ", mpeg, streamUid, auAddr, attrAddr);
return -1;
return hleLogWarning(Log::ME, -1, "bad streamUid ");
}
atracAu.write(auAddr);
u32 attr = 1 << 7; // Sampling rate (1 = 44.1kHz).
attr |= 2; // Number of channels (1 - MONO / 2 - STEREO).
if (Memory::IsValidAddress(attrAddr))
Memory::Write_U32(attr, attrAddr);
Memory::WriteUnchecked_U32(attr, attrAddr);
ERROR_LOG_REPORT_ONCE(mpegPcmAu, Log::ME, "UNIMPL sceMpegGetPcmAu(%08x, %i, %08x, %08x)", mpeg, streamUid, auAddr, attrAddr);
return 0;
return hleNoLog(0);
}
static int __MpegRingbufferQueryPackNum(u32 memorySize) {
@@ -1848,8 +1787,7 @@ static int sceMpegRingbufferQueryPackNum(u32 memorySize) {
return __MpegRingbufferQueryPackNum(memorySize);
}
static u32 sceMpegFlushAllStream(u32 mpeg)
{
static u32 sceMpegFlushAllStream(u32 mpeg) {
MpegContext *ctx = getMpegCtx(mpeg);
if (!ctx) {
return hleLogWarning(Log::ME, -1, "UNIMPL + bad mpeg handle");
@@ -1867,40 +1805,33 @@ static u32 sceMpegFlushAllStream(u32 mpeg)
return hleLogWarning(Log::ME, 0, "UNIMPL");
}
static u32 sceMpegFlushStream(u32 mpeg, int stream_addr)
{
static u32 sceMpegFlushStream(u32 mpeg, int stream_addr) {
if (!Memory::IsValidAddress(stream_addr)) {
ERROR_LOG(Log::ME, "UNIMPL sceMpegFlushStream(%08x, %i): invalid addresses", mpeg , stream_addr);
return -1;
return hleLogError(Log::ME, -1, "UNIMPL / invalid addresses");
}
MpegContext *ctx = getMpegCtx(mpeg);
if (!ctx) {
WARN_LOG(Log::ME, "UNIMPL sceMpegFlushStream(%08x, %i): bad mpeg handle", mpeg , stream_addr);
return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle");
return -1;
}
ERROR_LOG(Log::ME, "UNIMPL sceMpegFlushStream(%08x, %i)", mpeg , stream_addr);
//__MpegFinish();
return 0;
return hleLogError(Log::ME, 0, "UNIMPL");
}
static u32 sceMpegAvcCopyYCbCr(u32 mpeg, u32 sourceAddr, u32 YCbCrAddr)
{
static u32 sceMpegAvcCopyYCbCr(u32 mpeg, u32 sourceAddr, u32 YCbCrAddr) {
if (!Memory::IsValidAddress(sourceAddr) || !Memory::IsValidAddress(YCbCrAddr)) {
ERROR_LOG(Log::ME, "UNIMPL sceMpegAvcCopyYCbCr(%08x, %08x, %08x): invalid addresses", mpeg, sourceAddr, YCbCrAddr);
return -1;
return hleLogError(Log::ME, -1, "UNIMPL / invalid address(es)");
}
MpegContext *ctx = getMpegCtx(mpeg);
if (!ctx) {
ERROR_LOG(Log::ME, "UNIMPL sceMpegAvcCopyYCbCr(%08x, %08x, %08x): bad mpeg handle", mpeg, sourceAddr, YCbCrAddr);
return -1;
return hleLogError(Log::ME, -1, "UNIMPL / bad mpeg handle");
}
// This is very common.
DEBUG_LOG(Log::ME, "UNIMPL sceMpegAvcCopyYCbCr(%08x, %08x, %08x)", mpeg, sourceAddr, YCbCrAddr);
return 0;
return hleLogDebug(Log::ME, 0, "UNIMPL");
}
static u32 sceMpegAtracDecode(u32 mpeg, u32 auAddr, u32 bufferAddr, int init)
@@ -1996,15 +1927,14 @@ static u32 sceMpegAvcInitYCbCr(u32 mpeg, int mode, int width, int height, u32 yc
static int sceMpegAvcQueryYCbCrSize(u32 mpeg, u32 mode, u32 width, u32 height, u32 resultAddr)
{
if ((width & 15) != 0 || (height & 15) != 0 || height > 272 || width > 480) {
ERROR_LOG(Log::ME, "sceMpegAvcQueryYCbCrSize: bad w/h %i x %i", width, height);
return SCE_MPEG_ERROR_INVALID_VALUE;
return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "sceMpegAvcQueryYCbCrSize: bad w/h %i x %i", width, height);
}
DEBUG_LOG(Log::ME, "sceMpegAvcQueryYCbCrSize(%08x, %i, %i, %i, %08x)", mpeg, mode, width, height, resultAddr);
int size = (width / 2) * (height / 2) * 6 + 128;
Memory::Write_U32(size, resultAddr);
return hleNoLog(0);
if (Memory::IsValidAddress(resultAddr)) {
Memory::WriteUnchecked_U32(size, resultAddr);
}
return hleLogDebug(Log::ME, 0);
}
static u32 sceMpegQueryUserdataEsSize(u32 mpeg, u32 esSizeAddr, u32 outSizeAddr)
@@ -2020,40 +1950,33 @@ static u32 sceMpegQueryUserdataEsSize(u32 mpeg, u32 esSizeAddr, u32 outSizeAddr)
return -1;
}
DEBUG_LOG(Log::ME, "sceMpegQueryUserdataEsSize(%08x, %08x, %08x)", mpeg, esSizeAddr, outSizeAddr);
// Checked above.
Memory::WriteUnchecked_U32(MPEG_DATA_ES_SIZE, esSizeAddr);
Memory::WriteUnchecked_U32(MPEG_DATA_ES_OUTPUT_SIZE, outSizeAddr);
Memory::Write_U32(MPEG_DATA_ES_SIZE, esSizeAddr);
Memory::Write_U32(MPEG_DATA_ES_OUTPUT_SIZE, outSizeAddr);
return 0;
return hleLogDebug(Log::ME, 0);
}
static u32 sceMpegAvcResourceGetAvcDecTopAddr(u32 mpeg)
{
ERROR_LOG(Log::ME, "UNIMPL sceMpegAvcResourceGetAvcDecTopAddr(%08x)", mpeg);
static u32 sceMpegAvcResourceGetAvcDecTopAddr(u32 mpeg) {
// it's just a random address
return 0x12345678;
return hleLogError(Log::ME, 0x12345678, "UNIMPL");
}
static u32 sceMpegAvcResourceFinish(u32 mpeg)
{
DEBUG_LOG(Log::ME,"UNIMPL sceMpegAvcResourceFinish(%08x)", mpeg);
return 0;
static u32 sceMpegAvcResourceFinish(u32 mpeg) {
return hleLogInfo(Log::ME, 0, "UNIMPL");
}
static u32 sceMpegAvcResourceGetAvcEsBuf(u32 mpeg)
{
static u32 sceMpegAvcResourceGetAvcEsBuf(u32 mpeg) {
ERROR_LOG_REPORT_ONCE(mpegResourceEsBuf, Log::ME, "UNIMPL sceMpegAvcResourceGetAvcEsBuf(%08x)", mpeg);
return 0;
return hleNoLog(0);
}
static u32 sceMpegAvcResourceInit(u32 mpeg)
{
static u32 sceMpegAvcResourceInit(u32 mpeg) {
if (mpeg != 1) {
return SCE_MPEG_ERROR_INVALID_VALUE;
return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE);
}
ERROR_LOG(Log::ME, "UNIMPL sceMpegAvcResourceInit(%08x)", mpeg);
return 0;
return hleLogError(Log::ME, 0, "UNIMPL");
}
// TODO: SIMD this (or rather, the caller).
@@ -2143,105 +2066,84 @@ static int sceMpegAvcConvertToYuv420(u32 mpeg, u32 bufferOutputAddr, u32 bufferA
return hleLogDebug(Log::ME, (width << 16) | height);
}
static int sceMpegGetUserdataAu(u32 mpeg, u32 streamUid, u32 auAddr, u32 resultAddr)
{
static int sceMpegGetUserdataAu(u32 mpeg, u32 streamUid, u32 auAddr, u32 resultAddr) {
MpegContext *ctx = getMpegCtx(mpeg);
if (!ctx) {
WARN_LOG(Log::ME, "sceMpegGetUserdataAu(%08x, %08x, %08x, %08x): bad mpeg handle", mpeg, streamUid, auAddr, resultAddr);
return -1;
return hleLogWarning(Log::ME, -1, "bad mpeg handle", mpeg);
}
DEBUG_LOG(Log::ME, "sceMpegGetUserdataAu(%08x, %08x, %08x, %08x)", mpeg, streamUid, auAddr, resultAddr);
// TODO: Are these at all right? Seen in Phantasy Star Portable 2.
Memory::Write_U32(0, resultAddr);
Memory::Write_U32(0, resultAddr + 4);
if (Memory::IsValidRange(resultAddr, 8)) {
// TODO: Are these at all right? Seen in Phantasy Star Portable 2.
Memory::WriteUnchecked_U32(0, resultAddr);
Memory::WriteUnchecked_U32(0, resultAddr + 4);
}
// We currently can't demux userdata so this seems like the best thing to return in the meantime..
// Then we probably shouldn't do the above writes? but it works...
return SCE_MPEG_ERROR_NO_DATA;
return hleLogDebug(Log::ME, SCE_MPEG_ERROR_NO_DATA);
}
static u32 sceMpegNextAvcRpAu(u32 mpeg, u32 streamUid)
{
static u32 sceMpegNextAvcRpAu(u32 mpeg, u32 streamUid) {
MpegContext *ctx = getMpegCtx(mpeg);
if (!ctx) {
WARN_LOG(Log::ME, "UNIMPL sceMpegNextAvcRpAu(%08x, %08x): bad mpeg handle", mpeg, streamUid);
return -1;
return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle", mpeg);
}
ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegNextAvcRpAu(%08x, %08x)", mpeg, streamUid);
return 0;
}
static u32 sceMpegGetAvcNalAu(u32 mpeg)
{
static u32 sceMpegGetAvcNalAu(u32 mpeg) {
MpegContext *ctx = getMpegCtx(mpeg);
if (!ctx) {
WARN_LOG(Log::ME, "UNIMPL sceMpegGetAvcNalAu(%08x): bad mpeg handle", mpeg);
return -1;
return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle", mpeg);
}
ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegGetAvcNalAu(%08x)", mpeg);
return 0;
}
static u32 sceMpegAvcDecodeDetailIndex(u32 mpeg)
{
static u32 sceMpegAvcDecodeDetailIndex(u32 mpeg) {
MpegContext *ctx = getMpegCtx(mpeg);
if (!ctx) {
WARN_LOG(Log::ME, "UNIMPL sceMpegAvcDecodeDetailIndex(%08x): bad mpeg handle", mpeg);
return -1;
return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle", mpeg);
}
ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegAvcDecodeDetailIndex(%08x)", mpeg);
return 0;
}
static u32 sceMpegAvcDecodeDetail2(u32 mpeg)
{
static u32 sceMpegAvcDecodeDetail2(u32 mpeg) {
MpegContext *ctx = getMpegCtx(mpeg);
if (!ctx) {
WARN_LOG(Log::ME, "UNIMPL sceMpegAvcDecodeDetail2(%08x): bad mpeg handle", mpeg);
return -1;
return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle", mpeg);
}
ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegAvcDecodeDetail2(%08x)", mpeg);
return 0;
}
static u32 sceMpegGetAvcEsAu(u32 mpeg)
{
static u32 sceMpegGetAvcEsAu(u32 mpeg) {
MpegContext *ctx = getMpegCtx(mpeg);
if (!ctx) {
WARN_LOG(Log::ME, "UNIMPL sceMpegGetAvcEsAu(%08x): bad mpeg handle", mpeg);
return -1;
return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle", mpeg);
}
ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegGetAvcEsAu(%08x)", mpeg);
return 0;
}
static u32 sceMpegAvcCscInfo(u32 mpeg)
{
static u32 sceMpegAvcCscInfo(u32 mpeg) {
MpegContext *ctx = getMpegCtx(mpeg);
if (!ctx) {
WARN_LOG(Log::ME, "UNIMPL sceMpegAvcCscInfo(%08x): bad mpeg handle", mpeg);
return -1;
return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle", mpeg);
}
ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegAvcCscInfo(%08x)", mpeg);
return 0;
}
static u32 sceMpegAvcCscMode(u32 mpeg)
{
static u32 sceMpegAvcCscMode(u32 mpeg) {
MpegContext *ctx = getMpegCtx(mpeg);
if (!ctx) {
WARN_LOG(Log::ME, "UNIMPL sceMpegAvcCscMode(%08x): bad mpeg handle", mpeg);
@@ -2249,7 +2151,6 @@ static u32 sceMpegAvcCscMode(u32 mpeg)
}
ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegAvcCscMode(%08x)", mpeg);
return 0;
}
+65
View File
@@ -17,6 +17,8 @@
#pragma once
#include <map>
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
@@ -62,6 +64,69 @@ struct SceMpegRingBuffer {
u32_le gp;
};
// Internal structure
struct AvcContext {
int avcDetailFrameWidth;
int avcDetailFrameHeight;
int avcDecodeResult;
int avcFrameStatus;
};
struct StreamInfo {
int type;
int num;
int sid;
bool needsReset;
};
static const int MPEG_DATA_ES_BUFFERS = 2;
typedef std::map<u32, StreamInfo> StreamInfoMap;
class MediaEngine;
// Internal structure
struct MpegContext {
MpegContext();
~MpegContext();
void DoState(PointerWrap &p);
u8 mpegheader[2048];
u32 defaultFrameWidth;
int videoFrameCount;
int audioFrameCount;
bool endOfAudioReached;
bool endOfVideoReached;
int videoPixelMode;
u32 mpegMagic;
int mpegVersion;
u32 mpegRawVersion;
u32 mpegOffset;
u32 mpegStreamSize;
s64 mpegFirstTimestamp;
s64 mpegLastTimestamp;
u32 mpegFirstDate;
u32 mpegLastDate;
u32 mpegRingbufferAddr;
int mpegwarmUp;
bool esBuffers[MPEG_DATA_ES_BUFFERS];
AvcContext avc;
bool avcRegistered;
bool atracRegistered;
bool pcmRegistered;
bool dataRegistered;
bool ignoreAtrac;
bool ignorePcm;
bool ignoreAvc;
bool isAnalyzed = false;
bool ringbufferNeedsReverse = false;
StreamInfoMap streamMap;
MediaEngine *mediaengine = nullptr;
};
void __MpegInit();
void __MpegDoState(PointerWrap &p);
void __MpegShutdown();
+40 -40
View File
@@ -514,13 +514,13 @@ static const KeyValue *LookupCategory(std::string_view path, int *count) {
found = true;
break;
} else {
ERROR_LOG(Log::System, "Not a dir");
ERROR_LOG(Log::sceReg, "Not a dir");
return nullptr;
}
}
}
if (!found) {
WARN_LOG(Log::System, "Path not found: %.*s", (int)path.size(), path.data());
WARN_LOG(Log::sceReg, "Path not found: %.*s", (int)path.size(), path.data());
return nullptr;
}
}
@@ -544,28 +544,28 @@ int sceRegOpenRegistry(u32 regParamAddr, int mode, u32 regHandleAddr) {
Memory::WriteUnchecked_U32(0, regHandleAddr);
}
g_openRegistryMode = mode;
return hleLogInfo(Log::System, 0);
return hleLogInfo(Log::sceReg, 0);
}
int sceRegCloseRegistry(int regHandle) {
if (regHandle != 0) {
return hleLogError(Log::System, SCE_REG_ERROR_REGISTRY_NOT_FOUND);
return hleLogError(Log::sceReg, SCE_REG_ERROR_REGISTRY_NOT_FOUND);
}
g_openCategories.clear();
return hleLogInfo(Log::System, 0);
return hleLogInfo(Log::sceReg, 0);
}
int sceRegFlushRegistry(int regHandle) {
if (regHandle != 0) {
return hleLogError(Log::System, SCE_REG_ERROR_REGISTRY_NOT_FOUND);
return hleLogError(Log::sceReg, SCE_REG_ERROR_REGISTRY_NOT_FOUND);
}
// For us this is a no-op.
return hleLogInfo(Log::System, 0);
return hleLogInfo(Log::sceReg, 0);
}
// Seems dangerous! Have not dared to test this on hardware.
int sceRegRemoveRegistry(u32 regParamAddr) {
return hleLogError(Log::System, 0, "UNIMPL");
return hleLogError(Log::sceReg, 0, "UNIMPL");
}
int sceRegOpenCategory(int regHandle, const char *name, int mode, u32 regHandleAddr) {
@@ -573,54 +573,54 @@ int sceRegOpenCategory(int regHandle, const char *name, int mode, u32 regHandleA
return -1;
}
if (!name) {
return hleLogError(Log::System, SCE_REG_ERROR_INVALID_NAME);
return hleLogError(Log::sceReg, SCE_REG_ERROR_INVALID_NAME);
}
if (regHandle != 0) {
Memory::WriteUnchecked_U32(-1, regHandleAddr);
return hleLogError(Log::System, SCE_REG_ERROR_REGISTRY_NOT_FOUND, "Invalid registry");
return hleLogError(Log::sceReg, SCE_REG_ERROR_REGISTRY_NOT_FOUND, "Invalid registry");
}
if (equals(name, "") || equals(name, "/")) {
return hleLogError(Log::System, SCE_REG_ERROR_INVALID_PATH);
return hleLogError(Log::sceReg, SCE_REG_ERROR_INVALID_PATH);
}
int count = 0;
const KeyValue *keyvals = LookupCategory(name, &count);
if (!keyvals) {
Memory::WriteUnchecked_U32(-1, regHandleAddr);
return hleLogError(Log::System, SCE_REG_ERROR_CATEGORY_NOT_FOUND);
return hleLogError(Log::sceReg, SCE_REG_ERROR_CATEGORY_NOT_FOUND);
}
// Let's see if this category is marked as inaccessible (presumably from user mode)..
if (count == 1 && keyvals[0].type == ValueType::FAIL) {
const int errorCode = keyvals[0].intValue;
return hleLogWarning(Log::System, errorCode, "Inaccessible category");
return hleLogWarning(Log::sceReg, errorCode, "Inaccessible category");
}
int handle = g_handleGen++;
OpenCategory cat{ name, mode };
g_openCategories[handle] = cat;
Memory::WriteUnchecked_U32(handle, regHandleAddr);
return hleLogInfo(Log::System, 0, "open handle: %d", handle);
return hleLogInfo(Log::sceReg, 0, "open handle: %d", handle);
}
int sceRegCloseCategory(int regHandle) {
auto iter = g_openCategories.find(regHandle);
if (iter == g_openCategories.end()) {
// Not found
return hleLogError(Log::System, 0, "Not an open category");
return hleLogError(Log::sceReg, 0, "Not an open category");
}
g_openCategories.erase(iter);
return hleLogInfo(Log::System, 0);
return hleLogInfo(Log::sceReg, 0);
}
int sceRegRemoveCategory(int regHandle, const char *name) {
return hleLogError(Log::System, 0, "UNIMPL");
return hleLogError(Log::sceReg, 0, "UNIMPL");
}
int sceRegFlushCategory(int regHandle) {
return hleLogError(Log::System, 0, "UNIMPL");
return hleLogError(Log::sceReg, 0, "UNIMPL");
}
// Key level
@@ -628,7 +628,7 @@ int sceRegFlushCategory(int regHandle) {
int sceRegGetKeysNum(int catHandle, u32 numAddr) {
auto iter = g_openCategories.find(catHandle);
if (iter == g_openCategories.end()) {
return hleLogError(Log::System, 0, "Not an open category");
return hleLogError(Log::sceReg, 0, "Not an open category");
}
if (!Memory::IsValid4AlignedAddress(numAddr)) {
@@ -639,21 +639,21 @@ int sceRegGetKeysNum(int catHandle, u32 numAddr) {
const KeyValue *keyvals = LookupCategory(iter->second.path, &count);
if (!keyvals) {
Memory::WriteUnchecked_U32(-1, numAddr);
return hleLogWarning(Log::System, SCE_REG_ERROR_CATEGORY_NOT_FOUND);
return hleLogWarning(Log::sceReg, SCE_REG_ERROR_CATEGORY_NOT_FOUND);
}
Memory::WriteUnchecked_U32(count, numAddr);
return hleLogInfo(Log::System, 0);
return hleLogInfo(Log::sceReg, 0);
}
int sceRegGetKeys(int catHandle, u32 bufAddr, int num) {
auto iter = g_openCategories.find(catHandle);
if (iter == g_openCategories.end()) {
return hleLogError(Log::System, 0, "Not an open category");
return hleLogError(Log::sceReg, 0, "Not an open category");
}
if (!Memory::IsValidRange(bufAddr, num * 27)) {
return hleLogError(Log::System, -1, "bad output addr");
return hleLogError(Log::sceReg, -1, "bad output addr");
}
const int addrLen = 27; // for some reason
@@ -661,7 +661,7 @@ int sceRegGetKeys(int catHandle, u32 bufAddr, int num) {
int count = 0;
const KeyValue *keyvals = LookupCategory(iter->second.path, &count);
if (!keyvals) {
return hleLogWarning(Log::System, SCE_REG_ERROR_CATEGORY_NOT_FOUND);
return hleLogWarning(Log::sceReg, SCE_REG_ERROR_CATEGORY_NOT_FOUND);
}
count = std::min(count, num);
@@ -671,19 +671,19 @@ int sceRegGetKeys(int catHandle, u32 bufAddr, int num) {
strncpy(dest, keyvals[i].name.c_str(), 27);
}
return hleLogInfo(Log::System, 0);
return hleLogInfo(Log::sceReg, 0);
}
int sceRegGetKeyInfo(int catHandle, const char *name, u32 outKeyHandleAddr, u32 outTypeAddr, u32 outSizeAddr) {
auto iter = g_openCategories.find(catHandle);
if (iter == g_openCategories.end()) {
return hleLogError(Log::System, 0, "Not found");
return hleLogError(Log::sceReg, 0, "Not found");
}
int count = 0;
const KeyValue *keyvals = LookupCategory(iter->second.path, &count);
if (!keyvals) {
return hleLogWarning(Log::System, SCE_REG_ERROR_CATEGORY_NOT_FOUND);
return hleLogWarning(Log::sceReg, SCE_REG_ERROR_CATEGORY_NOT_FOUND);
}
for (int i = 0; i < count; i++) {
@@ -709,15 +709,15 @@ int sceRegGetKeyInfo(int catHandle, const char *name, u32 outKeyHandleAddr, u32
// Let's just make the index the key handle.
Memory::WriteUnchecked_U32(size, outSizeAddr);
}
return hleLogInfo(Log::System, 0, "handle: %d type: %d size: %d", i, (int)keyvals[i].type, size);
return hleLogInfo(Log::sceReg, 0, "handle: %d type: %d size: %d", i, (int)keyvals[i].type, size);
}
}
return hleLogWarning(Log::System, -1, "key with name '%s' not found", name);
return hleLogWarning(Log::sceReg, -1, "key with name '%s' not found", name);
}
int sceRegGetKeyInfoByName(int catHandle, const char *name, u32 typeAddr, u32 sizeAddr) {
return hleLogError(Log::System, 0);
return hleLogError(Log::sceReg, 0);
}
int sceRegGetKeyValue(int catHandle, int keyHandle, u32 bufAddr, u32 size) {
@@ -727,48 +727,48 @@ int sceRegGetKeyValue(int catHandle, int keyHandle, u32 bufAddr, u32 size) {
auto iter = g_openCategories.find(catHandle);
if (iter == g_openCategories.end()) {
return hleLogError(Log::System, 0, "Not found");
return hleLogError(Log::sceReg, 0, "Not found");
}
int count = 0;
const KeyValue *keyvals = LookupCategory(iter->second.path, &count);
if (!keyvals) {
return hleLogWarning(Log::System, SCE_REG_ERROR_CATEGORY_NOT_FOUND);
return hleLogWarning(Log::sceReg, SCE_REG_ERROR_CATEGORY_NOT_FOUND);
}
if (keyHandle < 0 || keyHandle >= count) {
return hleLogWarning(Log::System, SCE_REG_ERROR_CATEGORY_NOT_FOUND);
return hleLogWarning(Log::sceReg, SCE_REG_ERROR_CATEGORY_NOT_FOUND);
}
const KeyValue &keyval = keyvals[keyHandle];
switch (keyval.type) {
case ValueType::BIN:
Memory::MemcpyUnchecked(bufAddr, keyval.strValue.data(), std::min(size, (u32)keyval.strValue.size()));
return hleLogInfo(Log::System, 0);
return hleLogInfo(Log::sceReg, 0);
case ValueType::STR:
Memory::MemcpyUnchecked(bufAddr, keyval.strValue.data(), std::min(size, (u32)keyval.strValue.size() + 1));
return hleLogInfo(Log::System, 0, "value: '%s'", keyval.strValue.data());
return hleLogInfo(Log::sceReg, 0, "value: '%s'", keyval.strValue.data());
case ValueType::INT:
Memory::WriteUnchecked_U32(keyval.intValue, bufAddr);
return hleLogInfo(Log::System, 0, "value: %d (0x%08x)", keyval.intValue, keyval.intValue);
return hleLogInfo(Log::sceReg, 0, "value: %d (0x%08x)", keyval.intValue, keyval.intValue);
case ValueType::DIR:
case ValueType::FAIL:
default:
// Return an error?
return hleLogWarning(Log::System, 0, "Unexpected type for sceRegGetKeyValue");
return hleLogWarning(Log::sceReg, 0, "Unexpected type for sceRegGetKeyValue");
}
}
int sceRegGetKeyValueByName(int catHandle, const char *name, u32 bufAddr, u32 size) {
return hleLogError(Log::System, 0);
return hleLogError(Log::sceReg, 0);
}
int sceRegSetKeyValue(int catHandle, const char *name, u32 bufAddr, u32 size) {
return hleLogError(Log::System, 0);
return hleLogError(Log::sceReg, 0);
}
int sceRegCreateKey(int catHandle, const char *name, int type, u32 size) {
return hleLogError(Log::System, 0);
return hleLogError(Log::sceReg, 0);
}
const HLEFunction sceReg[] = {
+2 -1
View File
@@ -2004,7 +2004,8 @@ void DeveloperToolsScreen::CreateViews() {
if (!(flag & AlwaysDisableHLEFlags())) {
const HLEModuleMeta *meta = GetHLEModuleMetaByFlag(flag);
if (meta) {
list->Add(new BitCheckBox(&g_Config.iDisableHLE, (int)flag, meta->modname));
BitCheckBox *checkBox = list->Add(new BitCheckBox(&g_Config.iDisableHLE, (int)flag, meta->modname));
checkBox->SetEnabled(!PSP_IsInited());
}
}
}
+2 -2
View File
@@ -1910,10 +1910,10 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu
// More to come here...
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Audio")) {
if (ImGui::BeginMenu("Audio/Video")) {
ImGui::MenuItem("SasAudio mixer", nullptr, &cfg_.sasAudioOpen);
ImGui::MenuItem("Raw audio channels", nullptr, &cfg_.audioChannelsOpen);
ImGui::MenuItem("Decoder contexts", nullptr, &cfg_.audioDecodersOpen);
ImGui::MenuItem("AV Decoder contexts", nullptr, &cfg_.audioDecodersOpen);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Network")) {