fix(ajm): restart the stream total at a gapless reset #12322
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12322"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-28T09:23:56Z.
What
Ratchet & Clank: Rift Apart (PPSA01474) hangs on its title screen when it seeks a 4-channel ATRAC9 stream. The game sends
sceAjmBatchJobSetGaplessDecodewith the reset flag and a new total, then counts the new segment from the stream sideband's total decoded samples.Cause: the
SetGaplessDecodereset clearssegmentSamplesandskippedSamplesbut keepstotalDecodedSamples, so every later run reports the samples decoded before the seek as well. In the hang, the stream had decoded 10,944 samples before a seek to a 343,028-sample segment. When the voice hung, the segment had decoded 334,272 samples and the sideband reported 345,216. The game's voice reached its end 8,756 samples early (343,028 − 334,272), and the sideband claimed 2,188 samples past it (345,216 − 343,028). The two add up to 10,944. The voice then owes 140 samples it never gets, and the mixer loop holding the main thread's lock never exits. The trace and the core analysis are in #11700 (https://github.com/boykopovar/AnyPS5/issues/11700#issuecomment-6462306535).Fix: the reset branch of
SetGaplessDecodealso setstotalDecodedSamplesto 0, for every codec. This matchesClearContextin the same file, which already zeroes it on aCONTROL_RESET, and shadPS4'sAjmInstance::Reset()(m_total_samples = 0), which runs for every job with the reset flag. Not measured on a console; the debt entry says so.Related, already fixed on
main: the constant tone I reported in #11700 was not AJM. About 20 of the title's object ports get their PCM from the same two scratch buffers, set one port after another, and AudioOut2 read every pointer atAdvance, so each port mixed the last port's grain. A local copy of each grain atsceAudioOut2PortSetAttributesremoved it (no full-scale grain in 183 one-second summaries after the title, against 119 of 119 before). #8098 fixes the same thing onmain.This changes the expectation that #6040 added to
TestOpusGaplessReset: each segment's total now restarts instead of accumulating. #6040 kept the cumulative count as a choice, without console data. @Ondra97, if you know of a title or a measurement that needs the count kept across aSetGaplessDecodereset, I'd like to hear it.Tested
Linux 7.3 (CachyOS), GCC 16.2.1, Release,
BUILD_TESTING=ON, onmain316615d04.TestAt9GaplessResetRestartsTotal: a run decodes 1,024 samples, aSetGaplessDecodereset sets a 512-sample segment, and the next run must report a total of 512. A laterSetGaplessDecodewithout the reset must keep counting.Ajm.cppfrommain,guest_ajmfails. The first failure is inTestOpusGaplessReset. With the Opus calls skipped, the new test fails at its second run, which reports a total of 1,536 instead of 512.ctest -R 'ajm|audio': 65/65 passed.tools/check_conventions.py --base origin/mainpasses.main(abed03546) with #9749, #10906, #10000 and local probes. With this change as a switch, the tail rule from #11700, and local equivalents of #8098 and #11838 (both merged since), the title got through the title screen, save slot, difficulty and control style screens and the opening cutscene, to the first playable stage. Without this change (tail rule alone) it hung on the title screen as described above. One run each.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T09:31:40Z.
Review: APPROVED
The reset branch clears
totalDecodedSamplesalongside the segment counters, and the updated AT9/Opus tests verify the total restarts after reset but continues across a non-reset gapless update. The author reports 65/65 focused AJM/audio tests, including a negative control and the traced Ratchet & Clank title path; this was not measured on a physical PS5. Hosted Windows, conventions, intake and reporting pass. No blocking issue found on head08fdabc2d9fa.