Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
f365921
feat(disc): a UHD Blu-ray's Dolby Vision plays as Profile 7, the enha…
williamliu0516 Oct 16, 2026
7560243
test(disc): the Blu-ray Dolby Vision fold finds the RPU and the level
williamliu0516 Oct 16, 2026
3b96ebc
fix(software): an empty read-ahead store is the end of the stream onl…
williamliu0516 Oct 16, 2026
ba3bcbf
Pass the live refusal budget and backoff per reader in tests
pkajaba Oct 16, 2026
1e47156
Pass the reconnect backoff, pin idle gap and body reserve per reader …
pkajaba Oct 16, 2026
dd47348
Assert the body reserve was reported and fix its comment
pkajaba Oct 16, 2026
c73d10e
fix(demux): container chapters publish on the seek axis
pkajaba Oct 15, 2026
61aa6cb
test(tests): the live reader helper comment says the values are per r…
pkajaba Oct 16, 2026
650704c
fix(software-host): a seek before the first play lands on the source …
pkajaba Oct 16, 2026
db90587
fix(software-host): the session zero is predicted at load for every n…
pkajaba Oct 17, 2026
8039ebd
feat(visionos): 3D sources play as stereo: MV-HEVC keeps its second v…
williamliu0516 Oct 17, 2026
bd18a9c
fix(visionos): MV-HEVC keeps its 3D reference displays SEI in the hvc…
williamliu0516 Oct 17, 2026
c5176e5
chore(visionos): stereoPresentation is a correctable load option, and…
williamliu0516 Oct 17, 2026
52b8fe5
fix(hdr10+): the software path's VideoToolbox decoder carries HDR10+,…
williamliu0516 Oct 17, 2026
74ee906
Merge remote-tracking branch 'origin/main' into salvage/chapter-seek-…
pkajaba Oct 17, 2026
a6ddc87
test(cache): respect kernel purges in history eviction checks
yucelokan Oct 17, 2026
598ae25
fix(playback): publish native buffer growth while paused
orut34iop Oct 18, 2026
88eaa8d
fix(subtitles): scope inherited headers to the media origin
orut34iop Oct 18, 2026
156588a
fix(subtitles): preserve secondary track identity across rebuilds
orut34iop Oct 18, 2026
58cc7ee
fix(subtitles): preserve secondary sidecar ASS metadata
orut34iop Oct 18, 2026
d927981
feat(cache): allow explicit software packet storage selection
orut34iop Oct 18, 2026
2fe2836
fix(cache): preserve quantized audio sample clock coverage
orut34iop Oct 18, 2026
e28cb83
feat(subtitles): prepare and commit external selections transactionally
orut34iop Oct 18, 2026
33e2813
feat(cache): expose session byte budgets and lifecycle status
orut34iop Oct 18, 2026
67f1b9f
fix(ci): include audio coverage in standalone read-ahead build
orut34iop Oct 18, 2026
71096dd
fix(prewarm): skip suffix fetch for fully resident sources
orut34iop Oct 18, 2026
38d3409
fix(hls): inherit isolation for persistent body reads
brandomoore Oct 18, 2026
bc85e60
fix(hls): preserve isolation through socket progress reads
brandomoore Oct 18, 2026
c60ce1e
feat(preview): Dolby Vision Profile 5 / 10.0 scrub previews drawn by …
Oct 19, 2026
68a2851
feat(held-picture): Dolby Vision Profile 5 / 10.0 holds its frame thr…
Oct 19, 2026
516c47e
fix(audio): keep the Atmos confirmation pass off one-request origins
Oct 19, 2026
d66321a
feat(display): a host-owned display-criteria mode (#842)
Oct 19, 2026
72fff52
feat(preview): Dolby Vision Profile 5 / 10.0 scrub previews outside t…
Oct 19, 2026
6e6c630
Merge pull request #840 from superuser404notfound/feat/dv-compositor-…
superuser404notfound Oct 19, 2026
667236d
chore(release): prep 7.41.0 - Dolby Vision Profile 5 / 10.0 scrub pre…
Oct 19, 2026
35db225
Merge pull request #841 from superuser404notfound/fix/atmos-confirmat…
Oct 19, 2026
58303c7
Merge pull request #843 from superuser404notfound/feat/842-host-owned…
Oct 19, 2026
f5af2a3
chore(release): prep 7.42.0 - host-owned display criteria, Atmos conf…
Oct 19, 2026
fc1d120
fix(audio): with no audio track tagged, object audio replaces the def…
Oct 19, 2026
07de30e
Merge branch 'fix/untagged-object-audio-pick'
Oct 19, 2026
02ae2c6
fix(hls): gate each segment request on FIFO headroom
orut34iop Oct 18, 2026
3dba978
test(hls): cover an AES-128 segment filling the FIFO before the next …
Oct 19, 2026
af85d85
Merge PR #832: gate each persistent HLS segment request on FIFO headr…
Oct 19, 2026
e423baa
chore(deps): FFmpegBuild 3.8.0, RealMedia, 3GP, Theora and VobSub
Oct 19, 2026
ea1ab63
feat(audio): route RealAudio, AMR and DVD LPCM as named bridged codecs
Oct 19, 2026
3721cec
Merge feat/ffmpegbuild-3.8-realmedia: FFmpegBuild 3.8.0, RealMedia, 3…
Oct 19, 2026
cb25fe8
perf(load): produce the first segments while the panel switches (#348)
Oct 19, 2026
e3a00ff
Merge upstream/main into fix/readahead-empty-store-eos
williamliu0516 Oct 20, 2026
de5496a
Merge main into pr/hdr10plus-software-path
williamliu0516 Oct 20, 2026
82034ab
Merge branch 'main' into feat/visionos-stereo-upstream
williamliu0516 Oct 20, 2026
4467df7
Merge feat/ae348-load-during-switch: produce the first segments while…
Oct 20, 2026
e9b379e
chore(release): prep 7.43.0 - segments during the panel switch, RealM…
Oct 20, 2026
219e551
feat(audio): decode DTS:X with FFmpeg's dca decoder instead of LibDTS…
Oct 20, 2026
969096e
chore(deps): FFmpegBuild 3.9.0, LibDTSX out of the resolved graph (#798)
Oct 20, 2026
40adb21
Merge feat/798-dtsx-via-ffmpeg: decode DTS:X with FFmpeg's dca decode…
Oct 20, 2026
e5ea8da
chore(release): prep 7.44.0 - DTS:X through FFmpeg's dca decoder, Lib…
Oct 20, 2026
2394ab2
Merge PR #809: per-reader #255 body reserve, give-up test bounded fro…
Oct 20, 2026
a18a385
fix(software): live HLS holds back by its segment length, not a TS pa…
Oct 20, 2026
89b1b52
Merge fix/813-sw-live-hls-holdback: live HLS on the software path hol…
Oct 20, 2026
5688776
Merge PR #805: a UHD Blu-ray's Dolby Vision plays as Profile 7
Oct 20, 2026
b69a860
fix(disc): a folded UHD Blu-ray never takes the dual-layer route, the…
Oct 20, 2026
99168b5
Merge PR #815: container chapters publish on the seek axis
superuser404notfound Oct 20, 2026
2f294f0
docs(demux): container chapters are on the seek axis, an unchanged li…
Oct 20, 2026
31b3af2
fix(probe): bound the rewind after the load-time interlace sample
Oct 20, 2026
9c544c3
Merge PR #819: purgeable-history test no longer races the kernel
superuser404notfound Oct 20, 2026
a320dab
test(cache): keep memory-store history resident in tests that re-read…
Oct 20, 2026
2a5245d
Merge PR #821: native buffered position keeps publishing while paused
Oct 20, 2026
8cb7c62
Merge pull request #822 from orut34iop/codex/fix-subtitle-header-origin
Oct 20, 2026
acd54af
refactor(subtitles): require the media URL at every sidecar fill-job …
Oct 20, 2026
57ab376
Merge PR #824: preserve secondary subtitle identity across rebuilds
Oct 21, 2026
00079b0
docs(changelog): house style for the #824 entry
Oct 21, 2026
867b172
Merge PR #826: preserve secondary sidecar ASS metadata
Oct 21, 2026
d98f62a
docs(changelog): house style for the #826 entry, moved into Unreleased
Oct 21, 2026
e60cc82
Merge PR #827: explicit software packet cache storage
superuser404notfound Oct 21, 2026
e0203fc
refactor(cache): one constant for the memory packet store bounds, cha…
Oct 21, 2026
f301c79
Merge PR #829: transactional external subtitle preparation
Oct 21, 2026
cb7c6fb
fix(subtitles): prepared commit matches the ordinary sidecar select, …
Oct 21, 2026
7e4fd03
Merge PR #830: session cache byte budgets and lifecycle status
Oct 21, 2026
2d63474
fix(cache): an explicit session budget of 0 stays bounded, changelog …
Oct 21, 2026
b3f3e9d
fix(cache): no force unwrap on the resolved budget, undated stale dir…
Oct 21, 2026
debbb78
Merge PR #828: quantized audio sample clock coverage
Oct 21, 2026
ebb6a10
fix(cache): duration-less audio keeps successor coverage when the fra…
Oct 21, 2026
7865bbc
Merge branch 'pr-831' into merge-831
Oct 21, 2026
060d77a
test(subtitles): cover independent secondary bitmap decoding
orut34iop Oct 18, 2026
d1b227a
fix(audio): the Atmos output activator runs only on an HDMI route (#834)
Oct 21, 2026
3450f1c
Merge branch 'pr-837' into merge-837
Oct 21, 2026
2e5174d
fix(probe): HLG named by an alternative transfer SEI plays as HLG (#839)
Oct 21, 2026
c020384
Merge fix/839-hlg-alternative-transfer-sei: broadcast HLG via alterna…
Oct 21, 2026
6a48db4
feat(live): LoadOptions.liveEdgeCushionSeconds, a host-chosen distanc…
Oct 21, 2026
5425ba4
fix(live): a remote-HLS cushion never plays closer than the origin's …
Oct 21, 2026
6a0c3a8
Merge feat/live-minimum-holdback: LoadOptions.liveEdgeCushionSeconds,…
Oct 21, 2026
52802af
chore(release): prep 7.45.0 - live edge cushion, session cache budget…
Oct 21, 2026
ec57175
Merge upstream/main into fix/readahead-empty-store-eos
williamliu0516 Oct 21, 2026
19f23ef
Merge upstream/main into pr/hdr10plus-software-path
williamliu0516 Oct 21, 2026
a0d7ee1
fix(subtitles): arm the bitmap OCR worker only while its rendition is…
Oct 22, 2026
ff304b7
fix(native): reset the master-fallback single-shot across session-pre…
adityabakare Oct 22, 2026
7ace162
Update CHANGELOG.md
adityabakare Oct 22, 2026
ce00788
Merge branch 'main' into ac3-fix
adityabakare Oct 22, 2026
b77c837
fix(live): build the first live window before AVPlayer is handed the …
Oct 22, 2026
98cd7cc
Merge fix/live-cushion-playlist-timer: the first live window is built…
Oct 22, 2026
710d4fd
docs(iframe): name HDR on an SDR-locked output as the media-routing c…
Oct 22, 2026
ff5984b
feat(diag): per-thread CPU time beside the memprobe
Oct 22, 2026
58544a4
Merge feat/thread-cpu-probe: per-thread CPU time beside the memprobe
Oct 22, 2026
40193ce
chore(release): prep 7.46.0 - per-thread CPU probe, bitmap OCR on nat…
Oct 22, 2026
cc29b7c
fix(audio): size, snap and zones only in the reference build, Atmos a…
Oct 23, 2026
08916b7
Merge remote-tracking branch 'origin/main' into pr-812
Oct 23, 2026
da76534
docs(visionos): 3D entry under Unreleased, stereoPresentation in the …
Oct 23, 2026
0abf10c
Merge PR #812: play 3D films in 3D on visionOS (MV-HEVC, side-by-side…
Oct 23, 2026
ab25e45
fix(sw-live): start a live join on its first keyframe so picture and …
Oct 23, 2026
dda94f8
Merge fix/844-sw-live-join-on-keyframe: a software live join starts o…
Oct 23, 2026
90b591b
fix(native): a resume's buffering-rate evaluation is not a rebuffer (…
Oct 23, 2026
fcd90a5
fix(native): a cleared waiting reason does not recompute the rebuffer…
Oct 23, 2026
67d17ec
Merge fix/168-resume-evaluating-not-rebuffer: a resume's buffering-ra…
Oct 23, 2026
5a0d99b
docs(used-by): add Plozz
superuser404notfound Oct 23, 2026
be8877d
Merge pull request #857 from superuser404notfound/used-by/issue-845
superuser404notfound Oct 23, 2026
814fef1
fix(audio): the Atmos activator matches the HDMI port's real type, HD…
Oct 23, 2026
a1a70cd
chore(release): prep 7.47.0 - 3D on visionOS, Atmos activator on HDMI…
Oct 23, 2026
bb3068a
fix(audio): pad a title's audio with silence to the end of its video …
Oct 24, 2026
4669b4c
fix(audio): an ALAC tail fill follows the track's cookie frameLength …
Oct 24, 2026
6f0d774
chore(deps): FFmpegBuild 3.10.0 - the AAC and ALAC encoders (#847)
Oct 24, 2026
2eac64d
Merge fix/847-video-outlives-audio: a title whose audio ends before i…
Oct 24, 2026
97e32c5
fix(sw): the preroll holds while the decoder is still working, and pu…
Oct 24, 2026
88a459e
Merge fix/800-preroll-progress: the preroll holds while the decoder i…
Oct 24, 2026
e600649
fix(live): a plain-URL live open the origin answers with a status fai…
Oct 24, 2026
bc471de
Merge fix/796-live-open-typed-status: a plain-URL live open the origi…
Oct 24, 2026
3d71452
feat(audio): TrueHD Atmos decoded exactly and its objects rendered ag…
Oct 24, 2026
906dd05
chore(deps): LibTrueHD 3.1.0, the exact decode the object renderer ne…
Oct 24, 2026
8ccd381
Merge feat/truehd-exact-render: TrueHD Atmos decoded exactly and its …
Oct 24, 2026
cb3c210
Merge PR #811 'fix/readahead-empty-store-eos': an empty read-ahead st…
Oct 24, 2026
8944331
Merge main into pr/hdr10plus-software-path (#814)
Oct 24, 2026
8085474
fix(hdr10+): store a frame's HDR10+ payload only once its packet reac…
Oct 24, 2026
9421ef0
fix(pump): stay userInitiated once the relaxed class measures below r…
Oct 24, 2026
9759e5e
Merge fix/pump-relax-rate-850: a pump that measures below real time o…
Oct 24, 2026
83fcb1f
Merge #852: reset the master-fallback single-shot across session-pres…
Oct 24, 2026
a71c6b1
chore(native): file the #849 latch reset under Unreleased and under i…
Oct 24, 2026
952a3bc
fix(native): an audio switch keeps the media playlist its session fel…
Oct 24, 2026
0f080f8
Merge fix/audio-switch-keeps-media-849: an audio switch keeps the med…
Oct 24, 2026
28cffb9
fix(native): a refused HDR master does not latch the panel refusal on…
Oct 24, 2026
def48fe
Merge fix/builtin-panel-refusal-no-latch: a refused HDR master does n…
Oct 24, 2026
fa00f1b
Merge upstream AetherEngine main (def48fe8, after 7.47.0) into the Si…
Quick104 Oct 24, 2026
0a883e2
test: pass mediaURL to the subtitle fill helpers in the fork's author…
Quick104 Oct 24, 2026
ff62623
fix(subtitles): keep a secondary ASS sidecar as plain text in the Sil…
Quick104 Oct 24, 2026
df72cc5
fix(subtitles): keep a prepared secondary ASS commit as styled text
Quick104 Oct 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
447 changes: 434 additions & 13 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Three samples covering different audiences:
```
https://github.com/superuser404notfound/AetherEngine
```
Dependency Rule: Up to Next Major Version, starting from `7.40.1`. Add the `AetherEngine` library product to your app target.
Dependency Rule: Up to Next Major Version, starting from `7.47.0`. Add the `AetherEngine` library product to your app target.

3. **Drop the file in.** Replace the Xcode template's default `App.swift` (or whatever the generated `@main` file is called) with the contents of [`MinimalPlayerApp.swift`](MinimalPlayer/MinimalPlayerApp.swift). The file is self-contained: it defines both the `@main App` struct and the `ContentView`.

Expand Down
24 changes: 3 additions & 21 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 3 additions & 15 deletions Package.swift

Large diffs are not rendered by default.

29 changes: 15 additions & 14 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Scripts/test-software-packet-read-ahead.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ trap 'rm -f "$TASK_TMP/check"; rmdir "$TASK_TMP"' EXIT
xcrun swiftc \
"$TASK_ROOT/Sources/AetherEngine/Native/SoftwareStoredPacket.swift" \
"$TASK_ROOT/Sources/AetherEngine/Native/SoftwarePacketCoverage.swift" \
"$TASK_ROOT/Sources/AetherEngine/Native/SoftwareAudioPacketCoverage.swift" \
"$TASK_ROOT/Sources/AetherEngine/Native/SoftwareVideoPacketCoverage.swift" \
"$TASK_ROOT/Sources/AetherEngine/Native/SoftwarePacketDiskFIFO.swift" \
"$TASK_ROOT/Sources/AetherEngine/Native/SoftwarePacketStore.swift" \
Expand Down
42 changes: 42 additions & 0 deletions Sources/AetherEngine/AetherEngine+CompositorPreview.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import Foundation

/// Where a compositor-drawn scrub preview landed (`AetherEngine.showScrubPreview(atSeconds:in:)`).
public struct ScrubPreviewPlacement: Sendable, Equatable {
/// Playlist/output seconds of the keyframe on screen.
public let actualSeconds: Double
/// The span the same picture stands for: the plan segment that keyframe opens.
public let validRange: Range<Double>
}

extension AetherEngine {

/// True when this session's scrub previews come through `showScrubPreview(atSeconds:in:)` and an
/// `AetherScrubPreviewView` rather than a `CGImage`: a native VOD session of Dolby Vision without
/// a displayable base layer (Profile 5, AV1 Profile 10.0), whose colour only the system
/// compositor applies. Independent of the `DolbyVisionStillReshaping` trait. Inside the resident
/// window the picture comes out of the segment cache, like `scrubThumbnail`; outside it, out of
/// the source's own keyframe, read by a side demuxer.
public var scrubPreviewDrawsInView: Bool {
guard !isLive, let session = nativeVideoSession else { return false }
return session.previewNeedsCompositor
}

/// Shows the keyframe that opens the plan segment holding `seconds` (playlist/output axis, as
/// `scrubThumbnail` takes it) in `view`: from the segment cache when that segment is resident,
/// otherwise read off the source the way the I-frame rendition reads its entries. Nil when
/// `scrubPreviewDrawsInView` is false, the segment is not resident and the origin admits no side
/// read (sequential, serial or held connection, disc, not reopenable by URL), the read failed, a
/// newer request superseded this one, or the session changed meanwhile; the view keeps its
/// previous picture in every case.
public func showScrubPreview(atSeconds seconds: Double, in view: AetherScrubPreviewView) async -> ScrubPreviewPlacement? {
guard seconds.isFinite, scrubPreviewDrawsInView, let session = nativeVideoSession else { return nil }
let gen = loadGeneration
let file = await BlockingWork.detached(priority: .userInitiated) { [session] in
session.compositorPreviewFile(atSeconds: seconds)
}.value
guard let file, gen == loadGeneration, !Task.isCancelled else { return nil }
guard await view.present(file.url), gen == loadGeneration else { return nil }
return ScrubPreviewPlacement(actualSeconds: file.startSeconds,
validRange: file.startSeconds..<(file.startSeconds + file.durationSeconds))
}
}
24 changes: 24 additions & 0 deletions Sources/AetherEngine/AetherEngine+Diagnostics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ extension AetherEngine {
HTTPDiscIOReader.resetLifetimeFetchedBytes()
// #134: currentTime()/loadedTimeRanges are sync XPC reads; hop them off the main actor.
let probeReadQueue = DispatchQueue(label: "engine.memprobe.avfread", qos: .utility)
let cpuSampler = ThreadCPUSampler()
_ = cpuSampler.sample()
memoryProbeTask = Task { @MainActor [weak self] in
while !Task.isCancelled {
try? await Task.sleep(for: .seconds(30))
Expand Down Expand Up @@ -367,6 +369,9 @@ extension AetherEngine {
+ "seams=\(self.presentationAxis.seams.count)"

EngineLog.emit(line, category: .engine)
if let cpu = cpuSampler.sample() {
EngineLog.emit("[AetherEngine] cpuprobe t=\(elapsed)s " + cpu.logFragment(), category: .engine)
}

// #250: the steady-state cadence for the subtitle-resolution statement. It rides
// the memprobe rather than the 2 Hz drain tick because it states a span, and a
Expand Down Expand Up @@ -488,6 +493,25 @@ extension AetherEngine {

// MARK: - Live telemetry bridge

/// Lifecycle callbacks can arrive after stop or a new load. Only cleanup may publish after
/// the owning session has detached; the token still prevents it crossing into its successor.
func acceptSessionCacheStatus(_ status: SessionCacheStatus, token: UInt64) {
guard token == sessionCacheStatusToken else { return }
guard status.cleanupResult != .notRun || nativeVideoSession != nil else { return }
diagnostics.sessionCacheStatus = status
}

/// Read the cache ledger off-main. An old tick must never overwrite a new session or cleanup.
func refreshSessionCacheStatus() async {
guard let session = nativeVideoSession else { return }
let token = sessionCacheStatusToken
let generation = loadGeneration
let status = await BlockingWork.detached(priority: .utility) { session.sessionCacheStatus() }.value
guard !Task.isCancelled, sessionCacheStatusToken == token, loadGeneration == generation,
nativeVideoSession === session else { return }
diagnostics.sessionCacheStatus = status
}

/// Single write-through point: sampler never reaches into `EngineDiagnostics` directly.
func applyLiveTelemetry(_ snapshot: LiveTelemetry) {
diagnostics.liveTelemetry = snapshot
Expand Down
71 changes: 58 additions & 13 deletions Sources/AetherEngine/AetherEngine+HeldPicture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ extension AetherEngine {
let generation = loadGeneration
let started = ContinuousClock.now

if let host = nativeSource,
Self.heldPictureNeedsReshaping(videoFormat: videoFormat, dolbyVisionProfile: sourceDVProfile),
!OptionalComponent.dolbyVisionStillReshaping.isBuiltIn {
await holdThroughCompositor(host: host, view: view, generation: generation, started: started)
return
}

let held: (frame: CVPixelBuffer, isHDR: Bool, route: String)?
if let host = nativeSource {
if Self.heldPictureNeedsReshaping(videoFormat: videoFormat, dolbyVisionProfile: sourceDVProfile) {
// Without the reshaping there is no correct picture to hold, so nothing is decoded.
guard OptionalComponent.dolbyVisionStillReshaping.isBuiltIn else {
heldPictureLastSkip = "Dolby Vision still reshaping not built in"
EngineLog.emit("[AetherEngine] held picture: skipped (Dolby Vision still reshaping not built in, "
+ "DolbyVisionStillReshaping trait off)", category: .engine)
return
}
held = await reshapedDolbyVisionStill(itemSeconds: host.avPlayer.currentTime().seconds)
.map { ($0, false, "Dolby Vision reshaped") }
} else {
Expand Down Expand Up @@ -92,8 +92,58 @@ extension AetherEngine {
EngineLog.emit("[AetherEngine] held picture: frame could not be wrapped for display", category: .engine)
return
}
armHeldPicture(on: view, route: held.route, nativeSource: nativeSource)
EngineLog.emit(
"[AetherEngine] held picture: up after \(Self.milliseconds(ContinuousClock.now - started))ms "
+ "(\(held.route), \(CVPixelBufferGetWidth(held.frame))x\(CVPixelBufferGetHeight(held.frame)), "
+ "hdr=\(held.isHDR))",
category: .engine)
}

/// Dolby Vision without a displayable base layer and without the still reshaping: the frame under
/// the playhead, played out of the resident segment by a player of the surface's own, so the
/// system compositor colours it as it colours playback. Waits at most
/// `heldPictureDolbyVisionBudgetSeconds`, the outgoing picture paused meanwhile.
private func holdThroughCompositor(host: NativeAVPlayerHost, view: any HeldStillSurface,
generation: UInt64, started: ContinuousClock.Instant) async {
let itemSeconds = host.avPlayer.currentTime().seconds
guard let session = nativeVideoSession else { return }
let built = await BlockingWork.detached(priority: .userInitiated) { [session] in
session.compositorHoldFile(atSeconds: itemSeconds)
}.value
guard let hold = built else {
heldPictureLastSkip = "no frame from the outgoing picture"
EngineLog.emit("[AetherEngine] held picture: no resident segment for the compositor hold", category: .engine)
return
}
let spent = Double((ContinuousClock.now - started).components.seconds)
+ Double((ContinuousClock.now - started).components.attoseconds) / 1e18
let budget = max(0.2, Self.heldPictureDolbyVisionBudgetSeconds - spent)
let shown = await view.showCompositorStill(file: hold.url, pastFirstFrameBy: hold.offsetSeconds,
gravity: videoGravity, budgetSeconds: budget)
guard shown else {
heldPictureLastSkip = "no frame from the outgoing picture"
EngineLog.emit("[AetherEngine] held picture: the compositor hold did not become displayable", category: .engine)
return
}
guard loadGeneration == generation, nativeHost === host, (boundStillView ?? boundView) === view else {
view.clearStill()
heldPictureLastSkip = "superseded while the frame was read"
EngineLog.emit("[AetherEngine] held picture: superseded while the frame was read", category: .engine)
return
}
armHeldPicture(on: view, route: "Dolby Vision compositor", nativeSource: host)
EngineLog.emit(
"[AetherEngine] held picture: up after \(Self.milliseconds(ContinuousClock.now - started))ms "
+ "(Dolby Vision compositor, item \(String(format: "%.3f", itemSeconds))s)",
category: .engine)
}

/// Records the hold and arms its release: the next item's first frame (native), the next host's
/// (software), or `heldPictureTimeoutSeconds`.
private func armHeldPicture(on view: any HeldStillSurface, route: String, nativeSource: NativeAVPlayerHost?) {
heldPictureView = view
heldPictureLastRoute = held.route
heldPictureLastRoute = route
heldPictureShownAt = .now
heldPictureToken &+= 1
let token = heldPictureToken
Expand All @@ -113,11 +163,6 @@ extension AetherEngine {
guard let self, self.heldPictureToken == token, self.heldPictureView != nil else { return }
self.releaseHeldPicture(reason: "timeout")
}
EngineLog.emit(
"[AetherEngine] held picture: up after \(Self.milliseconds(ContinuousClock.now - started))ms "
+ "(\(held.route), \(CVPixelBufferGetWidth(held.frame))x\(CVPixelBufferGetHeight(held.frame)), "
+ "hdr=\(held.isHDR))",
category: .engine)
}

/// visionOS has no external playback, and no `isExternalPlaybackActive` to ask.
Expand Down
29 changes: 27 additions & 2 deletions Sources/AetherEngine/AetherEngine+Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@ extension AetherEngine {
// A route transition never transfers expanded native retention into it.
w.setWindowSeconds(softwareHost?.liveDVRWindowSeconds)
}
// AE#813: only the software path holds back from a segmented frontier; a route change clears it.
w.noteEdgeHoldback(videoRoute == .software ? softwareHost?.liveHoldback.edgeHoldbackSeconds : nil)
// Resident media bounds the allowance on both playback routes.
var residentFloor = videoRoute == .software ? softwareHost?.liveDVRResidentFloor : residentLiveFloorSessionSeconds()
// An empty/delayed AVPlayer seekableTimeRanges mirror yields only the item's zero
Expand Down Expand Up @@ -811,8 +813,15 @@ extension AetherEngine {
///
/// Landing the lead behind the frontier reaches the same place with the same cushion and spends
/// nothing on the way. A target the ring already holds that lead for is untouched.
nonisolated static func softwareLiveLanding(requested: Double, window: LiveWindow) -> Double {
window.clamp(Swift.min(requested, window.edgeTime - AudioLookaheadPolicy.rebufferResumeLeadSeconds))
///
/// AE#813: a source that delivers whole segments needs more than that lead, because nothing
/// arrives until the next segment does, so it lands as far back as a join would place it
/// (`SoftwareLiveHoldback.landingHoldbackSeconds`).
nonisolated static func softwareLiveLanding(
requested: Double, window: LiveWindow,
holdbackSeconds: Double = AudioLookaheadPolicy.rebufferResumeLeadSeconds
) -> Double {
window.clamp(Swift.min(requested, window.edgeTime - holdbackSeconds))
}

/// AE#454: how close the fresh item has to be to the place it was asked for before the correcting
Expand Down Expand Up @@ -908,4 +917,20 @@ extension AetherEngine {
let target = Swift.max(floor, edge - offset)
await seek(to: target)
}

/// AE#851: the loopback's first-serve gate, waited out before AVPlayer asks for the playlist.
/// Returns when the gate does (window ready, degraded at its deadline, or cancelled by a stop),
/// so a superseded load still has to check its generation afterwards.
nonisolated static func awaitFirstLiveWindow(_ provider: VideoSegmentProvider) async {
let timeout = LiveEdgePolicy.firstServeTimeoutSeconds(edgeCushionSeconds: provider.liveEdgeCushionSeconds)
let started = DispatchTime.now()
let ready = await BlockingWork.detached(priority: .userInitiated) {
provider.waitForFirstLiveSegment(timeout: timeout)
}.value
let waited = Double(DispatchTime.now().uptimeNanoseconds &- started.uptimeNanoseconds) / 1_000_000_000
EngineLog.emit(
"[AetherEngine] AE#851 first live window \(ready ? "ready" : "not ready") after "
+ "\(LiveEdgePolicy.seconds(waited))s, before the item was attached",
category: .session)
}
}
Loading