Repository navigation
fix(subtitles): forward prefetcher fills the drain lead window past the producer park (#151) - #156
Merged
superuser404notfound merged 1 commit intoJul 19, 2026
Conversation
…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
superuser404notfound
deleted the
feature/issue151-subtitle-forward-prefetch
branch
July 19, 2026 16:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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$subtitleCuesin 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
SubtitlePacketStoreup toplayhead + subtitleDrainLeadSeconds(60 s) independent of the producer. The drainer is untouched; it already decodes to +60 s once packets exist, so$subtitleCuesnow actually holds that window. This is the forward-production approach preferred in the issue, covering text and bitmap.resetAndDecodewith an existing cursor -> re-anchor at the new playhead). A fresh selection starts it with the Fast language loading optimization: LoadOptions.preferredAudioLanguage / preferredSubtitleLanguage — select a track by language during the load open #73 resume anchor.sideReaderSeekBudgetSeconds, verified byte-estimate fallback (Error selecting PGS subtitles #112 round 10)..pump/.prefetch) in the store, so the two writers can assemble the same stream concurrently without corrupting each other's in-flight display set. Completed packets dedupe by PTS via the existing same-PTS replacement.Tests
6 new tests in
Issue151SubtitleForwardPrefetchTests:.pumpdefault compatibilityDemuxer)768 tests / 130 suites green, strict-concurrency build clean, tvOS Simulator build green.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NAPCg4tCDdSqkK6tPkNptw