From b26dcb3f9a29b3526883d5b547e6ea9d1d2cfa76 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sun, 7 Jun 2026 20:27:06 +0800 Subject: [PATCH] Try to fix 'avail' test --- Core/HLE/sceMpeg.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 84825c3065..b7fe9fc58f 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -1376,7 +1376,12 @@ static int sceMpegRingbufferAvailableSize(u32 ringbufferAddr) { } ctx->mpegRingbufferAddr = ringbufferAddr; - if (ctx->mediaengine) { + + // PPSSPP doesn't have a fully asynchronous Media Engine thread to constantly drain the buffer. + // Games like Ridge Racer 2 rely on this function to implicitly update the available size. + // However, we must NOT overwrite packetsAvail if the stream hasn't been initialized/analyzed yet. + // This protects manual struct modifications (like in the 'avail' test) prior to stream playback. + if (ctx->mediaengine && ctx->isAnalyzed) { ringbuffer->packetsAvail = ringbuffer->packets - ctx->mediaengine->getRemainSize() / 2048; }