Skip to content

fix(ajm): decode an ATRAC9 run's whole input and follow gapless segments - #2052

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
esatturan:fix/ajm-atrac9-gapless-segments
Oct 10, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
esatturan:fix/ajm-atrac9-gapless-segments

Conversation

@esatturan

@esatturan esatturan commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

  • An ATRAC9 run job stops after the gapless total of output samples, counted from the start of the current segment, and leaves the rest of its input unconsumed. The next run starts the next segment with the decoder as it is, without a second skip. A reset (SetGaplessDecode with the reset flag, ClearContext, initialization) starts a new segment.
  • An ATRAC9 run job decodes its whole input with or without RUN_MULTIPLE_FRAMES: FMOD in PPSA29141 puts two run jobs in one batch, with the second's input right after the whole of the first's. MP3 and Opus run jobs are unchanged.
  • FMOD sets a gapless total shorter than a sound's frames and reads the frames after it on later runs. With the output held at the total, its stream reader waited forever and the last buffer looped.
  • Both are recorded in TechnicalDebt.

Tested

Windows 11, i7-13650HX, RTX 4070 Laptop, MinGW-w64 GCC 15.2.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes (Claude Code)

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Three things before this can go in:

  • Drop the code comments in Ajm.cpp (the segmentSamples and RunAt9 blocks) and in AudioOut2Context.cpp.
  • Drop the APS5_DUMP_AUDIO dump and the new batch traces; they're a separate change.
  • Add a guest_ajm case that fails on main: a gapless total shorter than the frames, then a second run that gets the frames after it.

It conflicts with main in TechnicalDebt now, so please rebase when you push.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@esatturan
esatturan force-pushed the fix/ajm-atrac9-gapless-segments branch from 09e3616 to 9c95d48 Compare October 9, 2026 23:19
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1491 docs/dev/TechnicalDebt.md L361

@esatturan esatturan changed the title fix(ajm): follow ATRAC9 gapless segments across run jobs fix(ajm): decode an ATRAC9 run's whole input and follow gapless segments Oct 9, 2026
@esatturan

Copy link
Copy Markdown
Contributor Author

Done, rebased on current main:

  • Removed the code comments in Ajm.cpp, and dropped the AudioOut2Context.cpp change (APS5_DUMP_AUDIO) and the new batch traces.
  • Added TestAt9GaplessSegments to guest_ajm. The gapless total is 512 samples over a 1024-sample superframe. The first run stops after two frames and leaves input; the second run gets the two frames after the total. On main the first run consumes the whole superframe, so the test fails.
  • Added TestAt9RunDecodesWholeInput for the other half of the change: a run without RUN_MULTIPLE_FRAMES decodes the whole superframe. It also fails on main. The description now states this half, and TechnicalDebt records it, since the console's behaviour there is not verified.

@oneandonlydean
oneandonlydean merged commit c323d49 into boykopovar:main Oct 10, 2026
6 of 8 checks passed
SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
…ess-segments

fix(ajm): decode an ATRAC9 run's whole input and follow gapless segments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants