Add synchronized Raven display buffer planning

This commit is contained in:
Meta Vens 2026-05-29 22:23:34 +01:00
commit 4be341bc3f
12 changed files with 486 additions and 3 deletions

View file

@ -51,6 +51,9 @@ reflection taps.
- The five-second default buffer is compute budget, not accidental delay.
- Loopback/reference audio is timing authority; network feeds are producers, not
clock authorities.
- `MimirSynchronizedBufferPlanner` owns aligned readout from retained buffers:
it chooses one canonical presentation time and applies source or
`clockDomainId` corrections before Fensalir/Faust consume slices.
- UI and telemetry read cached sync state; they do not run analysis.
- Native capture owns hardware calls. Runtime owns sample identity and buffer
placement.

View file

@ -183,6 +183,16 @@ a named invariant that the native runtime cannot protect yet.
instead of reusing a ring slot OBS has not acknowledged.
`scripts/build-obs-stem-plugin.ps1` stages the upstream OBS plugin template
SDK under `artifacts/obs-sdk/` and builds the plugin DLL locally.
- `MimirSynchronizedBufferPlanner` now builds one aligned presentation frame
from the live rolling buffers. It chooses a canonical presentation time inside
the shared retained window, applies source or clock-domain timing corrections,
and returns per-stream slices for cameras, network display feeds, and audio
blocks. This is the low-level Raven display/audio shape: Raven display frames
can be tagged with `clockDomainId: raven-sync`, while a Raven audio timing
signal routed into Scarlett earns the correction for that shared clock domain.
The display feed remains derived evidence, not an independent timing owner.
`Mimir.BufferSmoke --synchronized-buffer-planner-smoke` proves the aligned
local-camera, Raven-display, loopback, and mic buffer shape.
- `MimirRuntime` no longer submits the legacy direct `AquariumSplineFrame`
spectrum dashboard. Live spectrum visualization authority is the
`AquariumFieldEvidenceFrame`: Mimir declares the rolling resource, emits a

View file

@ -0,0 +1,45 @@
# Network Display Synchronization
Raven can be a low-level synchronized producer when it controls both its display
output and an audio timing signal routed into the Scarlett.
Authority map:
- Owner: `Mimir.Runtime` owns aligned rolling-buffer frames.
- Inputs: camera buffers, Raven display frames, Scarlett ASIO audio buffers, and
explicit timing corrections learned from audio evidence.
- Outputs: `MimirSynchronizedBufferFrame` slices at one canonical presentation
time for Fensalir/Faust/OBS publication.
- Derived state: Raven display timing is derived from the Raven audio sync
signal. The display feed is not a timing authority by itself.
- Forbidden writers: OBS, SRT bridge endpoints, frame-event probes, and network
receive timestamps must not decide cross-stream alignment.
- Shared path: local cameras, network display frames, mic channels, loopback
channels, and Raven audio sync channels all enter `MimirRollingStreamBuffer`
first, then the synchronized planner chooses slices.
- Deletion line: any compositor path that directly consumes Raven pixels outside
the runtime buffer/alignment path is diagnostic only.
Practical shape:
1. Raven renders a visible timing marker or encoded frame identity on the
captured display.
2. Raven emits the matching audio timing signal through its audio output.
3. That audio is physically or digitally routed into a Scarlett input beside the
mic channels.
4. Mimir decodes the Scarlett audio evidence, learns the Raven clock offset, and
applies that clock-domain correction to the `raven-display` video buffer.
5. Fensalir receives aligned buffer slices and still owns composition.
The disabled example in `config/mimir-runtime.asio.example.json` tags the
network display stream with `clockDomainId: raven-sync`. The display receiver is
expected to emit frame-event metadata with Raven source timestamps and frame
identity. The Scarlett channel carrying Raven's sync audio is the evidence path
that earns the `raven-sync` timing correction.
Smoke proof:
```powershell
dotnet run --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --synchronized-buffer-planner-smoke
```