Skip to content

Player: a starved direct-play stream pauses and shows Buffering instead of slow motion - #1441

Merged
GLinnik21 merged 6 commits into
mainfrom
feat/progressive-hold-debt
Nov 18, 2026
Merged

GLinnik21 merged 6 commits into
mainfrom
feat/progressive-hold-debt

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What

When a direct-play (progressive Original) Feed stream is starved by a link slower than the
file, the player now pauses and shows Buffering until the queue is full, instead of letting the
TV play in slow motion and then catch up by dropping frames.

  • Begin rule (ClockDebt, a CUSUM on clock debt): S ← max(0, S + (Δwall − Δpos) − k·Δwall),
    k = 0.05; hold when S ≥ 100 ms. S resets while the video queue holds more than 1 MiB and is
    disarmed while priming, seeking and before the first picture. A dead link (position callbacks
    stop) holds through the silence arm.
  • Release: the video or audio queue reaches its byte cap, or end of stream. No new queue
    headroom.
  • Scope: Quality = Original only. Quality = Auto keeps its existing switch from Original to
    HLS; a fixed-quality re-encode and trailer previews are not held.
  • A viewer Pause/Play inside the hold reuses the held-prime paths from Player: a Play pressed while a held prime waits now resumes playback #1439.

Why these constants (TV measurements, mock server)

  • Under a steady deficit Starfish presents at delivered/local bitrate (slow motion) and later
    repays the debt by dropping frames; a reserve threshold cannot detect it.
  • Resume drops scale with the debt at fire: drops ≈ 23.6 × debt (s), R² 0.96 over 33 holds.
    Trigger 0.4 s → ~12 frames per resume, 0.2 s → ~6.6, 0.1 s → ~3.6.
  • At 0.1 s: zero holds on healthy Eclipse (4K DV) and 4K HEVC runs; on a 0.39× throttle it holds
    11 times in 180 s, each ending full after ~10.5 s, and plays normally after the link recovers.
  • A 24 MiB headroom grant cost ~27 MiB of free memory on the set, so no headroom.

Tests

  • ClockDebt table tests (11), failing on the tests-first commit's stub.
  • Hostsim rig (progressive_rebuffer_pump_tests.rs): a starved stream is held and reads
    Buffering; a 0.4× link holds; a dead link holds through the silence arm; EOF releases; a viewer
    Pause/Play inside a hold stays held; never held for a full-rate stream, a link that keeps pace,
    a preview, an Auto-watched Original, or a fixed-quality re-encode.
  • held_prime_play rows for the progressive hold.

Gates

  • make test-crate C=plx_playback_contract: test result: ok. 54 passed; 0 failed
  • make test-crate C=plx_play_feed: test result: ok. 351 passed; 0 failed
  • make test-crate C=plx_media: test result: ok. 2152 passed; 0 failed; 104 ignored
  • make test-hostsim C=plx_media T=progressive_rebuffer: 22 passed, then the dead-link test fixed and passing alone.
  • make check-nodef: ok. ci/check-deps.sh, module layers, ledger ratchet, list-caps: green.
  • Full make check, the full hostsim pass and the ARM build: gated by CI (the local runs were
    refused by the disk preflight).

TV verification (this head's debug build, mock server, Guest)

  • Slow link (0.39x, 180 s): 11 holds, all reason=full, 2-6 frames dropped per resume (mean 3.9); none before the throttle or after it lifted.
  • Healthy link (240 s): 0 holds, 0 drops.
  • Dead link (20 s blackhole): one hold, held 20.8 s, resumed full, no reload; the HUD shows the Buffering spinner during the hold.
  • End of file on a slow link: 5 holds, the last released reason=eof (EOS pushed while held, then Play); playback reached 564 s of 566 s and ended normally.
  • Quality = Auto on a slow link: auto: Original -> HLS, 0 progressive holds.

🤖 Generated with Claude Code

GLinnik21 and others added 6 commits November 17, 2026 23:27
…Buffering

The clock-debt detector (playback-contract clock_debt) lands as an inert stub with its table tests,
and the hostsim rig for a starved direct-play stream is added: a link at 0.4x, a dead link, the end of
the stream, a viewer Pause/Resume inside a hold, and the streams that are never held (start, healthy,
keeping pace, preview, Auto-watched, viewer Pause). Everything holding-related is red against this
tree; the detector and the hold follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A direct-play (Quality=Original) Feed stream whose link is slower than the file
played in slow motion over an empty queue and then dropped frames to catch up.
It is now held like an HLS rebuffer: the sink is paused, the viewer sees the
existing Buffering UI, and playback resumes when the video or audio queue is
full or the stream ends.

- ClockDebt (playback-contract): a pure CUSUM over the native position callback,
  S <- max(0, S + (dwall - dpos) - k*dwall), k = 0.05, fire at S >= 100 ms, reset
  whenever the video queue holds more than 1 MiB, disarmed until the first
  picture, while priming and during a seek.
- play-feed: the begin rule steps ClockDebt once per position callback at the
  unity rate; the dead-link arm (native_clock_stopped over the further lane's
  reserve) also holds. The release is `queue full || EOF` with no runway
  constant. One info line per hold and per resume.
- HoldRoute { SegmentedHls, ProgressiveOriginal, Unheld } carries the policy:
  segmented HLS is unchanged; Quality=Auto's supervised Original, a fixed
  quality's progressive re-encode and a trailer preview are never held.
- A viewer Pause/Play during the hold takes the paths PR #1439 gave the HLS
  rebuffer hold (the hold keeps its own certificate; its Play clears the
  Buffering mirror).
- ffi_host::silence_clock_for_test: a test-only way to stop the host position
  thread without a Pause verb, so the dead-link arm is reachable in the rig.

Docs: player/CLAUDE.md and docs/adaptive-playback.md section 5.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…dit)

The hold's certificate is a full queue or the end of the stream, not a runway; a
non-1x rate disarms only the clock-debt arm; Original is the default only for a
profile saved before Auto existed; the Auto supervisor's exits are section 7; the
rebuffer read-out is no longer HLS-only; a Fired ClockDebt is not reset by a gap.
Comments and Markdown only.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…must not begin a hold

PR #1441's hostsim job failed `a_dead_link_is_held_through_the_silence_arm`, and the
fw-compat review found a hold that can begin when its own release is already true.
This commit holds only tests and test-support, so it is RED against the pump:

- the dead-link test no longer waits on the real clock: the host's own position thread
  is hushed (`Rig::hushed`, `ffi_host::hush_ticker_for_test`, which also stops its real-time
  stamps from fighting the virtual wall) and the observation is aged with explicit stamps;
- new: a link dying in the millisecond of the watch's restart, and one dying before the
  first callback after a viewer's Resume, must be held;
- new: with the audio queue at its cap and the sink refusing audio
  (`ffi_host::refuse_feed_lane_for_test`), no hold may begin (no Pause then Play in one tick).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…releases at once

1. The dead-link arm required a position callback STRICTLY after the clock watch's last
   restart (`tick_since_watch_restart`, a helper this branch added; the HLS rule never had
   it). A link that died before the first callback after a viewer's Resume or a hold's Play,
   or in the very millisecond of the restart, was never held: a frozen picture and no
   Buffering. The progressive arm now reads the silence exactly as the HLS rule does, from
   the later of the last callback and the last restart (`silence_between`, wrap-aware), and
   the reserve test in `native_clock_stopped` keeps a resume that leaves a full queue from
   reading as dead. `tick_since_watch_restart` is deleted.
2. A hold could begin when its own release was already true (a video or audio queue at its
   byte cap), giving Starfish a Pause and a Play in the same tick, repeatedly. A parked queue
   now disarms the detector like a finished demuxer (`ProgressiveStall::queue_parked`).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…the tail re-primes)

CI showed the real Pause/Resume variant never held: a viewer's Resume re-primes the clock and
the nearly empty queue at the tail never primes, so the detector stays disarmed for a reason
unrelated to the silence rule. The rig now sets the state the Pause or a hold's Play leaves
(last callback older than the watch's restart) directly.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@GLinnik21
GLinnik21 marked this pull request as ready for review November 18, 2026 02:21
@GLinnik21
GLinnik21 merged commit 9f5ff48 into main Nov 18, 2026
13 checks passed
@GLinnik21
GLinnik21 deleted the feat/progressive-hold-debt branch November 18, 2026 02:22
nphil added a commit to nphil/Marquee that referenced this pull request Nov 18, 2026
A film played at Original quality over a link slower than the file kept
playing as its queues ran dry: the picture ran in slow motion and the sink
then dropped frames to catch up. Only HLS had a rebuffer hold.

The pump now holds a progressive stream the same way (one Pause, the
Buffering read-out, the try_prime Play). The hold begins when the native
position falls more than 100 ms behind the wall, net of a 5 % drift
allowance, while the app's video queue holds under 1 MiB, or when the
native clock stops over a remnant it will never spend. It releases on a
full video or audio queue or the end of the stream, never on a runway.
The debt constants are upstream's, measured on its TV, not yet on this one.

stall_watch stays the reporter and the restarter of a source parked on a
full lane; a hold never begins while a queue is at its cap, so the two never
act on one stall. A seek takes the clock from a hold at once. The silence
clock is wrap-safe and the position tick is published last, with Release.

A Play pressed while a held prime waits (plxnative#1439) needs no port: resume
already defers the Play to the hold's release.

Ported from upstream 9f5ff48 (Player: a starved direct-play stream pauses and shows Buffering instead of slow motion (plxnative#1441)).
tiper added a commit to tiper/fin-native that referenced this pull request Nov 18, 2026
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.

1 participant