Repository navigation
fix(playback): carry a seek target onto the source axis (#107) - #573
superuser404notfound merged 1 commit into
Conversation
…notfound#107) `SoftwarePlaybackHost.seek(to:)` takes the session axis — the axis the host publishes positions on — and handed it unchanged to four things that speak the source's own timestamps: `Demuxer.seekBounded`, the packet store's `beginSeek`/`prepareSeek`/`endSeek`, the decoder's skip threshold, and `AudioOutput.seekClock`. For a zero-based source the two axes coincide and nothing was ever wrong. For a mid-stream-joined one — the case superuser404notfound#107 added `sessionZeroSeconds` for — they differ by hours, and two things broke at once. The demuxer was asked for a timestamp before the file's first packet and clamped to its start, so a seek rewound. And the packet store's reservoir, measured as `storedVideoSeconds - sourceClock`, read as the whole offset: the producer saw hours of buffer, stopped reading, and the consumer starved with nothing to report — no error, no stall, just a standing picture and a clock running past the end of the file. The conversion is `SWClockAnchorPolicy.sourceSeconds(forSession: sessionZeroSeconds:)`, the inverse of the mapping the host already applies when publishing `currentTime`, and the identity when the offset is zero. `currentTime` stays on the session axis. Test plan - `swift test`: 3132 tests, all green, including four new cases on the conversion (identity, the carry, a round trip against the published position, and refusing a target that cannot be expressed). - Device: Apple TV 4K (3rd gen), tvOS 26, a 64.5 s MPEG-TS capture on an SMB share whose first PTS is 24549.835 s, played through AetherEngineSMB. Before: `packet cache seek result=miss resident_bytes=0`, `aLead=24549.8`, `enq=+0 disp=+0` on every diagnostic tick until the session was torn down. After: `target_s` lands on the source axis, `result=hit resident_bytes=44565599`, `aLead` back to 1.96 … -0.04, and seeking forwards and backwards repeatedly plays on from the new position. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
8b04315
into
superuser404notfound:main
|
Merged, thank you. The diagnosis is exactly right, and the write-up made it possible to check rather than take on trust. Three things were worth verifying before this went in, and all three hold:
Two changes were made on merge, neither of them to the logic: the CHANGELOG entry was rebased onto the two that landed ahead of it, and three em-dashes were replaced, since the house style does not use them. One thing the review turned up that this PR does not cover, mentioned here because it is the same root cause. This will go out in the next release; there is no need to run anything further on it in the meantime. |
superuser404notfound#107, superuser404notfound#416) A software VOD seek opened the pump's coverage run at the session-axis target while `subtitleDrainTick` reports that reader's progress from `sourceTime`. On a zero-based source the two coincide, so nothing was ever wrong. On a mid-stream-joined one the anchor sits the whole offset below every note that follows it, and `noteReach` has no unannounced-advance guard (only `noteProgress` does), so the first note stretches one run across ground nobody read. `SubtitleHarvestCoverage.covers` then answers yes to anything, and `subtitleLandingGroundIsRead` admits exactly the stale PGS arrival superuser404notfound#416 exists to refuse. `SoftwarePlaybackHost.sourceSeconds(forSession:)` exposes the conversion `seek(to:)` already makes for everything inside the host, so the anchor and the notes name the same axis. Found while reviewing superuser404notfound#573, which fixes the same axis confusion inside the host. swift test: 3163 swift-testing tests and the XCTest half green, exit 0. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F
A seek on a source whose first packet is not at zero rewinds to the start of the file, and then the reader starves with nothing reported.
What happens
SoftwarePlaybackHost.seek(to:)takes the session axis — the axis the host publishescurrentTimeon — and hands it unchanged to four things that speak the source's own timestamps:Demuxer.seekBounded(to:)beginSeek/prepareSeek/endSeek(sourceClock:)videoDecoder.skipUntilPTSandrenderer.setSkipThresholdAudioOutput.seekClock(to:)For a zero-based source the two axes coincide, so nothing was ever wrong. For a mid-stream-joined one — the case #107 introduced
sessionZeroSecondsfor — they differ by however far into the broadcast the source was opened, and two things break at once:reservoirSecondsLocked()measuresstoredVideoSeconds - sourceClock. With the store on the source axis andsourceClockon the session axis, the reservoir reads as the entire offset. The producer concludes it has hours of buffer, relaxes, and stops reading; the consumer then starves. Nothing fails, so nothing is logged and no recovery path can fire — the picture simply stands while the clock runs on past the end of the file.The change
One conversion at the top of
seek(to:), applied to everything that speaks the source axis.currentTimestays on the session axis.SWClockAnchorPolicy.sourceSeconds(forSession:sessionZeroSeconds:)is the inverse of the mapping the host already applies when publishing the position, and the identity when the offset is zero.liveScrubStillin the same file already makes exactly this conversion withsessionStartPts, and says so in its doc comment — the VOD path was simply missing it.Test plan
swift test— 3147 tests green, including four new cases on the conversion: identity without an offset, the carry itself, a round trip against the position the host publishes, and passing a target through rather than making it worse when it cannot be expressed.AetherEngineSMB.result=miss resident_bytes=0result=hit resident_bytes=44565599aLead=24549.8aLead=1.96 … -0.04enq=+0 disp=+0on every tickSeeking forwards and backwards repeatedly, and resuming at a stored position, both behave.
How it was reached
Syravo now records live television to an SMB share and plays it back through
AetherEngineSMB, which is what produced a source with a non-zero timestamp origin in the first place. Happy to adjust the shape of the fix if you would rather the conversion sat somewhere else.