Don't double decrease g_inCbCount.

Happened when a thread was deleted, it seems like.  Fixes #6542.
This commit is contained in:
Unknown W. Brackets 2014-07-12 09:56:03 -07:00
parent 88cfcf7e26
commit ef4847b6f5
2 changed files with 6 additions and 3 deletions

View file

@ -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)

View file

@ -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.