Skip to content

fix(audio): objects play from the first frame after a seek in TrueHD Atmos - #741

Merged
superuser404notfound merged 2 commits into
superuser404notfound:mainfrom
kristofferR:fix/object-audio-hold-before-metadata
Oct 13, 2026
Merged

superuser404notfound merged 2 commits into
superuser404notfound:mainfrom
kristofferR:fix/object-audio-hold-before-metadata

Conversation

@kristofferR

Copy link
Copy Markdown
Contributor

Summary

After every seek or producer restart, TrueHD Atmos rendered to APAC plays the LFE alone for a moment. Decoding resumes at the next major sync, but the stream's first object metadata arrives 0 to 38 access units later (up to 32 ms on measured films). Until then the renderer has no position for any object and renders it silent, and in films whose bed is LFE only, that is everything else. This holds those blocks and plays them at the first metadata's positions.

Ref #731

What changed

  • TrueHDObjectAudioDecoder holds the blocks it decodes between a reset and the first metadata (ObjectMetadataHold). When the payload arrives, it releases them in order, and the first one carries that payload's first state as a jump at frame 0. The payload's own update still applies at its own offset.
  • Only presentations with objects are held, and only for up to 100 ms (4800 frames). A stream that sends no metadata within that is released unchanged, objects silent until their metadata, as before.
  • A configuration change re-arms the hold, because the bridge's rebuilt renderer starts without positions too.
  • At end of input, SpatialAudioBridge.flush() asks the decoder to release whatever it holds (ObjectAudioDecoding.finishInput()) and renders it unchanged.
  • Nothing is held between the first metadata and the next reset or configuration change, so steady-state blocks pass through uncopied.
  • Block timing is untouched (inputFrameOffset stays per block), so the bridge anchors exactly as before; the served fragments' tfdt values are identical with and without the change.

Test plan

  • Device / OS: M-series Mac, macOS 27, aetherctl serve --atmos-bed 7.1.4.

  • Source media: Dolby's Nature's Fury demo, TrueHD Atmos in MKV, LFE + objects. Cold fetches of seg20 (producer restart at 80.25 s) and seg19 (restart at 76.12 s), decoded with AVAssetReader.

  • Result: non-LFE energy at the start of seg20:

    Window main This PR Source
    0–4 ms −200 dB −31.1 dB −30.4 dB
    8–12 ms −200 dB −29.5 dB −27.5 dB
    16–20 ms −200 dB −27.1 dB −25.7 dB
    20–24 ms −131 dB −30.5 dB −29.3 dB

    seg19's first 4 ms: −118.8 dB on main, −30.5 dB with this PR (source −29.0 dB).

  • ObjectMetadataHoldTests covers:

    • in-order release with the frame-0 state and the audio copied intact;
    • priming of the frames before metadata inside the first block;
    • steady-state pass-through without copies;
    • bed-only presentations never held;
    • the 100 ms limit;
    • configuration changes, before and after the first metadata;
    • release at end of input.

    The 100 ms quoted in formats.md is pinned in DocumentedConstantsTests. swift test --filter "ObjectMetadataHoldTests|DocumentedConstants|SpatialObjectRenderingTests|SpatialAudioBridgeTests|TrueHDObjectMetadataMapping|PublicAPIDocumentation" passes.

This is one of three independent TrueHD Atmos fixes. Each adds an entry under Unreleased › Fixed in CHANGELOG.md, so whichever merges second needs a one-line rebase there.

Checklist

  • CHANGELOG.md updated
  • Commit messages follow Conventional Commits (feat(...), fix(...), chore(...))
  • The fix lives in the engine, not in a host-side workaround
  • Public API changes are intentional and documented (none)

…Atmos

Decoding resumes at the next major sync after a seek, and the first object
metadata follows up to 32 ms later. Until it arrived every object rendered
silent, so the APAC carried the LFE alone. The decoder now holds those
blocks and releases them with the first metadata's state applied from
their first frame, waiting at most 100 ms.
…s at EOF

A configuration change rebuilds the renderer without object positions, so
the hold re-arms for it instead of passing the new configuration's first
blocks straight through. At the end of input no metadata will come for
what is held, so the bridge's flush releases it and renders it as it is.
@superuser404notfound
superuser404notfound merged commit 7c2cf57 into superuser404notfound:main Oct 13, 2026
superuser404notfound pushed a commit that referenced this pull request Oct 13, 2026
The hold added in #741 keeps up to 100 ms of TrueHD Atmos blocks back after a reset until the first
object metadata arrives. settle(), which the producer calls before a cut, only waited for the encode
pipeline, so blocks still held at a cut (a decoder self-reset just before one) came out after it and
landed in the next segment. settle() now releases and renders them first, so a cut sees what it saw
before the hold existed. A release with nothing held leaves the hold armed, so a cut ahead of the
first audio after a restart does not switch it off. finishInput() is renamed releaseHeldBlocks(),
since end of input is no longer its only caller.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
@superuser404notfound

Copy link
Copy Markdown
Owner

Thanks a lot for this one, and for the before/after numbers on Nature's Fury, that made it easy to verify. Merged in 7c2cf57 (the CHANGELOG conflict resolved into Unreleased › Fixed), full suite green on both runners.

One follow-up on top, c2f70cb: settle(), which the producer calls before a cut, only waited for the encode pipeline, so blocks still held at a cut (a decoder self-reset just before one) would have come out after it and landed in the next segment. settle() now releases and renders them first, so a cut sees what it saw before the hold existed. A release with nothing held leaves the hold armed, so a cut ahead of the first audio after a restart does not switch it off. finishInput() became releaseHeldBlocks() since EOF is no longer its only caller. If #742 touches the same protocol, that is the name to rebase onto.

It goes out with the next release.

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.

2 participants