Skip to content

fix(cache): preserve quantized audio sample clock coverage - #828

Open
orut34iop wants to merge 2 commits into
superuser404notfound:mainfrom
orut34iop:codex/fix-audio-sample-clock-coverage
Open

orut34iop wants to merge 2 commits into
superuser404notfound:mainfrom
orut34iop:codex/fix-audio-sample-clock-coverage

Conversation

@orut34iop

@orut34iop orut34iop commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Positive-duration audio packets can describe a continuous sample clock while their timestamps are quantized to a coarse container time base. For example, non-reservoir WMA frames of 2,048 samples at 44.1 kHz occupy 46/47 ms steps; treating each declared 46 ms packet independently fragments cache coverage and rejects seeks into bytes already retained.

Carry a feasible integer rational sample-clock phase across packets when the codec parameters admit exact sample geometry. Use the same coverage for the read-ahead frontier, resident ranges and retained-seek admission. A genuine missing packet, accumulated drift, missing/backward timestamps, conflicting duration or arithmetic overflow cannot be explained away by a fixed gap tolerance. Unknown codecs/packed layouts keep strict coverage. The decoded audio output clock and video admission are unchanged.

Admission covers AC-3/MPEG audio, declared AAC/E-AC-3 frame sizes, complete non-reservoir WMA v1/v2 blocks and exact PCM sample frames. This reuses upstream's duration-less successor coverage (#775) rather than presenting it as a new TrueHD fix. It overlaps #823's overflow protection in the replaced audio coverage helper: this model also checks subtraction overflow. If #823 is accepted first, preserve its regression when resolving that textual overlap. #613/#614's video interval behavior is unchanged.

Tests include 24 long sample-rate/time-base combinations, exact PCM/WMA admission, drift/real gaps/unknown layouts and actual disk and memory stores. The memory integration witnesses keep packets in the non-purgeable forward queue; they do not assume consumed history survives reclamation (#759/#819).

Validation on Apple Silicon (Mac17,3), macOS 26.7.1 / Swift 6.4:

  • swift build --build-tests passed; test executable signed and verified with a valid Apple Development identity.
  • Strict cooperative-pool focused run: 8 tests / 4 suites passed (including 4 real-store/gap combinations and the 24 long timing combinations).
  • Full default-traits suite, serial: 795 XCTest (one pre-existing skip) and 4,619 Swift Testing tests / 636 suites passed.
  • Documentation links and git diff --check passed.

CI on the initial implementation passed iOS/tvOS/visionOS builds and default/all-traits tests, including both strict cooperative-pool runs. Its later standalone regression step exposed a missing source entry in test-software-packet-read-ahead.sh; the follow-up commit adds SoftwareAudioPacketCoverage.swift to that build. All six standalone packet regressions now pass locally (packet/video coverage, disk FIFO, read-ahead, read admission and stored packets), with Apple Development signatures verified. CI for the follow-up commit is pending. These are deterministic timing and store witnesses, not new physical media/device acceptance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant