Skip to content

Commit

Permalink
Corrects the calculation of the return value when the callback of Rin…
Browse files Browse the repository at this point in the history
…gbufferPut returns a negative value.
  • Loading branch information
shenweip committed Dec 28, 2020
1 parent c4d6c19 commit a174390
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Core/HLE/sceMpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,9 @@ void PostPutAction::run(MipsCall &call) {
const u8 *data = Memory::GetPointer(ringbuffer->data + writeOffset * 2048);

int packetsAddedThisRound = currentMIPS->r[MIPS_REG_V0];
ringbufferPutPacketsAdded += packetsAddedThisRound;
if (packetsAddedThisRound > 0) {
ringbufferPutPacketsAdded += packetsAddedThisRound;
}

// It seems validation is done only by older mpeg libs.
if (mpegLibVersion < 0x0105 && packetsAddedThisRound > 0) {
Expand Down Expand Up @@ -1506,7 +1508,12 @@ void PostPutAction::run(MipsCall &call) {
}
DEBUG_LOG(ME, "packetAdded: %i packetsRead: %i packetsTotal: %i", packetsAddedThisRound, ringbuffer->packetsRead, ringbuffer->packets);

call.setReturnValue(ringbufferPutPacketsAdded);
if (packetsAddedThisRound < 0 && ringbufferPutPacketsAdded == 0) {
// Return an error.
call.setReturnValue(packetsAddedThisRound);
} else {
call.setReturnValue(ringbufferPutPacketsAdded);
}
}


Expand Down

0 comments on commit a174390

Please sign in to comment.