Skip to content

rust: Port output pause plan #3020

Closed

Description

@rdoupe

Unit

libobs/obs-output.c.h: the pause plan of obs_output_pause(), obs_encoded_output_pause() and obs_raw_output_pause() (the gates, which encoders' pause records are locked and in what order, the all-or-nothing check over the records, the pause time snapped to the video frame grid, and the start time or the end and offset each record gets), moved to libobs/obs-output-pause.c.h and ported to rust/obs-output (module output_pause, next to output_reconnect and output_slots).

Phase and position

Phase 2 libobs core, outputs (core-output group), after the output reconnect policy port (#2990, merged). Tracking: #4.

Dependencies and existing tests

  • Depends on nothing open; the output reconnect, start, stop and slots ports have merged.
  • No characterization yet: test_output_pause_steps (cmocka, the moved file on its own) lands first, pinning pause and unpause with one video and two audio encoders (times and offset), one encoder whose record isn't clear (the whole pause fails and no record changes), an encoded output with audio encoders only (always fails: characterized, not endorsed), a raw output, the three refusal gates, and the grid snap for last_video_ts 0, a clock on the grid and one frame past it.

Notes

  • What moves are the decisions on plain values: whether the output can pause, the already-in-that-state answer, which slots' records are locked, the pause time from the last video timestamp, the clock and the frame interval, whether a record can start or stop a pause, and the end time and offset a record gets. obs-output.c keeps obs_output_valid(), every atomic load and store on active and paused, every pause.mutex lock and unlock (in the order the core marks, released in reverse), os_gettime_ns() and the read of the frame interval where they are, get_first_video_encoder_index(), the record stores, the pause/unpause signals and the log. Each read stays where it is.
  • Intentional differences, fixed in the port and listed in its parity test:
    1. One encoder can sit in two audio slots (or two video slots): the setters check only the slot being set. obs_encoded_output_pause() then locks the same encoder's plain pause.mutex twice and the caller hangs. The port locks, checks and updates each distinct encoder once.
    2. The pause time divides by obs->video.video_frame_interval_ns, which stays 0 until video is first set up, so a raw output that can pause in a host that never reset video divides by zero. The port uses the clock as the pause time when the interval is 0.
      Both are reachable only from plugins, scripts and libobs hosts; the frontend sets one encoder per slot and always resets video.
  • Threads: the encoders' own pause checks (video_pause_check, audio_pause_check) read these records under the same mutexes; the core holds no state and is asked under the locks C already holds.

Activity

  1. added
    enhancement
    port
    on Oct 30, 2026
  2. rdoupe commented on Oct 30, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #3020.

    1. Move: the pause decisions of obs-output.c into libobs/obs-output-pause.c, behaviour-neutral, checked with a move harness (gcc and clang, -O0/-O2, ASan/UBSan, planted mutants).
    2. Characterize: test_output_pause_steps against the moved C.
    3. RED: obs_output::output_pause Tier 1 tests on todo!() stubs.
    4. GREEN: the core and its C shims in a libobs.ported-output-pause group, with the two intentional differences in the issue (each distinct encoder locked and updated once; a frame interval of 0 gives the clock as the pause time).
    5. Tier 3: the original C as an oracle, exhaustive over slot layouts with repeated encoders and every record state, proptests over clocks, intervals (0 included) and offsets, with the mutation check.
    6. Docs: rust/README.md, naming.md, the crate description, and a port_comparison bench.

    Draft PR once the RED commit exists, today.

  3. added
    ready
    on Oct 30, 2026
  4. rdoupe commented on Oct 30, 2026

    @rdoupe
    CollaboratorAuthor

    Fixed by the output pause plan port (PR #3024, merged): the pause decisions of obs-output.c (which encoders' pause records are locked and updated, the pause time on the video frame grid, each record's start, end and offset) now run in Rust as rust/obs-output output_pause, with the two intentional differences (each distinct encoder locked once; a frame interval of 0 uses the clock as the pause time).

    Left: nothing of this unit. The encoders' own pause checks (video_pause_check() and audio_pause_check(), which read the records this port writes) are the next unit, tracked in #3033.

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