diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index 8bee52f1f2..c6b4327086 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -3385,8 +3385,10 @@ void __KernelReturnFromMipsCall() currentMIPS->r[MIPS_REG_V1] = call->savedV1; cur->currentMipscallId = call->savedId; - if (call->cbId != 0) + // IF the thread called ExitDelete, we might've alreayd decreased g_inCbCount. + if (call->cbId != 0 && g_inCbCount > 0) { g_inCbCount--; + } currentCallbackThreadID = 0; if (cur->nt.waitType != WAITTYPE_NONE) diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index f2e9214492..7945b62c7b 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -1408,10 +1408,9 @@ void PostPutAction::run(MipsCall &call) { // Program signals that it has written data to the ringbuffer and gets a callback ? u32 sceMpegRingbufferPut(u32 ringbufferAddr, u32 numPackets, u32 available) { - DEBUG_LOG(ME, "sceMpegRingbufferPut(%08x, %i, %i)", ringbufferAddr, numPackets, available); - numPackets = std::min(numPackets, available); if (numPackets <= 0) { + DEBUG_LOG(ME, "sceMpegRingbufferPut(%08x, %i, %i): no packets to enqueue", ringbufferAddr, numPackets, available); return 0; } @@ -1430,6 +1429,8 @@ u32 sceMpegRingbufferPut(u32 ringbufferAddr, u32 numPackets, u32 available) // Execute callback function as a direct MipsCall, no blocking here so no messing around with wait states etc if (ringbuffer->callback_addr != 0) { + DEBUG_LOG(ME, "sceMpegRingbufferPut(%08x, %i, %i)", ringbufferAddr, numPackets, available); + PostPutAction *action = (PostPutAction *)__KernelCreateAction(actionPostPut); action->setRingAddr(ringbufferAddr); // TODO: Should call this multiple times until we get numPackets.