TASK 21 slice 3: loop control in MediaVideoSource (process factory + Loop flag)

- IMediaFrameSource gains bool Looping.
- MediaVideoSource ctor takes Func<IDecodeProcess> processFactory instead of a
  single IDecodeProcess: a System.Diagnostics.Process can't be re-Start()ed, so
  each loop pass creates a fresh decoder. Decode wrapped in do-while(Looping):
  restart on natural EOF instead of raising Completed.
- Production wiring (MainViewModel media factory): passes the process factory
  AND FfmpegFrameRateProbe -- closes the slice-2b gap where production had no
  probe and therefore no pacing.
- Tests: loop test (single frame re-emits across passes, Completed only when
  loop cleared); fakes updated for the new interface member. Media tests 12/12,
  build 0 warnings.

Wiring Source.MediaIsLooping into the flag needs a manager-level per-path loop
provider -> lands with the UI-picker (acquisition) slice.

Derivative reference: looping media by restarting decode on EOF, standard in
playback/overlay tooling (OBS media source repeat).
This commit is contained in:
2026-08-31 19:52:10 -07:00
parent a2219be198
commit 881addb5b4
8 changed files with 98 additions and 28 deletions
+13 -3
View File
@@ -63,7 +63,17 @@ absent probe → no pacing). New test `MediaVideoSource_PacesFramesByProbedFps`
(fake probe + recording delay, one delay per frame ≈1ms). Media tests 5/5,
build 0 warnings.
Next (slice 3): loop control (restart decode on `Completed` when `MediaIsLooping`).
Next (slice 3): loop control — SHIPPED. `MediaVideoSource` takes a
`Func<IDecodeProcess>` process factory (a single `Process` can't be re-`Start()`ed,
so each loop pass creates a fresh decoder) and wraps the decode in a
`do…while (Looping)` restart, keyed on the new `IMediaFrameSource.Looping` flag;
Production wiring in `MainViewModel` (media factory) now passes the factory AND
`FfmpegFrameRateProbe` (closing the slice-2b gap where production had no probe →
no pacing). Loop test `MediaVideoSource_LoopsUntilLoopDisabled` (single frame
re-emits, `Completed` only when loop cleared) — media tests 12/12 (6 source + 6
manager), build 0 warnings. Open: wiring `Source.MediaIsLooping` into
`IMediaFrameSource.Looping` needs a manager-level per-path loop provider — lands
with the UI picker (acquisition) slice.
**Landmine:** a stale `testhost` can lock `ytLive.Tests`'s `ytLive.dll` and break
`dotnet build` of the test project — kill it first (`cmd.exe /c "taskkill /PID N /F"`)
@@ -73,8 +83,8 @@ pure tests run in WSL; user verifies the GUI suites on native Windows PowerShell
## Next
1. Commit slice 2b (this unit): native-FPS pacing in `MediaVideoSource` + pacing test + docs.
2. Slice 3: loop control (restart decode on `Completed` when `MediaIsLooping`).
1. Commit slice 3 (this unit): loop mechanism + process factory + probe wiring + tests + docs.
2. UI picker slice: acquire/release media sessions on add/remove AND wire `Source.MediaIsLooping` → `IMediaFrameSource.Looping` (manager-level per-path loop provider).
3. Slice 3: loop control (restart decode on `Completed` when `MediaIsLooping`).
4. UI picker slice: acquire/release media sessions on add/remove (the remaining slice-1-step-4 open end).
5. Await user push checkpoint for the pending TASK 22/21 commits.