Skip to content

sim: the host sink reports the pipeline's end-of-stream - #925

Merged
GLinnik21 merged 1 commit into
mainfrom
sim-pipeline-eos
Oct 22, 2026
Merged

GLinnik21 merged 1 commit into
mainfrom
sim-pipeline-eos

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

What the simulator could not do

Follow-up to #865, which made a film end on the pipeline's own end-of-stream (type=28, Shared::pipeline_eos) because a film whose audio outlasts its video never brings the playhead within a second of the container's duration.

The simulator's HostSink (rust-modules/media/src/player/ffi_host.rs) clamps its clock to the highest VIDEO pts it was fed and never sent a type=28. A film whose audio outlasts its video therefore stalled at the video tail on the simulator exactly as on the television, and #865's new arm could not fire there.

What it does now

  • sf_push_eos latches the push.
  • Once the clock has played out to the last fed video frame, the ticker sends type=28 num=1 str=true through the real sf_on_event (never by writing SHARED), once per pushed EOS. A paused clock sends nothing, and nothing is sent before an EOS is pushed.
  • The latch is cleared wherever the fed timeline restarts: Clock::rewind (which sf_load, sf_flush, sf_unload, sf_destroy and sf_quarantine all call) and sf_seek_ms.
  • Clock::tick is split out of the ticker thread so a test can take a tick on its own thread.
  • The stale comment above the pump's end-of-stream block now names Shared::pipeline_eos. Nothing else in player: a film ends on the pipeline's end-of-stream #865's code changed.

Device evidence the plant mirrors

Both show the same order: type=28 arrives after the last video frame is presented, while the clock stays at the video tail.

  • A contributor's LG C1 (webOS 6.5.3), from player: a film ends on the pipeline's end-of-stream #865: the film's audio ran 3 s past its last video frame, the clock stopped at 5894 s of 5897 s after the EOS, and smp_cb type=28 num=1 str=true was the only sign the pipeline had finished.
  • The dev TV (webOS 4.10.2, major 4, ACB route), tests/run.py --pipeline --filter pipe_finish_eos with a 720x480 H.264 + AC3 clip whose video ends at 20 s and audio at 23 s.
    • Build before player: a film ends on the pipeline's end-of-stream #865 (ffc9c44dd): EOS pushed at true EOF, remaining audio refused (feed a#800 ... fed=21979000000 reply=e), clock stuck at pos=19s, then smp_cb type=28 num=1 str=true, then nothing. finished FAILED, max_stall 36 s.
    • main at 60538b68: EOS pushed at true EOF -> smp_cb type=28 num=1 str=true -> smp: the pipeline reached end-of-stream -> EOS reached: playpos=19s/23s -> ended -> stop_bufferfeed: torn down. PASS.

Red, then green

player::pump::end_of_film_tests::a_film_whose_audio_outlasts_its_video_ends_on_the_host_sink drives the real feed lanes and the real pump against HostSink (video AUs to 20 s, audio AUs to 23 s, duration 23 s, a real host Load so the callback gate is open). It never sets pipeline_eos or ended. Phase one runs the clock to the video tail with the demuxer still producing and asserts nothing was sent; phase two completes both lanes, lets the engine push the EOS, and asserts player::ended(). The sink-level tests in ffi_host.rs grade the latch (once per push, waits for the clock, silent while paused, withdrawn by a rewind, flush, seek or unload).

Without the plant (make test-hostsim C=plx_media T=a_film_whose_audio_outlasts_its_video_ends_on_the_host_sink):

the film never ended: video ran to 20s, audio to 23s, and the pipeline's clock stopped at the last picture: playpos=19958ms duration=23000ms eos_pushed=true pipeline_eos=false ended=false clock=19958ms running=true stage_streaming=true pending_video=false feed_allowed=true seek_pending=-1
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1921 filtered out; finished in 0.01s

With it:

test player::pump::end_of_film_tests::a_film_whose_audio_outlasts_its_video_ends_on_the_host_sink ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1925 filtered out; finished in 0.00s

Full make test-hostsim C=plx_media: test result: ok. 1862 passed; 0 failed; 64 ignored; 0 measured; 0 filtered out; finished in 42.28s.

Simulator run, real demuxer

macOS simulator, plxnative-clocksink, a 640x360 H.264 + AAC clip whose video ends at 20 s and audio at 23 s (container duration 23.023 s), served by tests/serve_fixtures.py, a synthetic token and tests/mock_pms.py. No real account.

Before (simulator built from unmodified main): the playhead sits at pos=19s with play=0pm for the rest of the run (37 heartbeats), and the log has no smp_cb type=28 and no EOS reached. The stop_bufferfeed: torn down at the end of that log is the harness's SIGTERM at 60 s, not the film ending.

EOS pushed at true EOF
loop=59 route=player overlay=none pos=19s play=0pm vtick=5 vgap=210ms fps=60 ...
loop=60 route=player overlay=none pos=19s play=0pm vtick=5 vgap=207ms fps=61 ...

After (this branch):

EOS pushed at true EOF
loop=60 route=player overlay=none pos=18s play=1021pm vtick=5 vgap=208ms fps=60 ...
smp_cb type=28 num=1 str=true
smp: the pipeline reached end-of-stream
EOS reached: playpos=19s/23s → ended
stop_bufferfeed: torn down (native Unload epoch=1 continues off-frame)

Verification

On the committed tree (git status --short empty before and after):

  • make check: exit 0. Its hostsim pass for plx_media: test result: ok. 1862 passed; 0 failed; 64 ignored; 0 measured; 0 filtered out; finished in 90.63s. For the application crate (plxnative_modules): test result: ok. 1038 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 72.86s. Its plain pass for plx_media: test result: ok. 1703 passed; 0 failed; 64 ignored; 0 measured; 0 filtered out; finished in 48.05s.
  • make check-nodef: Finished dev profile with no errors.
  • Not covered: the television. This changes only the simulator's sink; whether type=28 arrives is already measured on two devices above. The ARM cross-build does not compile ffi_host.rs.

Left alone: tests/README.md, "Playing to the END", still says the pump gates EOS reached on eos_pushed && pos >= dur - 1s; that has not been true since #865.

🤖 Generated with Claude Code

#865 made a film end on the pipeline's own end-of-stream (type=28), but the simulator's
HostSink never sent one: its clock stops at the last fed VIDEO pts, so a film whose audio
outlasts its video hung there exactly as on the television, and #865's arm could not fire.

sf_push_eos now latches the push; once the clock has played out to the last fed video frame,
the ticker sends type=28 num=1 str=true through the real callback, once per pushed EOS. The
latch is cleared wherever the fed timeline restarts (Clock::rewind, sf_seek_ms). Clock::tick
is split out of the ticker thread so a test can take a tick on its own thread.

A hostsim regression test drives the real feed lanes and the real pump against HostSink
(video to 20 s, audio to 23 s, duration 23 s) and asserts player::ended(); it also grades
that nothing is sent before an EOS is pushed. Sink-level tests grade the latch.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 8be69a8 into main Oct 22, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the sim-pipeline-eos branch October 22, 2026 15:28
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