Repository navigation
obs-output: Port the output start decisions - #2532
Merged
Merged
Conversation
Behaviour-neutral extraction before the Rust port. The decisions of obs_output_start(), obs_output_actual_start(), obs_output_initialize_encoders() and obs_output_begin_data_capture_internal() move to libobs/obs-output-start.c.h, as six functions on plain values declared in the new libobs/obs-output-start.h without EXPORT (hidden, as -fvisibility=hidden keeps them): - obs_output_start() and obs_output_begin_data_capture_internal(): _service() (OBS_OUTPUT_SERVICE: the service gate before the start, the activation after the hookup); - obs_output_actual_start(): _drop_restart_ref() (a delayed restart's reference is dropped when delay_restart_refs is not 0); - obs_output_initialize_encoders(): _init_video() and _init_audio(); - obs_output_begin_data_capture_internal(): _reset_raw() (a raw output resets its audio and timestamps) and _pair() (video and audio both: the encoders are paired). Two rules were already ported, so their callers ask them: obs_output_start()'s delayed start is obs_output_raw_audio_delay_on() (delay_sec is not 0), the test hook_data_capture() asks (obs-rust#2457), and reset_raw_output()'s conversion fill (a rate that is not 0, a format and speakers that are not unknown replace the mix's) is obs_encoder_size_audio_defaults(), get_audio_info()'s fill. The two headers note the new callers. One function per decision, asked where the C made it, so every read stays where it was. The plan's routes (start_route over starting and delay_active, actual_steps over success and the restart refs, init_route over active and delay_active, begin_route and begin_signal over delay_active, active and reconnecting) would load an atomic where the C's && and early returns do not, or load one once for a whole function that another thread writes between the tests, so the single-field tests stay C in their order: context.data, starting and delay_active (the "already starting" refusal), success, active and delay_active, delay_capturing, audio, audio_conversion_set, reconnecting. Each atomic is loaded where it always was. Nothing is left to decide in begin_delayed_capture() (two single-field tests) or obs_output_begin_data_capture() (it always clears starting after active is set), so they are unchanged. C keeps the stopping event wait, every atomic load and store, info.start, obs_video_stats_frame_counts(), the caption track reset under its mutex, obs_service_can_try_to_connect() and obs_service_initialize() in their && order, obs_service_activate(), obs_output_delay_start(), the encoder initialization with the last-error copy, can_begin_data_capture(), pair_encoders() (its locks and weak references), hook_data_capture(), calculate_batch_size(), clear_raw_audio_buffers(), audio_output_get_info(), get_audio_planes(), get_audio_size(), pause_reset(), every signal and every log. One read changes: obs_output_begin_data_capture_internal()'s pair test reads info.flags once where flag_video() && flag_audio() read it twice. info.flags is set when the output is created and never written again. Checked in a scratch harness (not committed). It compiles origin/master's seven functions (obs_output_start(), _actual_start(), _initialize_encoders(), begin_delayed_capture(), reset_raw_output(), obs_output_begin_data_capture_internal() and obs_output_begin_data_capture()) and their flag and atomic helpers verbatim, and this branch's with the moved file, obs-output-raw-audio.c.h and obs-encoder-size.c.h, with every read and write of an output field rewritten the same way into a logged access (with the value), over a stand-in output. It logs every atomic load, store and decrement (with the field and value), the stopping event wait, bfree(), the frame counts, every lock and unlock, the caption deque calls, obs_output_valid(), each service call, the delayed start, info.start, the encoder initialization, can_begin_data_capture(), pair_encoders(), hook_data_capture(), calculate_batch_size(), the raw audio calls (audio_output_get_info(), get_audio_planes() and get_audio_size() with their arguments, the buffer clear and the pause reset), every signal and every log, in order. Another thread flips one of starting, active, reconnecting, delay_active, delay_capturing, data_active and delay_restart_refs at any of those calls. A repeated info.flags read with nothing between is logged once (the read above). - Inputs: every low flag word with and without high bits, with and without context.data, a service and an audio, each atomic set and clear, restart refs of 0, 1, 2, -1, LONG_MIN and LONG_MAX, delays of 0, 1, 30 and UINT32_MAX, every result of the valid check, the service, info.start, the encoder initialization, the capture check and the delayed start, conversions with each field set, 0 or unknown (set or not), edge mix rates, formats and speakers, 0 to 10 caption tracks; one to six calls in a row. - 2,900,000 runs (GCC and Clang -O2, 1,000,000 each; GCC -O0, 500,000; ASan with UBSan under GCC -O0 and Clang -O2, 200,000 each) give equal events, equal returns and an equal end state (every output field and the caption tracks): 169,887,172 events. - Every branch of origin/master's functions that these callers can reach is taken both ways (gcov, 92 of 98; the other six are log_flag_encoded()'s inverse_log side, which they never ask, and the harness's dispatch). - 25 deliberately broken moves were planted and all 25 fail it: the restart refs loaded before info.start, delay_active loaded before starting or hoisted out of the &&, the service initialized before can_try, the delayed start on the wrong field, the conversion fill without its set test, with its arguments swapped or dropping the rate, active loaded before delay_active in the begin, the pair after data_active, the raw reset after the capture check, the activation after the signal, the begin signal tests swapped, audio encoders before video, delay_active loaded with active, the decrement unconditional, the wrong flag rule at the activation, and nine changed decisions (the service test inverted, the restart ref test > 0, the video and audio flags swapped in either init, the raw reset inverted, || for && and video only in the pair, the delay always on). git blame on the moved lines shows upstream commits only (ceb675f, 645e31f, 6ec0b2d, d314d47, 09e10a4, 8830c41). The four flags are copied into the header, so it needs no core header; obs-output.c.h checks them with _Static_assert. The new file joins libobs.core-output, just before obs-output.c.h, with libobs.pch.h, which includes the new header; source-sets.json lists it. docs/rust-port/naming.md maps the file to rust/obs-output. The exported symbol sets are unchanged (1766) on the C, hybrid and C reference libobs; the six functions are local. Refs obs-rust#2522
test_output_start_steps compiles libobs/obs-output-start.c.h, libobs/obs-output-raw-audio.c.h (whose delay test obs_output_start() asks) and libobs/obs-encoder-size.c.h (whose audio fill reset_raw_output() asks) with ASan and UBSan, and calls only their functions through their headers. Five cases on the functions: - the copied flags (OBS_OUTPUT_VIDEO, _AUDIO, _ENCODED, _SERVICE); - the service, init, raw reset and pair rules over every low 16-bit flag word with four high words (each looks at its own bits only); - the restart reference: dropped for any count that is not 0 (a negative count too: characterized, not endorsed, never reached); - the delayed start, for any delay that is not 0; - the conversion fill: each field set alone replaces only the mix's, 0 and unknown keep the mix's, any other format or speakers value is taken as it is. The bodies of obs_output_start(), obs_output_actual_start(), obs_output_initialize_encoders(), begin_delayed_capture(), reset_raw_output(), obs_output_begin_data_capture_internal() and obs_output_begin_data_capture() are also copied onto a stand-in output (no thread, lock, service or encoder; their results are given, and every call, store, signal and warning is recorded), to pin end to end in 14 cases: - the start of a stream, a recording and a raw output; invalid and no data; already starting (refused with the warning) and starting with a delay active (goes on); active, reconnecting and delay_capturing, which do not refuse it; - the service gate when it cannot try (initialize not called), when initialize fails and without the service flag; - the delayed start (its result, no "starting"; the gate first; a raw output with a delay is delayed too: characterized, not endorsed); - the actual start on success and failure, with and without data, with 0, 1, 2, 3 and -1 restart refs (one dropped per start, on success and failure), the last error freed and the caption tracks reset whatever the result; - the encoder initialization of raw, video, audio, AV and flagless encoded outputs, a video failure stopping before the audio, active (true only with a delay active), delay_active alone, and the raw refusal before the active test; - the raw reset with no conversion, an unset one, each field set alone, 0 and unknown, and no audio; - the begin of a stream, a recording, raw video, raw AV (paired too: characterized, not endorsed) and encoded audio-only outputs; active, a failed capture check (total_frames already reset, no data_active) and invalid; each end signal (reconnect_success clearing the flag, "starting" for a delay the hookup turned on, reconnecting over the delay, "start"); the delayed capture (start, reconnect_success, already capturing, before active and the capture check); starting cleared after every begin; - a start then a begin, a second start while starting, and a start after a failed one. It is in the native test graph, in name order, with the three headers as watch inputs, and links libm off MSVC. No assert_in_range or fail_msg, so it builds with cmocka 1.x and 2.x, and no comparison between two enum types (MSVC C5287). The real-libobs tests test_output_start_twice, test_output_failed_start_encoders, test_output_delay, test_output_delay_restart, test_output_before_video, test_raw_output_video_reset, test_output_interleave_restart and test_rtmp_send_thread_leak cover the callers. Refs obs-rust#2522
RED for the port of libobs/obs-output-start.c.h to a new output_start module of rust/obs-output, next to output_slots and raw_audio. The safe core is a stub (todo!()): service(), drop_restart_ref(), init_video(), init_audio(), reset_raw() and pair(), with the four flags (video_checks'). It re-exports raw_audio's delay_on() and encoder_size's audio_defaults() with AudioFill, the delayed start and the conversion fill the callers share, already ported. tests/output/output_start.rs ports test_output_start_steps 1:1: its 19 cases under the same names (steps_*), in the same order, with the same values and expectations, the characterized-not-endorsed cases included, the stand-in output and its copies of obs_output_start(), obs_output_actual_start(), obs_output_initialize_encoders(), begin_delayed_capture(), reset_raw_output(), obs_output_begin_data_capture_internal() and obs_output_begin_data_capture() written in Rust over the core. Edge cases (edge_*) check the core against the origin/master expressions inline: every low 16-bit flag word under 16 high words; every restart count from -1,000 to 1,000 and the extremes; every delay to 100,000 and the top 1,000; the conversion fill over every combination of edge formats, rates and speakers for the conversion and the mix (86,016); the stand-in through every caller for every low flag word, each of six atomics set and clear, three restart counts, a delay or none and each of eleven call results failing alone (73,728 outputs); and proptests (4,096 cases each) of every decision over full-range values and of the stand-in over sequences of up to eleven calls, with another thread flipping the atomics, the restart refs, the delay and the call results between them. soldr cargo test -p obs-data --test obs-tests-core -- output::output_start passes 6 of 25 (the constants and the cases that ask only the already-ported delay test and conversion fill) and fails 19 with "not yet implemented". Refs obs-rust#2522
Ports libobs/obs-output-start.c.h, the output start and begin-capture decisions, to the output_start module of rust/obs-output. obs-output.c.h stays C around it: obs_output_valid(), log_flag_encoded(), every warning, every atomic load and store (starting, delay_active, active, reconnecting, data_active, delay_capturing and delay_restart_refs) where it always was, the context.data, success, audio and audio_conversion_set tests and the single-field tests in their && order, the stopping event wait, info.start, the frame counts, the caption track reset under its mutex, the service calls in their order, obs_output_delay_start(), the encoder initialization, can_begin_data_capture(), pair_encoders() with its locks and weak references, hook_data_capture(), calculate_batch_size(), the raw audio calls, every signal and every log. The hybrid libobs drops the C file and links the Rust shims in its place. Safe core (src/output_start.rs): - service(): OBS_OUTPUT_SERVICE is in the flags (the gate before the start, the activation after the hookup); - drop_restart_ref(): the loaded restart count is not 0; - init_video() and init_audio(): OBS_OUTPUT_VIDEO, OBS_OUTPUT_AUDIO; - reset_raw(): OBS_OUTPUT_ENCODED is not in the flags; - pair(): both OBS_OUTPUT_VIDEO and OBS_OUTPUT_AUDIO; - delay_on() re-exported from raw_audio and audio_defaults() (with AudioFill) from encoder_size: obs_output_start() and reset_raw_output() call those shims, so they share one implementation. The flags are video_checks'. The module denies clippy's arithmetic, as, indexing, unwrap, expect, panic, todo, unimplemented and unreachable lints, keeps no state, takes no lock and does not divide. Shims (src/ffi/output_start.rs): the six functions keep the C signatures; the restart count comes in as c_long (32 bits on Windows) and is widened to i64. No pointer crosses. No intentional differences. C side: the file leaves libobs.core-output for its own group, libobs.ported-output-start (LIBOBS_PORTED_SOURCES), whose PCH is only obs-output-start.h; libobs.pch.h keeps the header for obs-output.c. The functions are not EXPORT, so the shims are hidden: rust-hidden.txt, the local: list of rust-exports.map and rust-unexports-macos.txt. libobs-rust already links the crate's ffi. ci/test_ported_sources.py checks the group on every host. The exported symbol sets are unchanged (1766) on the C, hybrid and C reference libobs, and the six functions are local in each; the hybrid libobs has no C object for the group. test_output_start_steps still compiles the C file into itself, unchanged. It has no _rust variant, as for test_output_slots_steps: the shims' archive member also holds the rest of obs-output, which needs libobs's hidden seams and obs-util, so it does not link on its own. Its tests.d file says so. soldr cargo test -p obs-data --test obs-tests-core -- output::output_start passes 25 of 25. Through ctest (private Xvfb and D-Bus, own HOME and runtime directory, no sound), the full suite passes against the C libobs (538 of 538) and the hybrid libobs (570 of 570), the same 3 skipped on each (a PulseAudio default sink and the v4l2 vivid module, absent here). Against the C reference libobs 569 of 570 passed in that run: test_encoder_error_stop's raw replay buffer case saw no packets before its injected failure at a load average of about 20, and passed in each of three runs on its own (the C reference runs the same C as the C libobs, where it passed). Among them test_output_start_steps, test_output_start_twice, test_output_failed_start_encoders, test_ffmpeg_output_connecting, test_output_start_log, test_output_delay, test_output_delay_e2e, test_output_delay_restart, test_output_before_video, test_raw_output_video_reset, test_output_interleave_restart, test_rtmp_send_thread_leak, test_output_raw_audio_steps and test_encoder_size_steps. Refs obs-rust#2522
Tier 3 for the output_start port. The oracle (rust/obs-c-oracle/oracle/output_start.c) compiles the unchanged libobs/obs-output-start.c.h with its six functions renamed to oracle_*, plus its four flags and the width of long, bound in src/output_start.rs. Nothing in it divides. The delayed start's oracle is output_raw_audio's and the conversion fill's encoder_size's. tests/output/output_start_parity.rs compares the oracle, the shims and the core exactly, all three sides: - the four flags and sizeof(long) (32 bits on Windows: the shim takes c_long and widens it); - the five flag rules over every low 16-bit flag word under 16 high words and a stride through all of u32; - the restart count over -100,000 to 100,000, the 100,000 values at each extreme of long and a stride through all of it; - the delayed start over 0 to 1,000,000, the top 100,000 and a stride through all of u32; - the conversion fill over every combination of 12 formats, 12 rates and 12 speakers against four mixes (6,912); - the callers on test_output_start_steps' stand-in output (shared with Tier 1), on the oracle's gates and on the shims: every caller for every low flag word under two high words, each of six atomics set and clear, three restart counts, two delays and each of twelve call results failing alone (147,456 outputs), comparing every return, the record and the end state; - proptests (20,000 cases each) of every decision over full-range values and of the stand-in over sequences of up to fifteen calls, with another thread flipping the atomics, the restart refs, the delay and the call results between them. No input is excluded: nothing in the C divides or overflows. A restart count past a 32-bit long is passed to the C and the shim at the nearest end, which keeps "not 0". The proptests keep no regression files (failure_persistence None), as the delay and interleave parity runners do. Mutation check (once, not committed): 20 mutants, 13 in the core and 7 in the shims. mutant Tier 1 Tier 3 service: == 12 4 service: the video flag 11 4 OBS_OUTPUT_SERVICE = 1 << 4 9 5 drop_restart_ref: > 0 6 3 drop_restart_ref: never 6 4 init_video: the audio flag 6 4 init_video: always 6 4 init_audio: the video flag 6 4 reset_raw: encoded 9 4 reset_raw: the video flag 8 4 OBS_OUTPUT_ENCODED = 1 << 3 3 5 pair: || 7 4 pair: video only 7 4 shim service inverted 0 4 shim drop_restart_ref: positive only 0 3 shim init_video asks init_audio 0 4 shim init_audio asks init_video 0 4 shim reset_raw inverted 0 4 shim pair asks service 0 4 shim service: flags >> 1 0 4 (failing tests per tier.) Tier 1 kills all 13 core mutants and Tier 3 all 20. soldr cargo test -p obs-data --test obs-tests-core -- output::output_start passes 33 of 33 (25 Tier 1, 8 Tier 3). Refs obs-rust#2522
rust/README.md gets the row for libobs/obs-output-start.c.h (obs-output::output_start), after encoder_lifecycle's: what moved, the delayed start and the conversion fill shared with raw_audio and encoder_size, what stays C and why (every atomic loaded where it always was, the single-field tests in their && order, the order of the stores), the one read that changed (info.flags once in the pair test), the characterized-not-endorsed behaviours (a negative restart count dropped, a raw output delayed or paired, a flagless encoded output initializing nothing, only starting refusing a start) and the tests that cover it; the obs-output crate row names the file. The crate's Cargo description and lib.rs named the module in the port commit, and docs/rust-port/naming.md maps the file (the move commit). rust/obs-c-oracle/benches/port_comparison/output_start.rs, in the sorted module list, runs 1024 rounds over the flag words of a stream, a recording, a raw video and a raw AV output with restart counts, delays and four conversions, asking every decision obs_output_start(), obs_output_actual_start(), obs_output_initialize_encoders(), reset_raw_output() and obs_output_begin_data_capture_internal() ask, in their order, on the shims and on the oracle, and checks both checksums match. Release, x86_64 Linux, GCC, median (load average 9 to 26): Rust 19.06 us, C 19.94 us (0.96x), about 19 ns a round, next to the service calls, the encoder initialization or a single signal. The port changes nothing a user can see, so docs/features.md has no line. Fixes obs-rust#2522
zackees
reviewed
Oct 26, 2026
zackees
left a comment
Member
There was a problem hiding this comment.
Reviewed:
- Each flag test and
delay_restart_refscheck now calls one decision function at the point where the C made it, so the evaluation order is unchanged. - The
_Static_asserts pin the copied flags, and the conversion fill reusesobs_encoder_size_audio_defaultsrather than copying it. - The C oracle, the Rust-vs-C comparison test and the bench are all present. Among existing test files, only
test-graph.jsonis touched, and no public header changed. - No ledger line is needed (no behaviour change).
Queuing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2522
What and why
Ports the decisions of the output start and begin-capture path of
libobs/obs-output.c.htorust/obs-output, as a new moduleoutput_start, next tooutput_slotsandraw_audio. Every stream, recording, replay buffer and virtual camera start passes through these, and so does every reconnect and delayed restart:obs_output_start(): the service gate (OBS_OUTPUT_SERVICE: the service is asked whether it can connect, then initialized);obs_output_actual_start(): whether a delayed restart's reference is dropped (the loaded count is not 0);obs_output_initialize_encoders(): which encoders are initialized (OBS_OUTPUT_VIDEO, thenOBS_OUTPUT_AUDIO);obs_output_begin_data_capture_internal(): whether a raw output resets its audio and timestamps (noOBS_OUTPUT_ENCODED), whether the encoders are paired (video and audio both) and whether the service is activated.Two rules are reused, not copied.
obs_output_start()'s delayed start (delay_secis not 0) isobs_output_raw_audio_delay_on(), the testhook_data_capture()already asks (#2457).reset_raw_output()'s conversion fill (a rate that is not 0, a format and speakers that are not unknown replace the mix's) isobs_encoder_size_audio_defaults(), the fillget_audio_info()already asks.output_startre-exports both, and the two headers note the new callers.One function per decision, asked where the C made it. Six functions cross the C ABI:
obs_output_start_service(),_drop_restart_ref(),_init_video(),_init_audio(),_reset_raw()and_pair(). The plan's routes (start_routeoverstartinganddelay_active,actual_stepsoversuccessand the restart count,init_routeoveractiveanddelay_active,begin_routeandbegin_signaloverdelay_active,activeandreconnecting) would load an atomic on paths where the C's&&and early returns never load it, or load one once for a whole function while another thread (the delay, reconnect or end-capture thread) writes it between the tests. So those stay C: the single-field tests in their order, each atomic loaded where it always was. That coverscontext.data;startingthendelay_active(the "already starting" refusal);success;activethendelay_active;delay_capturing;audio;audio_conversion_set; andreconnectingthendelay_active(the signal that ends a begin).begin_delayed_capture()(two single-field tests) andobs_output_begin_data_capture()(it always clearsstartingafteractiveis set; the order of those stores stays C) have nothing left to decide, so they are unchanged.What stays C, at its point and under its condition:
obs_output_valid(),log_flag_encoded()(it logs as it tests), every warning and every signal;starting,delay_active,active,reconnecting,data_active,delay_capturing,delay_restart_refs); Rust only gets values C already loaded;info.start,obs_video_stats_frame_counts(), the caption track reset under its mutex;obs_service_can_try_to_connect()andobs_service_initialize()in their&&order,obs_service_activate(),obs_output_delay_start();can_begin_data_capture(),pair_encoders()(its locks and weak references),hook_data_capture(),calculate_batch_size();clear_raw_audio_buffers(),audio_output_get_info(),get_audio_planes(),get_audio_size(),pause_reset().Nothing divides and no pointer crosses. The header copies the four flags, and
obs-output.c.hchecks them with_Static_assert. The restart count crosses aslong(32 bits on Windows) and is widened toi64.One read changes. The pair test reads
info.flagsonce, whereflag_video() && flag_audio()read it twice.info.flagsis set when the output is created and never written again.Six commits:
Move (behaviour-neutral,
84fee9a0d): the decisions go tolibobs/obs-output-start.c.h, declared in the newobs-output-start.hwithoutEXPORT, so they are hidden. The file joinslibobs.core-output.git blameon the moved lines shows upstream commits only.The move was checked against the original code. A scratch harness (not committed) compiles origin/master's seven functions (
obs_output_start(),_actual_start(),_initialize_encoders(),begin_delayed_capture(),reset_raw_output(),obs_output_begin_data_capture_internal(),obs_output_begin_data_capture()) and their flag and atomic helpers verbatim, next to this branch's (with the moved file,obs-output-raw-audio.c.handobs-encoder-size.c.h), with every read and write of an output field rewritten the same way into a logged access:bfree(), the frame counts, every lock and unlock, the caption deque calls,obs_output_valid(), each service call, the delayed start,info.start, the encoder initialization, the capture check, the pairing, the hookup, the batch size, the raw audio calls with their arguments, every signal and every log are logged in order;starting,active,reconnecting,delay_active,delay_capturing,data_activeanddelay_restart_refsat any of those calls;info.flagsread with nothing between is logged once (the read above);context.data, a service and an audio, each atomic set and clear, restart counts of 0, 1, 2, -1,LONG_MINandLONG_MAX, delays of 0, 1, 30 andUINT32_MAX, every result of the valid check, the service,info.start, the encoder initialization, the capture check and the delayed start, conversions with each field set, 0 or unknown, edge mixes, 0 to 10 caption tracks, and one to six calls in a row.2,900,000 runs (GCC and Clang
-O2, 1,000,000 each; GCC-O0, 500,000; ASan with UBSan under GCC-O0and Clang-O2, 200,000 each): all 169,887,172 logged events match, and so do the returns and the end state after each run. Every branch of origin/master's functions these callers can reach is taken both ways (gcov, 92 of 98; the other six arelog_flag_encoded()'sinverse_logside, which they never ask, and the harness's dispatch). After the rebase onto5bb55ba9c(which does not touch the moved files), another 200,000 runs match; the later rebase onto332145031does not touch them either.25 deliberately broken moves were tried, and all 25 fail the harness: the restart count loaded before
info.start;delay_activeloaded beforestartingor hoisted out of the&&; the service initialized beforecan_try; the delayed start on the wrong field; the conversion fill without its set test, with its arguments swapped or dropping the rate;activeloaded beforedelay_activein the begin; the pairing afterdata_active; the raw reset after the capture check; the activation after the signal; the begin's signal tests swapped; audio encoders before video;delay_activeloaded withactive; the decrement made unconditional; the wrong flag rule at the activation; and nine changed decisions.Characterization (
95aadca5a):test_output_start_steps, 19 cases. It compiles the moved file,obs-output-raw-audio.c.handobs-encoder-size.c.hwith ASan and UBSan, and calls only their functions. Five cases pin the decisions (every low 16-bit flag word under four high words, the restart count, the delay, the conversion fill field by field). Fourteen copy the seven callers onto a stand-in output that records every call, store, signal and warning, end to end:reconnect_successclearing the flag,startingfor a delay the hookup turned on,start), the delayed capture, andstartingcleared after every begin;It is in the test graph, sorted, with the three headers as watch inputs. No
assert_in_rangeorfail_msg, and no comparison between two enum types (MSVC C5287).RED (
d649ed4a6): Tier 1 againsttodo!(). It ports the 19 C cases 1:1 and adds 6 edge tests against the origin/master expressions inline: every low 16-bit flag word under 16 high words, every restart count from -1,000 to 1,000 and the extremes, every delay to 100,000 and the top ofu32, the conversion fill over 86,016 combinations, the stand-in through every caller for 73,728 output states, and proptests over full-range values and over call sequences with another thread flipping the atomics, the restart count, the delay and the call results between calls.GREEN (
8ed8d2e6a): the safe core (six functions plus the two re-exports) and six#[no_mangle]shims, in a newlibobs.ported-output-startgroup whose PCH is only the new header.source-sets.json, the unity lists, the three export lists andci/test_ported_sources.py, each in sorted place.test_output_start_stepshas no_rustvariant, as fortest_output_slots_steps: the shims' archive member also holds the rest ofobs-output, which does not link on its own. Its tests.d file says so.Tier 3 (
1e2772b5c): a C oracle of the unchanged file, the parity tests and a mutation check. The oracles of the two reused rules areoutput_raw_audio's andencoder_size's.Docs (
f0ea8f9c2): the README rows and aport_comparisonbench file in the sorted lists.docs/rust-port/naming.mdmaps the file in the move commit. The port changes nothing a user can see, sodocs/features.mdhas no line.The core denies clippy's arithmetic, indexing,
as, unwrap, expect, panic, todo, unimplemented and unreachable lints. It keeps no state, takes no lock and does not divide.obs_output_delay_start();startingrefuses a start:active,reconnectinganddelay_capturingdo not.Mutation check (once, not committed), failing tests per tier:
==OBS_OUTPUT_SERVICE = 1 << 4> 0OBS_OUTPUT_ENCODED = 1 << 3||Tier 1 kills all 13 core mutants, Tier 3 all 20.
port_comparisonbench (output_start/start_and_begin/1024, release, x86_64 Linux, GCC, median, load average 9 to 26): Rust 19.06 µs, C 19.94 µs (0.96x), about 19 ns a round, next to a service call, the encoder initialization or a single signal.RED → GREEN
d649ed4a6. On its previous rebase (8ae75b0da, the same Rust tree),soldr cargo test -p obs-data --test obs-tests-core -- output::output_startpasses 6 of 25 (the constants, and the cases that ask only the already-ported delay test and conversion fill) and fails 19 with "not yet implemented". Before the rebase (same Rust tree, ate2e0e350c),local_gate.py --test-diff origin/masterran 4528 tests and failed exactly those 19 (4509 passed, 6 skipped), and--lane lintpassed.8ed8d2e6a, 33 of 33 (25 Tier 1, 8 Tier 3) at the head (242 of 242 with the encoder modules). Full ctest on the GREEN commit before the rebase (f6cec0de4, onbf3ff380d; private Xvfb and D-Bus, own HOME and runtime directory, no sound): 538 of 538 on the C libobs and 570 of 570 on the hybrid libobs, the same 3 environment skips on each (a PulseAudio default sink and the v4l2 vivid module); onlibobs-c-reference569 of 570,test_encoder_error_stop's raw replay buffer case seeing no packets before its injected failure at a load average of about 20, then passing three runs in a row on its own. After the rebase onto5bb55ba9c(which brought in the encoder lifecycle port, obs-output: Port the encoder lifecycle decisions #2521), at24a0076bd: 540 of 540 (C), 572 of 572 (hybrid) and 572 of 572 (C reference), the same 3 environment skips on each. The head was then rebased onto332145031(an obs-graphics port and characterization tests, nothing in the output files). At the headf0ea8f9c2, the output and encoder tests (test_output_start_steps,test_output_start_twice,test_output_start_log,test_output_failed_start_encoders,test_ffmpeg_output_connecting,test_output_delay,test_output_delay_e2e,test_output_delay_restart,test_output_before_video,test_raw_output_video_reset,test_output_interleave,test_output_interleave_e2e,test_output_interleave_restart,test_rtmp_send_thread_leak,test_output_raw_audio_steps,test_encoder_size_steps,test_output_slots_steps,test_encoder_error_stop,test_encoder_lifecycle_steps): 19 of 19 on each lane. Exported symbol sets identical (1766) on the C, hybrid and C reference libobs (libobs-c-referencerebuilt before each run); the six functions are local, and the hybrid libobs has no C object for the group (its shim has no C line information; the C reference's is the C file). Atf0ea8f9c2:local_gate.py --test-diff origin/master(4575 of 4575, 6 skipped),--lane lintand--lane cross(Windows MSVC and macOS clippy, and every test binary linked for both) pass. Windows MSVC clippy over obs-output's and the test binary's--all-targets(SOLDR_RUSTC_WRAPPER=none) is clean at24a0076bd(same Rust tree as the head).Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): not applicable, none