Skip to content

rust: port async_tick and its filter_frame and get_closest_frame steps to obs-source #5929

Done

Description

@rdoupe

async_tick() in libobs/obs-source.c.h (~528-556 on master, 90aaafe) and its two static steps, filter_frame() (~502) and get_closest_frame() (~1677), are still C. They are what obs_source_video_tick() runs once a frame for every async source. Every decision in them is already Rust: the route (obs_source_video_tick_async_route(), obs-source-video-tick.c), the frame pacing (obs_source_async_pacing(), obs-source-async-pacing.c) and the async filter chain (filter_async_video(), #5917). What is left is the glue on the source's fields, async_mutex, the frame queue and the frame refs.

Behavior the port keeps, call for call:

  • async_tick(): read the frame time from the video stats before the lock; under async_mutex, ask the route with deinterlacing_enabled(); DEINTERLACE runs deinterlace_process_last_frame(), CLOSEST releases cur_async_frame through remove_async_frame() and takes get_closest_frame(). Then store last_sys_timestamp, ask the route again (it reads deinterlace_mode a second time), filter prev_async_frame only on DEINTERLACE, then cur_async_frame, and set async_update_texture from set_async_texture_size() when a current frame is left.
  • filter_frame(): on a frame, increment refs, run filter_async_video(), decrement refs on what comes back (the frame the chain returned, not the one passed in), store the result. No frame: the slot is stored as NULL.
  • get_closest_frame(): no queued frame returns NULL. Otherwise copy each queued timestamp (heap-allocated past MAX_ASYNC_FRAMES, the stack array otherwise), ask the pacing, erase and remove_async_frame() the dropped frames off the front one at a time, store last_frame_ts, and take the front frame when the pacing says so.

Plan, one PR into obs-source (the shape of #5916 and #5926):

  1. Extract the three functions verbatim into libobs/obs-source-async-tick.c.h (live core-source group). No behavior change.
  2. Tier 1 RED in obs-source's existing category binary against a todo!() core over a trait for the field reads/writes, the queue, the mutex and the calls.
  3. GREEN: safe core in obs-source, the export as C ABI in ffi/, a field shim with no EXPORT, the extracted file moved to a reference-only ported group.
  4. Tier 3 parity against the original C in obs-c-oracle: the same queue, timestamps, routes and filter results through both, comparing fields, the queue, refs, calls and their order.
  5. Tier 2: a new cmocka test of an async source through a tick (empty queue, frames dropped and taken, a filter that replaces or drops the frame, the deinterlace route) through the hybrid libobs and the C reference. The existing async tests run unchanged.

Activity

  1. added
    enhancement
    port
    on Nov 29, 2026
  2. rdoupe commented on Nov 29, 2026

    @rdoupe
    CollaboratorAuthor

    /ready

  3. added
    ready
    on Nov 29, 2026
  4. rdoupe commented on Nov 29, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #5929 port of async_tick and its filter_frame and get_closest_frame steps (extract, Tier 1 RED, GREEN, Tier 3 parity, Tier 2). No other issues in the batch; first PR (draft, at the RED commit) today.

  5. added a commit that references this issue on Nov 29, 2026
    1eeba27
  6. added a commit that references this issue on Nov 29, 2026
    83ba791
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementportready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions