Skip to content

fix(subtitles): forward prefetcher fills the drain lead window past the producer park (#151) - #156

Merged
superuser404notfound merged 1 commit into
mainfrom
feature/issue151-subtitle-forward-prefetch
Jul 19, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
feature/issue151-subtitle-forward-prefetch

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

Closes #151.

Problem

On direct-play sources the pump tap harvests subtitle packets only as far as the segment producer's forward park (#102), so the drainer's 60 s lead window (subtitleDrainLeadSeconds) held only ~2-3 s of cues past the playhead. A host rendering $subtitleCues in its own overlay with an ADVANCE sync offset (mkvmerge convention, negative offset) queried cues ahead of the playhead and found nothing, or saw them flash in late. Text (SRT) and bitmap (PGS) alike, since both flow through the same packet-store drain.

Fix

A VOD-only subtitle forward prefetcher: a subtitle-only side reader that fills the session SubtitlePacketStore up to playhead + subtitleDrainLeadSeconds (60 s) independent of the producer. The drainer is untouched; it already decodes to +60 s once packets exist, so $subtitleCues now actually holds that window. This is the forward-production approach preferred in the issue, covering text and bitmap.

Tests

6 new tests in Issue151SubtitleForwardPrefetchTests:

  • writer-keyed split-set assembly isolation + .pump default compatibility
  • read loop harvests to the lead edge, parks (nothing read past it while the playhead stands), resumes on playhead advance through EOF (in-memory MKV fixture, real Demuxer)
  • loop aborts on a vanished playhead provider instead of spinning
  • VOD/live + drain-target + source gating rules
  • re-anchor decision: jump with cursor yes, fresh selection no, steady tick no

768 tests / 130 suites green, strict-concurrency build clean, tvOS Simulator build green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NAPCg4tCDdSqkK6tPkNptw

…he producer park (#151)

The pump tap harvests subtitle packets only as far as the producer's
forward park (#102), so the drainer's 60 s lead window held ~2-3 s of
cues on direct-play sources and a host-applied ADVANCE sync offset on
$subtitleCues found nothing, text and bitmap alike.

Add a VOD-only subtitle forward prefetcher: a third side reader that
fills the session SubtitlePacketStore up to playhead +
subtitleDrainLeadSeconds independent of the producer. It routes every
embedded subtitle stream (all others discarded, #104), parks on the
subtitle PTS axis, follows seeks via the drain tick's jump detection,
defers open while a producer restart is in flight (#93), and positions
with the shared bounded-seek + byte-estimate rules (#112 round 10).
Split-PES PGS sets assemble under a per-writer key in the store so the
pump's in-flight set is never corrupted; overlapping completed packets
dedupe by PTS. Best-effort: on open failure or wedge the tap-fed
behavior is unchanged. The drainer itself is untouched; it already
decodes to +60 s once packets exist.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NAPCg4tCDdSqkK6tPkNptw
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.

Direct-play embedded subtitles: forward cue exposure bounded by the producer park breaks host advance-offsets (text and bitmap)

1 participant