Repository navigation
Closed
Labels
enhancementNew feature or requestportPort a C unit to Rust (four-tier policy)readyMeets the definition of Ready; claimable
Description
Unit
libobs/obs-encoder.c.h: the encoder pause and unpause checks of video_pause_check() and audio_pause_check() (whether a paused encoder drops a video frame or ends its pause on it; where an audio buffer is cut at the pause start, cut at the pause end, dropped or passed), moved to libobs/obs-encoder-pause.c.h and ported to rust/obs-output (module encoder_pause, next to encoder_audio_start and encoder_packet_ts).
Phase and position
Phase 2 libobs core, outputs (core-output group), beside the output pause plan port (#3020, which writes the pause records these checks read). Tracking: #4.
Dependencies and existing tests
- Shares the core-output unity group file and the sorted lists with the open output pause plan PR (obs-output: Port the output pause plan #3024); whichever lands second rebases. No other open PR touches
obs-encoder.c.hor the group. - No characterization yet:
test_encoder_pause_steps(cmocka, the moved file on its own) lands first, pinning video frames before, at the start of, inside and at the end of a pause; an audio buffer before the pause (passed), holding the start (cut), wholly inside (dropped) and holding the end (cut, and stamped with the pause start: characterized, not endorsed); a start exactly at a buffer's start (empty, dropped) and at its end.
Notes
- What moves are the decisions on plain values: whether a pause is on (
ts_start), the video frame's step (pass, drop, or end the pause), where a pause start falls against an audio buffer, and, while paused, whether the buffer holds the end.obs-encoder.ckeeps everypause.mutexlock and unlock, thelast_video_tsstore (before the check, as today), bothutil_mul_div64()conversions (audio_frames_to_ns()for the buffer's end,ns_to_audio_frames()for each cut) with their subtractions, every write tots_start,ts_end, the buffer'sframesandtimestamp, the data pointer advance, thets_offsetsubtraction,pause_reset()and every caller. Each read stays where it is. - Intentional differences, fixed in the port and listed in its parity test:
- The video check ends a pause only on a frame stamped exactly
ts_end. The unpause time is snapped to the frame grid of the output's first video encoder, so an encoder with a frame rate divisor of 2 or more, fed through video-io, may never see a frame atts_end: it then drops every later frame, and since the record never clears, the output refuses every later pause. The port ends the pause on the first frame at or afterts_end(oncets_endis set). - A pause and unpause that both fall inside one audio buffer cut the buffer at the start and never look at the end; every later buffer starts after
ts_end, takes the "still paused" branch and is dropped, so that encoder gets no more audio and the output refuses later pauses. The port ends the pause on a paused buffer that starts after a setts_end: the record clears and the buffer passes with its own timestamp. The audio betweents_endand the end of the buffer that was cut (at most one buffer) is still lost.
The first needs a plugin or script setting a divisor on an encoder of a pausable output; the second a pause and unpause in quick succession (a double press of the pause hotkey, a script or a websocket client).
- The video check ends a pause only on a frame stamped exactly
- Threads: the video thread or GPU encode thread, the audio thread and the pause caller share one record under
pause.mutex; the core holds no state and is asked under the lock C already holds.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestportPort a C unit to Rust (four-tier policy)readyMeets the definition of Ready; claimable
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 30, 2026
Claiming: #3033.
video_pause_check()andaudio_pause_check()into libobs/obs-encoder-pause.c.h, behaviour-neutral, checked with a move harness (gcc and clang, -O0/-O2, ASan/UBSan, planted mutants).One PR; the draft opens with the RED commit today, the rest follows on it. It shares the core-output group file with #3024, and whichever lands second rebases.
libobs: Move encoder pause checks to own file
test: Characterize the encoder pause checks
obs-output: Add Tier 1 tests for encoder pause
obs-output: Port the encoder pause checks
obs-output: Check the encoder pause port against C
docs: Record the encoder pause port
libobs: Split the encoder pause video decision
test: Scale encoder pause cases, keep the edges
rdoupe commentedon Oct 30, 2026
Fixed by PR #3037 (merged as 4d2ae71): the encoder pause checks of
video_pause_check()andaudio_pause_check()now run in Rust (obs_output::encoder_pause), checked against the original C by the parity tests. The port also fixes the two stuck-pause cases: a pause and unpause inside one audio buffer no longer cuts that encoder's audio for the rest of the recording, and an encoder with a frame rate divisor no longer stays paused for good.Left: the audio between the unpause time and the end of the one buffer that was cut is still lost. The pause mutex, the two
util_mul_div64()conversions, every write to the pause record and the buffer, and the callers stay in C inobs-encoder.c.Follow-up issue: none filed. Nothing else in this unit is open, and the tracking issue (#4) has no checkbox for it to tick.
obs-output: Port the encoder pause checks (obs-rust#3037)