From b23566b8234af087218609ac1c6ce1178d49a206 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Thu, 3 Nov 2022 11:14:37 +0100 Subject: [PATCH] [APU] Fix incorrect packet frame count when frame ends exactly where packet ends This resolves looping background sound in GoW --- src/xenia/apu/xma_context.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/xenia/apu/xma_context.cc b/src/xenia/apu/xma_context.cc index b8fa080a8..cc6b80271 100644 --- a/src/xenia/apu/xma_context.cc +++ b/src/xenia/apu/xma_context.cc @@ -851,6 +851,12 @@ std::tuple XmaContext::GetPacketFrameCount(uint8_t* packet) { if (stream.Read(1) == 0) { return {frame_count, false}; } + // There is a case when frame ends EXACTLY at the end of packet. + // In such case we shouldn't increase frame count by additional not existing + // frame and don't mark it as splitted, but as a normal frame + if (!stream.BitsRemaining()) { + return {frame_count, false}; + } } }