Skip to content

test: Run the output stream delay end to end through libobs - #1578

Merged
zackees merged 1 commit into
obs-rust:masterfrom
rdoupe:test/output-delay-e2e
Oct 21, 2026
Merged

zackees merged 1 commit into
obs-rust:masterfrom
rdoupe:test/output-delay-e2e

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Refs #1546 (follow-up to #1567: an end-to-end test of the ported delay)

What and why

#1567's deliberate-break check showed that no test set a stream delay through the libobs that ships. test_output_delay compiles obs-output-delay.c.h into itself, so with the Rust core broken, every end-to-end test still passed against libobs-with-rust. Only the Tier 3 parity tests caught the break. This PR adds test/cmocka/test_output_delay_e2e.c, which drives a real encoded output with a delay through real libobs. It is test-only: no change to libobs, to Rust code or to an existing test.

  • How it runs. obs_startup(), then an audio encoder and an audio-only encoded output, both registered in the test (like test_output_interleave_restart). A real-time audio_output_open() thread feeds the encoder silence, and each packet's encode time is recorded. No video, no graphics, no network. On Linux obs_startup() needs a display, so the test is wrapped in xvfb-run the way test_audio_controls is, and it skips without a display.
  • Timing. The delayed cases use a 1 s delay. All checks are orderings or lower bounds; there are no upper bounds. The whole test takes about 10-13 s.
  • Registration. A tests.d/test_output_delay_e2e.cmake fragment. No Cargo C-test manifest entry: the native driver runs without a display, and no manifest test calls obs_startup().
  • The 5 cases:
    • delayed_start_packets_and_stop: the output's start() runs at least 1 s after obs_output_start(), and not before it returns. obs_output_get_delay() is 1 and obs_output_get_active_delay() is 0 before the start, then 1. Every packet reaches the output at least 1 s after it was encoded, in pts order from the first one, with none missing, and none before start(). obs_output_stop() signals stopping at once. The output's stop() runs at least 1 s later, with the time the stop was asked for. Every packet queued before the stop was sent; none encoded after it was. Once the output deactivates, the active delay is back to 0.
    • force_stop_skips_delay: obs_output_force_stop() runs stop() before it returns (ts 0). The output deactivates, and the queued second of packets is dropped, not sent.
    • no_delay_passes_through: with no delay, start() and stop() run inside obs_output_start() and obs_output_stop(), and packets pass straight through.
    • preserve_holds_queue_through_reconnect: with OBS_OUTPUT_DELAY_PRESERVE, the output reports OBS_OUTPUT_DISCONNECTED itself (no network) and reconnects after a 2 s retry wait. Packets encoded before the outage reach the output after it, no packet goes missing, and the active delay grows to at least 2 s.
    • no_preserve_drops_due_packets_through_reconnect: without the flag, during a 1 s retry wait, packets keep coming due and are dropped. The output receives a gap, still in order, and the active delay stays at 1.

RED → GREEN

  • No RED commit: the test covers existing behaviour and passes on master in both libraries. c66cc66 test: Run the output stream delay end to end through libobs.
  • Runs (headless: private Xvfb, private D-Bus, fresh HOME), 5 runs of the test in each build tree against each library:
Lane libobs libobs-with-rust
C (ENABLE_RUST_LIBOBS=OFF) 5/5, 12.56-12.58 s 5/5, 12.56-12.58 s
Rust (ENABLE_RUST_LIBOBS=ON) 5/5, 12.58-12.59 s 5/5, 12.56-12.59 s
  • The swap is now visible end to end. Mutants of the Rust core (rust/obs-output/src/delay.rs), each rebuilt into libobs-with-rust and run against it (mode ON): 6 of 8 fail the test.
    • Killed: the delay halved in the pop; preserve ignored; the delay not grown while reconnecting; the stop run with ts 0 instead of its own time; the active-delay getter returning 0; delivery without the capturing check.
    • Survived: >= for the strict > in the pop, and one pop per call instead of the loop. Neither shows on a real clock. The first differs only when an entry's age equals the delay to the nanosecond. The second only lags each delivery by one packet interval. The deterministic Tier 1/2/3 tests (test clock) cover both.
  • Full cmocka suite, both build trees, each against both libraries:
Lane libobs libobs-with-rust Exported symbols
C (ENABLE_RUST_LIBOBS=OFF) 343/343 343/343 IDENTICAL (1766)
Rust (ENABLE_RUST_LIBOBS=ON) 343/343 343/343 IDENTICAL (1766)

No test was skipped or failed to run. test_output_delay_e2e takes 9.6 s inside the parallel suite.

  • uv run ci/local_gate.py --lane lint: passed. clang-format and gersemi are clean on the new files.
  • Real app: not applicable (test only).

Windows/macOS: not built there. The test is portable C with no host conditionals. It uses only public libobs API (obs.h, util/platform.h, util/threading.h), and runs where test_output_start_twice runs.

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (test only; it passes on master)
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): not applicable
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): not applicable (no port here)

test_output_delay compiles obs-output-delay.c.h into itself, so no test
set a stream delay through the libobs that ships. With the Rust delay
core broken, every end-to-end test still passed against
libobs-with-rust; only the Tier 3 parity tests caught it.

test_output_delay_e2e registers an audio encoder and an encoded output,
feeds the encoder from a real-time audio thread, and sets one-second
delays. It checks that packets reach the output at least the delay
after they were encoded, in order and without gaps; that the output's
start() and stop() run after the delay, the stop with the time it was
asked for; obs_output_get_active_delay(); that a force stop skips the
delay and drops the queue; and both reconnect paths: with
OBS_OUTPUT_DELAY_PRESERVE the queue is held and the delay grows by the
outage, without it the packets due during the outage are dropped. The
checks are orderings and lower bounds only, so a slow runner cannot
fail them.

Refs obs-rust#1546
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants