From 4ae2108629fa4e9f9f32768a0eea8b2d453d728a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 21 Apr 2019 19:54:34 -0700 Subject: [PATCH] Mp3: Fail to reserve if resource not inited. Also, add a required parameter for sceMp3LowLevelInit, since it fails unless proper values are passed for this on a PSP. --- Core/HLE/sceMp3.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceMp3.cpp b/Core/HLE/sceMp3.cpp index 72dd408b44..36187b1500 100644 --- a/Core/HLE/sceMp3.cpp +++ b/Core/HLE/sceMp3.cpp @@ -27,6 +27,7 @@ #include "Core/Reporting.h" #include "Core/HW/SimpleAudioDec.h" +static const u32 ERROR_MP3_RESOURCE_NOT_INIT = 0x80671201; struct Mp3Context { public: @@ -186,6 +187,10 @@ static int sceMp3CheckStreamDataNeeded(u32 mp3) { } static u32 sceMp3ReserveMp3Handle(u32 mp3Addr) { + if (!resourceInited) { + return hleLogError(ME, ERROR_MP3_RESOURCE_NOT_INIT, "sceMp3InitResource must be called first"); + } + INFO_LOG(ME, "sceMp3ReserveMp3Handle(%08x)", mp3Addr); if (!Memory::IsValidAddress(mp3Addr)){ ERROR_LOG(ME, "sceMp3ReserveMp3Handle(%08x) invalid address %08x", mp3Addr, mp3Addr); @@ -526,8 +531,8 @@ static u32 sceMp3ResetPlayPositionByFrame(u32 mp3, int position) { return ctx->AuResetPlayPositionByFrame(position); } -static u32 sceMp3LowLevelInit(u32 mp3) { - INFO_LOG(ME, "sceMp3LowLevelInit(%i)", mp3); +static u32 sceMp3LowLevelInit(u32 mp3, u32 unk) { + INFO_LOG(ME, "sceMp3LowLevelInit(%i, %i)", mp3, unk); auto ctx = new AuCtx; ctx->audioType = PSP_CODEC_MP3; @@ -597,7 +602,7 @@ const HLEFunction sceMp3[] = { {0XAE6D2027, &WrapU_U, "sceMp3GetMPEGVersion", 'x', "x" }, {0X3548AEC8, &WrapU_U, "sceMp3GetFrameNum", 'x', "x" }, {0X0840E808, &WrapU_UI, "sceMp3ResetPlayPositionByFrame", 'x', "xi" }, - {0X1B839B83, &WrapU_U, "sceMp3LowLevelInit", 'x', "x" }, + {0X1B839B83, &WrapU_UU, "sceMp3LowLevelInit", 'x', "xx" }, {0XE3EE2C81, &WrapU_UUUUU, "sceMp3LowLevelDecode", 'x', "xxxxx"} };