fix(audio): keep APAC priming so TrueHD Atmos stays in sync with the video - #8
Conversation
…video The spatial bridge dropped the encoder's two priming packets (2048 frames) and stamped the first content packet on the source position. AVFoundation presents an APAC packet's audio 2048 frames before its timestamp, so it removed the priming a second time and every TrueHD Atmos session played 42.7 ms ahead of the video, at load and after every seek. Packet k is now stamped anchor + k*1024 with the priming packets kept, the layout AVAssetWriter writes. Measured with AVPlayer over HLS on macOS 27 (5.1 APAC; macOS rejects 7.1.4) against an ALAC reference: the old layout played a click 42.7 ms early at the start, after a seek, and after a restarted encoder; the new one matches the reference in all three. A new test decodes the bridge's muxed output through AVAssetReader and checks that a click lands on its source position; it fails on the old stamping (0.2074 s instead of 0.25 s). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe bridge now retains APAC priming packets and timestamps each packet from the encoder start frame. Tests check packet timing, packet counts, muxing, and decoded audio onset. ChangesAPAC packet timing
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The change retains APAC priming packets to align TrueHD Atmos audio with video. No actionable merge-blocking issue is established; normal checks remain appropriate. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The new packet layout is documented and tested through decoding, and the review found no new security boundary or verified security issue. Recovery behavior and platform coverage remain less certain. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 4 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused APAC synchronization bug fix that retains encoder priming packets and corrects packet timestamps, while leaving other audio paths unchanged. Added tests verify both packet timelines and the decoded audio position through AVFoundation. You can add or adjust custom eligibility rules. Learn more. |
Silo-Server/AetherEngine#8 merged as a02975ed. Its tree is identical to the PR head 455bcd60 this branch pinned before, so only the recorded revision moves. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(player): pick up AetherEngine's TrueHD Atmos sync fix TrueHD Atmos played 42.7 ms ahead of the video: AetherEngine's APAC bridge dropped the encoder's 2048 frames of priming, which AVFoundation removes again on playback. Silo-Server/AetherEngine#8 keeps the priming packets. Move the pin, Package.resolved and the notices to that commit. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(deps): pin AetherEngine to the TrueHD Atmos sync fix merge commit Silo-Server/AetherEngine#8 merged as a02975ed. Its tree is identical to the PR head 455bcd60 this branch pinned before, so only the recorded revision moves. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Summary
TrueHD Atmos rendered to APAC played 42.7 ms ahead of the video in every session. The spatial bridge dropped the encoder's 2048 frames of priming, and AVFoundation removes the same 2048 frames again on playback. The bridge now keeps the priming packets and stamps packet k at
anchor + k × 1024, the layout AVAssetWriter writes, so the first content frame plays on its source position.Follow-up to #6.
What changed
SpatialAudioBridge.emitkeeps the encoder's two priming packets and stamps every packet from the anchor. Gap fill, restarts and the end-of-stream flush already count packets from the encoder start, so nothing else moves.clickDecodesOnItsSourcePositionrenders a click at a known source position, encodes and muxes it, and decodes the result withAVAssetReader. On the old stamping the click comes out at 0.2074 s instead of 0.25 s; it now lands within 1 ms.SpatialAudioBridgeTestsandTrueHDAtmosSampleTestsexpect two more packets, the priming.formats.md, theAPACEncodernotes andCHANGELOG.mddescribe the new layout.Test plan
AE_TRUEHD_ATMOS_SAMPLEset to Dolby's Unfold.thd, the 9.1.6 bridge emits 1270 contiguous packets.aetherctl serve --atmos-bed 7.1.4 --audio-index 1on the Unfold demo plays from the start and after a seek to 15 s.Checklist
CHANGELOG.mdupdatedfeat(...),fix(...),chore(...))AI disclosure: written with Claude Opus 5.5 (
claude-opus-5-5) in Claude Code. Claude Opus 5.5 review subagents found the offset while reviewing #6; the fix, tests and measurement harness were written in the same session. No other AI tooling was used.🤖 Generated with Claude Code
Note
Fix APAC TrueHD Atmos sync by retaining encoder priming packets
SpatialAudioBridgepreviously dropped the APAC encoder's two priming packets and subtracted leading frames from packet timestamps, so AVFoundation's 2048-frame pre-timestamp presentation placed the first content audio 42.7 ms early. It now emits every encoder packet and timestamps each at the encoder start frame plus its packet index × 1024 frames (SpatialAudioBridge.swift).SpatialAudioBridgeTestsandTrueHDAtmosSampleTeststo include the two priming packets, and documents the retained priming behavior in docs/formats.md and CHANGELOG.md.Macroscope summarized 455bcd6.