Skip to content

rust: Port the async video frame pacing in obs-source.c to obs-source #2024

Closed

Description

@rdoupe

Unit

Port the async video frame pacing in libobs/obs-source.c.h to rust/obs-source, as a new module async_pacing.

What moves:

  • ready_async_frame:
    • the unbuffered "newest only" rule;
    • the timing jump on frame_out_of_bounds;
    • the catch-up walk, with its 2 ms duplicate guard and the MAX_TS_VAR re-anchor;
  • get_closest_frame: the first-frame rule and the last_frame_ts seed.

What stays C: da_erase, remove_async_frame, the async cache, async_mutex (the caller holds it), and the frame pointers. C copies the queue's timestamps (at most MAX_ASYNC_FRAMES) into a stack array. Rust returns how many frames to drop from the front, whether to take the first, and the new last_frame_ts. C then erases and takes in the same order as today. frame_out_of_bounds stays an inline for obs-source-deinterlace.c.h, and Rust gets its own copy.

Plan (one PR, separate commits)

  1. A behaviour-neutral move into libobs/obs-source-async-pacing.c.h, as a hidden function.
  2. Characterization: test_async_frame_pacing_steps, against a model queue. It covers:
    • unbuffered with 1, 2 and 30 frames;
    • last_frame_ts == 0;
    • the jump at MAX_TS_VAR ± 1, both ways;
    • the 2 ms guard at its edges;
    • the re-anchor inside the walk;
    • timestamps going backwards, and a system clock that goes backwards;
    • 30 frames all in the past.
  3. RED, then GREEN: the safe Rust core plus shims, in a libobs.ported-source-async-pacing group. Exported symbols are unchanged.
  4. Tier 3 parity against the original C, plus a deliberate-break check and port_comparison numbers. Parity covers:
    • a proptest over full-range u64 queues of 1–30 frames;
    • sequences modelling 23.976, 25, 29.97, 30, 50 and 60 fps sources into 30 and 60 fps canvases, buffered and unbuffered, with jitter and jumps.

These real-libobs tests must stay green on every lane: test_media_restart_stale_frame, test_media_restart_first_frame, test_async_delay_audio and the v4l2 tests.

Activity

  1. rdoupe commented on Oct 24, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2024.

  2. added
    claimed
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions