mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-26 17:06:51 +00:00
Clean up sceMpegRingbufferAvailableSize().
Avoid a memory copy, some crash checks.
This commit is contained in:
parent
ca78dd4e6d
commit
0b4e93a671
@ -863,18 +863,23 @@ int sceMpegQueryAtracEsSize(u32 mpeg, u32 esSizeAddr, u32 outSizeAddr)
|
||||
|
||||
int sceMpegRingbufferAvailableSize(u32 ringbufferAddr)
|
||||
{
|
||||
if (!Memory::IsValidAddress(ringbufferAddr)) {
|
||||
PSPPointer<SceMpegRingBuffer> ringbuffer;
|
||||
ringbuffer = ringbufferAddr;
|
||||
|
||||
if (!ringbuffer.Valid()) {
|
||||
ERROR_LOG(HLE, "sceMpegRingbufferAvailableSize(%08x) - bad address", ringbufferAddr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SceMpegRingBuffer ringbuffer;
|
||||
Memory::ReadStruct(ringbufferAddr, &ringbuffer);
|
||||
DEBUG_LOG(HLE, "%i=sceMpegRingbufferAvailableSize(%08x)", ringbuffer.packetsFree, ringbufferAddr);
|
||||
MpegContext *ctx = getMpegCtx(ringbuffer.mpeg);
|
||||
int result = std::min(ringbuffer.packetsFree, ctx->mediaengine->getRemainSize() / 2048);
|
||||
MpegContext *ctx = getMpegCtx(ringbuffer->mpeg);
|
||||
if (!ctx) {
|
||||
ERROR_LOG(HLE, "sceMpegRingbufferAvailableSize(%08x) - bad mpeg", ringbufferAddr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
hleEatCycles(2020);
|
||||
return ringbuffer.packetsFree;
|
||||
DEBUG_LOG(HLE, "%i=sceMpegRingbufferAvailableSize(%08x)", ringbuffer->packetsFree, ringbufferAddr);
|
||||
return ringbuffer->packetsFree;
|
||||
}
|
||||
|
||||
void PostPutAction::run(MipsCall &call) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user