Skip to content

libobs: Keep source volumes finite and non-negative - #2128

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/source-volume-range
Oct 24, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/source-volume-range

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

Fixes #2108

What and why

A source's volume was never range-checked (#2108). libobs multiplies every
sample of a source by its volume, and obs_source_set_volume() and the
scene-collection load in obs_load_source() stored any float.

  • NaN made every sample of the source NaN, and NaN spreads through the
    sum into every mix the source is in. The clamped mix most outputs get
    turns NaN into 0, so the whole track went silent; outputs that allow
    clipping got NaN.
  • Infinity made the source's silent samples NaN (inf × 0) and the
    others infinite.
  • A negative volume inverted the phase.

The fix, at the setter and on load only:

  • obs_source_set_volume() maps the volume: NaN becomes the default, 1.0,
    a negative volume (including -inf) 0.0, and +inf 20.0 (+26 dB). It maps
    it before it is queued for the mix and passed to the volume signal, and
    again after the handlers, since the signal's volume is in/out (as libobs: Saturate push-to-talk stop times and clamp the audio balance #2058
    does for the balance).
  • obs_load_source() brings the stored double into float's range before
    the cast: below 0 is 0, beyond FLT_MAX is +inf, which the setter then
    maps to 20. A double such as 1e300 no longer goes through an
    out-of-range conversion.

Upper bound. Finite volumes of 0 or more are kept, including volumes
above 20; only +inf is mapped, to 20. 20 is the most any built-in control
sets, so no value they can produce changes:

  • Advanced Audio Properties (OBSAdvAudioCtrl): dB spin box from -96 to
    +26 dB (obs_db_to_mul(26) = 19.95), percent spin box from 0 to 2000%
    (20.0);
  • mixer faders (VolumeControl → obs_fader, C and the Rust port in
    obs-audio-controls): every curve has max_db = 0 dB, so at most 1.0;
  • obs-websocket SetInputVolume: inputVolumeMul validated 0 to 20,
    inputVolumeDb -100 to +26;
  • no other plugin in the tree calls obs_source_set_volume().

Finite volumes above 20 can only come from a plugin, a script or an edited
scene collection, and they amplify as asked without producing NaN, so
clamping them would change existing setups for no gain. A finite volume is
left alone.

What users see: a scene collection, plugin or script that sets a source's
volume to NaN no longer silences every track the source is in (it plays at
100%), a negative volume mutes the source instead of inverting it, and an
infinite volume plays at 2000% (+26 dB) instead of corrupting the mix. The
volume controls and obs-websocket could not produce these values, so
nothing changes for them. obs-websocket's InputVolumeChanged event now
reports the mapped value.

Every valid volume behaves as before: 0, -0, 0.5, 1, 19.95, 20, 100 and
FLT_MAX are kept bit for bit through the setter and the load, a loaded
0.3 rounds to float as before, and a missing volume still loads as 1.0.
As before, the mix applies the volume the setter was given, not one a
volume handler hands back; only the stored volume takes the handler's
value. get_source_volume() and the push-to-mute/talk gate (#2089) are
untouched. docs/features.md has the line under Fixed upstream bugs,
Audio, and the API reference states the range.

RED → GREEN

  • RED commit: baddc5b extends test_source_audio_ranges (core suite)
    with the volume through the setter, the volume signal and a loaded
    scene collection (getter and the volume queued for the mix, bit for bit),
    and adds test_source_volume_mix (graphics suite, Linux, under xvfb-run,
    registered in test-graph.json), which puts a source on the program and
    listens to the clamped and unclamped mixes. On C, hybrid and
    libobs-c-reference alike (run on f77649c55, the same commit before
    rebases onto later master):
    • test_source_audio_ranges: 3 of 13 fail (setter_maps_volume,
      volume_signal_is_mapped, loaded_volume_is_mapped: NaN kept as NaN);
      the 9 delay/balance tests and setter_keeps_valid_volume pass;
    • test_source_volume_mix: 2 of 4 fail. NaN leaves the clamped mix
      silent and the unclamped mix NaN; -1 inverts the source; ±inf and
      ±1e300 give NaN or infinite samples, through the setter and the load.
      The two valid-value tests (0, 1, 100) pass.
  • GREEN: 5dfb58c.
  • Real app (UI, protocol output or logging changes): N/A. No UI or log
    change, and the controls and obs-websocket can't produce these values.

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (N/A for docs-only; a focused CI fix may push RED and GREEN together)
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (PR CI builds no OBS app: run gh workflow run ci.yml --ref <branch> for the full builds) and cross-checked with clang and MSVC
  • Intentional differences from C listed in the parity test header and rust/README.md (ports)

A source's volume is a multiplier that libobs applies to every sample, and
neither obs_source_set_volume() nor obs_load_source() range-checks it. A
NaN volume makes every sample NaN, and NaN spreads through the sum into
every mix the source is in; an infinite one makes silent samples NaN; a
negative one inverts the phase.

test_source_audio_ranges gains the volume, next to the balance it already
covers. Through the setter, the "volume" signal and a loaded scene
collection, NaN must become the default, 1, a negative volume 0, and +inf
20 (+26 dB), the most the Advanced Audio Properties and obs-websocket set.
It checks the getter and the volume queued for the mix bit for bit, and
that the signal's handlers see and hand back mapped volumes. Valid volumes
stay bit for bit: 0, -0, 0.5, 1, 19.95 (+26 dB), 20, 100 and FLT_MAX, a
double such as 0.3 rounds to float as before, and a missing volume loads as
1.

test_source_volume_mix (graphics suite, Linux, under xvfb-run) puts a
source on the program and listens to the mixed audio: it must stay finite
and carry the source at the mapped volume, or stay silent at 0. NaN, -1,
+inf and -inf go through the setter and a loaded scene collection, and
1e300 and -1e300 through the load; 0, 1 and 100 must mix as before.

Refs obs-rust#2108
obs_source_set_volume() and obs_load_source() accepted any float as a
source's volume, and libobs multiplies every sample of the source by it. A
NaN volume made every sample NaN, and NaN spreads through the sum into every
mix the source is in: the clamped mix most outputs get turns NaN into 0, so
the whole track went silent, and outputs that allow clipping got NaN. An
infinite volume made the silent samples NaN and the others infinite, and a
negative one inverted the phase.

obs_source_set_volume() now maps the volume before it queues it for the mix
and before the "volume" signal, and again after the handlers, since the
signal's volume is in/out: NaN becomes the default, 1, a negative volume 0,
and +inf 20 (+26 dB), the most the Advanced Audio Properties (2000%) and
obs-websocket's SetInputVolume (0 to 20, or -100 to +26 dB) set. The mixer
faders stop at 0 dB. Finite volumes of 0 or more are kept, including those
above 20 that a plugin or script may set, so every value that was valid
behaves as before.

obs_load_source() brings the stored double into float's range before the
cast: below 0 is 0, beyond FLT_MAX is +inf, which the setter maps to 20.

get_source_volume() and the push-to-mute gate are unchanged.

Fixes obs-rust#2108
@rdoupe
rdoupe requested a review from zackees as a code owner October 24, 2026 10:48
@zackees
zackees added this pull request to the merge queue Oct 24, 2026
Merged via the queue into obs-rust:master with commit 6bae297 Oct 24, 2026
35 checks passed
zackees pushed a commit to rdoupe/obs-studio that referenced this pull request Oct 24, 2026
…e-load.c

Behaviour-neutral extraction before the Rust port. The pure decisions of
obs_load_source_type() move to libobs/obs-source-load.c.h, as six functions
on plain values declared in the new libobs/obs-source-load.h without EXPORT
(hidden, as -fvisibility=hidden keeps them):

- obs_source_load_prev_ver(stored): the saved "prev_ver" int64 as the
  uint32_t the source is created with (its low 32 bits, as the cast did);
- obs_source_load_volume(volume): obs-rust#2128's rule, 0 when negative, INFINITY
  past FLT_MAX, then the float cast;
- obs_source_load_balance(balance): obs-rust#2058's rule, 0 to 1, then the cast;
- obs_source_load_delay(delay): obs-rust#2058's rule, a negative push-to-mute or
  push-to-talk delay is none;
- obs_source_load_deinterlace_mode(mode): obs-rust#2120's rule, a mode past the int
  range is OBS_DEINTERLACE_MODE_DISABLE;
- obs_source_load_monitoring_migration(prev_ver, caps, monitoring_type):
  before 23.2.2 a source with OBS_SOURCE_MONITOR_BY_DEFAULT becomes
  monitor-only and gets all six mixers; before 33.0.0 "monitoring_enabled"
  is stored as the (migrated) type not being none. It takes the saved int64
  type and reads it as an int, as the (int) cast did. The answer is a
  struct: whether to set the mixers and to what, and whether to store
  "monitoring_enabled" and its value.

obs.c.h keeps every obs_data_*() call and setter, in the same order and the
same number of calls: it reads each value, passes it in, and hands the
answer to the setter (obs_source_set_audio_mixers() and obs_data_set_bool()
only when the plan says so, as the two ifs did). The source creation, the
canvas lookup, the private settings and the filter recursion stay as they
were.

The constants are copied into the header (MAKE_SEMANTIC_VERSION(23, 2, 2)
and (33, 0, 0), OBS_SOURCE_MONITOR_BY_DEFAULT, the two monitoring types,
the six-mixer mask and OBS_DEINTERLACE_MODE_DISABLE), so it needs only
stdbool.h and stdint.h; obs.c.h checks each against obs-config.h,
obs-source.h, obs.h and MAX_AUDIO_MIXES with _Static_assert. The new file
joins libobs.core, before obs.c.h, with libobs.pch.h, which includes the new
header; source-sets.json lists it. docs/rust-port/naming.md maps it to
rust/obs-core. The exported symbol set is unchanged (1766); the six
functions are local.

Checked in a scratch harness (not committed) that compiles origin/master's
obs_load_source_type() verbatim next to this one and the moved file, on stub
obs_data and source calls that record every call with its arguments
(doubles and floats by bit pattern, so NaN payloads and -0 count): 10,000,000
loads under ASan and UBSan, at -O0 and -O2, with saved values drawn from the
edges (NaN payloads of both signs, +-inf, -0, FLT_MAX and its neighbours,
subnormals, the int and int64 ends, versions at and around 23.2.2 and 33.0.0
and those plus 2^32), random bit patterns, keys present or missing, caps with
and without the cap, scene, group and filter types, and filters loaded
through the recursion: 859,000,000 recorded calls, equal in order and value.
Deliberately broken moves (each comparison of the volume, balance, delay and
deinterlace rules, the prev_ver cast, both version bounds, the migrated type,
the mixer mask, the type cast) all fail it, except a balance bound of
>= 1.0, which is equivalent.

git log -L on obs_load_source_type shows obs-rust#2058 (balance and delays), obs-rust#2120
(deinterlace mode) and obs-rust#2128 (volume) as the fork's changes; each rule and
its comment moves as it is; the volume's
"volume = INFINITY" becomes "volume = (double)INFINITY" (the same value),
since INFINITY is a float and the C oracle builds with -Wdouble-promotion
-Werror.

Refs obs-rust#2143
rdoupe added a commit to rdoupe/obs-studio that referenced this pull request Oct 24, 2026
* libobs: Move the source load migration and value rules into obs-source-load.c

Behaviour-neutral extraction before the Rust port. The pure decisions of
obs_load_source_type() move to libobs/obs-source-load.c.h, as six functions
on plain values declared in the new libobs/obs-source-load.h without EXPORT
(hidden, as -fvisibility=hidden keeps them):

- obs_source_load_prev_ver(stored): the saved "prev_ver" int64 as the
  uint32_t the source is created with (its low 32 bits, as the cast did);
- obs_source_load_volume(volume): obs-rust#2128's rule, 0 when negative, INFINITY
  past FLT_MAX, then the float cast;
- obs_source_load_balance(balance): obs-rust#2058's rule, 0 to 1, then the cast;
- obs_source_load_delay(delay): obs-rust#2058's rule, a negative push-to-mute or
  push-to-talk delay is none;
- obs_source_load_deinterlace_mode(mode): obs-rust#2120's rule, a mode past the int
  range is OBS_DEINTERLACE_MODE_DISABLE;
- obs_source_load_monitoring_migration(prev_ver, caps, monitoring_type):
  before 23.2.2 a source with OBS_SOURCE_MONITOR_BY_DEFAULT becomes
  monitor-only and gets all six mixers; before 33.0.0 "monitoring_enabled"
  is stored as the (migrated) type not being none. It takes the saved int64
  type and reads it as an int, as the (int) cast did. The answer is a
  struct: whether to set the mixers and to what, and whether to store
  "monitoring_enabled" and its value.

obs.c.h keeps every obs_data_*() call and setter, in the same order and the
same number of calls: it reads each value, passes it in, and hands the
answer to the setter (obs_source_set_audio_mixers() and obs_data_set_bool()
only when the plan says so, as the two ifs did). The source creation, the
canvas lookup, the private settings and the filter recursion stay as they
were.

The constants are copied into the header (MAKE_SEMANTIC_VERSION(23, 2, 2)
and (33, 0, 0), OBS_SOURCE_MONITOR_BY_DEFAULT, the two monitoring types,
the six-mixer mask and OBS_DEINTERLACE_MODE_DISABLE), so it needs only
stdbool.h and stdint.h; obs.c.h checks each against obs-config.h,
obs-source.h, obs.h and MAX_AUDIO_MIXES with _Static_assert. The new file
joins libobs.core, before obs.c.h, with libobs.pch.h, which includes the new
header; source-sets.json lists it. docs/rust-port/naming.md maps it to
rust/obs-core. The exported symbol set is unchanged (1766); the six
functions are local.

Checked in a scratch harness (not committed) that compiles origin/master's
obs_load_source_type() verbatim next to this one and the moved file, on stub
obs_data and source calls that record every call with its arguments
(doubles and floats by bit pattern, so NaN payloads and -0 count): 10,000,000
loads under ASan and UBSan, at -O0 and -O2, with saved values drawn from the
edges (NaN payloads of both signs, +-inf, -0, FLT_MAX and its neighbours,
subnormals, the int and int64 ends, versions at and around 23.2.2 and 33.0.0
and those plus 2^32), random bit patterns, keys present or missing, caps with
and without the cap, scene, group and filter types, and filters loaded
through the recursion: 859,000,000 recorded calls, equal in order and value.
Deliberately broken moves (each comparison of the volume, balance, delay and
deinterlace rules, the prev_ver cast, both version bounds, the migrated type,
the mixer mask, the type cast) all fail it, except a balance bound of
>= 1.0, which is equivalent.

git log -L on obs_load_source_type shows obs-rust#2058 (balance and delays), obs-rust#2120
(deinterlace mode) and obs-rust#2128 (volume) as the fork's changes; each rule and
its comment moves as it is; the volume's
"volume = INFINITY" becomes "volume = (double)INFINITY" (the same value),
since INFINITY is a float and the C oracle builds with -Wdouble-promotion
-Werror.

Refs obs-rust#2143

* test: Characterize the source load migration and value rules

test_source_load_migration_steps compiles libobs/obs-source-load.c.h into
itself (ASan and UBSan) and calls only its six hidden functions, through
obs-source-load.h. 19 cases pin:

- the header's constants: 0x17020002 (23.2.2), 0x21000000 (33.0.0), the
  cap bit 0x800, the two monitoring types, the mixer mask 0x3F and the
  disabled deinterlace mode;
- prev_ver: 0, 1, INT32_MAX and the step past it, and UINT32_MAX as
  themselves; characterized, not endorsed: an int64 past UINT32_MAX keeps
  its low 32 bits (2^32 + 23.2.1 reads as 23.2.1 and migrates, 2^32 as 0),
  and a negative one wraps (-1 is UINT32_MAX);
- the monitoring migration at, just below and just above 23.2.2 and 33.0.0
  (and 22.0.3, 23.2.0, 23.2.1, 32.255.65535 and 34.0.0): below 23.2.2 a
  source with the cap is monitor-only with all six mixers whatever its type;
  below 33.0.0 "monitoring_enabled" is stored as the type not being none; at
  and past 33.0.0 nothing is stored, for every type and cap;
- prev_ver 0 (never saved) migrating both ways and UINT32_MAX neither;
- each monitoring type and values outside the enum (3, -1, INT_MAX, INT_MIN)
  with no cap, the cap, every other bit and every bit; characterized, not
  endorsed: the saved int64 type is read as an int, so 2^32 is none and
  2^32 + 1 monitor-only;
- a cross of 12 versions, 8 cap sets and 11 types against the rule written
  out;
- the volume: in range as the nearest float (ties to even, subnormals, a
  double below half the smallest subnormal as 0), negative values and -inf
  as 0, FLT_MAX and below as themselves, anything past FLT_MAX as INFINITY
  (characterized, not endorsed: also a value float rounding would take back
  to FLT_MAX), NaN of either sign and any payload as NaN; characterized, not
  endorsed: -0.0 stays -0.0f;
- the balance: 0 to 1 as the nearest float (just under 1 rounds to 1), past
  1 and +inf as 1, negative and -inf as 0, NaN as NaN, -0.0 as -0.0f
  (characterized, not endorsed);
- the delays: 0 up to INT64_MAX as themselves, -1 down to INT64_MIN as 0;
- the deinterlace mode: every enum value, 9, -1, INT_MAX and INT_MIN as
  themselves (the setter disables a mode it does not know, obs-rust#2120), and past
  the int range (INT_MAX + 1, INT_MIN - 1, UINT32_MAX, 2^32 + 1, 2^32 + 5,
  the int64 ends) as disabled, not as the low 32 bits.

The test is in the core suite of the test graph and links libm except on
MSVC. test_source_audio_ranges, test_source_volume_mix and
test_deinterlace_mode_load cover the caller through the real libobs.

Refs obs-rust#2143

* obs-core: Add Tier 1 tests for the source load migration port

The safe API of obs_core::source_load, with todo!() bodies: the constants
(MONITOR_ONLY_BEFORE and MONITORING_ENABLED_BEFORE through
semantic_version(), MONITOR_BY_DEFAULT, the two monitoring types,
ALL_MIXERS, DEINTERLACE_DISABLE), MonitoringPlan (struct
obs_source_load_monitoring), and prev_ver(), volume(), balance(), delay(),
deinterlace_mode() and monitoring_migration().

tests/obs_core/source_load.rs ports test_source_load_migration_steps.c 1:1:
its 19 cases as steps_*, under the same names, in the same order, with the
same values, the "characterized, not endorsed" ones included. Six new
edge_* proptests (4096 cases each) check each function against its rule
written out independently:
- prev_ver() as the low 32 bits of any int64;
- the migration over any u32 version (weighted to 23.2.2 and 33.0.0 +-2 and
  the ends), any caps with and without the cap bit, and any int64 type;
- volume() and balance() over f64 bit patterns (every NaN payload,
  subnormals, both zeros), f32 bit patterns widened, and the 64 doubles
  either side of FLT_MAX, 1 and 0; the in-range result is checked against
  the nearest float found by a search over the float bits, ties to even,
  not against a cast;
- delay() and deinterlace_mode() over any int64, weighted to the int and
  int64 ends.

soldr cargo test -p obs-data --test obs-tests-core -- obs_core::source_load::
fails 24 of 25 with "not yet implemented"; steps_constants, which reads
only the constants, passes.

Refs obs-rust#2143

* obs-core: Port the source load migration and value rules

Ports libobs/obs-source-load.c.h, the source load migration and value rules
of obs_load_source_type(), to the source_load module of rust/obs-core.
obs.c.h stays C around it: every obs_data_*() call and setter, in the same
order and the same number of calls, the source creation, the canvas lookup,
the private settings and the filter recursion. The hybrid libobs drops the
C file and links the Rust shims in its place.

Safe core (src/source_load.rs):
- prev_ver(): the low 32 bits of the saved int64, as the C's cast;
- volume(): 0 when below 0, infinity when above f32::MAX, else the value;
  then as f32 (round to nearest, ties to even, as the C's cast). The
  comparisons are the C's, so NaN passes both and stays NaN, and -0.0 stays
  -0.0;
- balance(): f64::clamp(0.0, 1.0), which is the C's two comparisons
  (NaN and -0.0 pass through), then as f32;
- delay(): u64::try_from, 0 when negative;
- deinterlace_mode(): i32::try_from, DEINTERLACE_DISABLE when past the int
  range;
- monitoring_migration(): the saved type read as its low 32 bits; before
  23.2.2 with MONITOR_BY_DEFAULT, monitor-only with ALL_MIXERS; before
  33.0.0, store enabled as the type not being none.
The module denies clippy's arithmetic, indexing, unwrap, expect, panic,
todo, unimplemented and unreachable lints, keeps no state and takes no
lock.

Shims (src/ffi/source_load.rs): the six functions keep the C signatures.
struct obs_source_load_monitoring is mirrored #[repr(C)] and returned by
value. No pointer crosses. No intentional differences.

C side: the file leaves libobs.core for its own group,
libobs.ported-source-load (LIBOBS_PORTED_SOURCES), whose PCH is float.h,
limits.h, math.h and obs-source-load.h; libobs.pch.h keeps the header for
obs.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. The
exported symbol sets are unchanged and equal: 1766 on the C backend, the
hybrid and libobs-c-reference; the six functions are local in all three,
and the hybrid's come from the Rust archive (no C object of the group in
the hybrid libobs). ci/test_ported_sources.py checks the group on every
host.

test_source_load_migration_steps still compiles the C file into itself,
unchanged. It has no _rust variant: linking it against libobs_rust-static
was tried and fails with 404 undefined references, because the shims'
archive member (an obs_core codegen unit) also holds the views and the other
obs-core shims, which pull in obs-util and obs-media-io members that need
libobs (blog, bcrash, the graphics context, GIO). The real-libobs tests
(test_source_audio_ranges, test_source_volume_mix,
test_deinterlace_mode_load and the scene collection loads) see the swap
through the hybrid.

Tier 1 obs_core::source_load passes 25/25.

Refs obs-rust#2143

* obs-core: Check the source load migration port against the C

rust/obs-c-oracle/oracle/source_load.c compiles the unchanged
libobs/obs-source-load.c.h with its six functions renamed oracle_*, plus
its constants and the layout of struct obs_source_load_monitoring.
tests/obs_core/source_load_parity.rs (13 tests) runs the shim, the C and
the safe core on every input and compares the results exactly: the plan
field by field, the version, delay and mode as integers, the volume and
balance bit for bit (so -0.0 is not 0.0). A NaN must come out as a NaN on
every side; its payload and sign are not compared, since Rust leaves them
unspecified for an f64 to f32 cast and both setters map every NaN alike.

- the 7 constants, and the size, alignment and every offset of the struct,
  against the C;
- the migration exhaustively over the cap (each of the 32 caps bits alone,
  none, all, all but the cap) x 30 types (-3 to 5, the int and int64 ends,
  2^32 +-2 either way) x 80 versions (both bounds +-3, every power of two
  and one below, the ends): 84,000 combinations, every branch reached;
  every major.minor version (65,536) with patches 0 to 3 and 0xffff, with
  and without the cap, for each monitoring type and 3 (2,621,440 calls);
  saved int64 versions (those, +-2^32 and negated) through prev_ver() into
  the migration;
- the value rules over their edges (the 64 doubles either side of 0, 1,
  -1 and +-FLT_MAX, subnormals, the half-ulp and tie cases), ten NaN
  classes, every int64 within 64 of 0, the int ends, UINT32_MAX, +-2^32 and
  the int64 ends; and every 4093rd f32 bit pattern widened with its double
  neighbours (3,148,035 doubles, each through volume() and balance());
- proptests (8192 cases each) over any u32 version, caps and int64 type;
  versions within 2^24 of each bound; any int64 version through prev_ver();
  f64 bit patterns; f32 bit patterns widened; and any int64 value.

Tier 1 gains edge_semantic_version(): semantic_version() against
MAKE_SEMANTIC_VERSION() written out for every major, minor and 16-bit
patch.

The parity module passed 10 runs in a row with fresh seeds.
test_source_load_migration_steps passed 19/19 under ASan and UBSan. The
committed regression files hold the seeds proptest saved while mutants
failed; all pass on the port.

Mutation check (not committed): 41 mutants, 32 in the core and 9 in the
shims, each run against Tier 1 (26 tests) and Tier 3 (13). 40 fail; the one
that survives is equivalent (the balance clamped to 1 - f64::EPSILON, which
rounds to 1.0f). Tier 1 does not reach the shims; Tier 3 kills every shim
mutant (the arguments swapped, the struct's fields reordered or swapped, the
volume and balance crossed, the delay, mode and version pre-mangled, the
mixers forced). A semantic_version() that drops the patch's high byte is
killed by Tier 1 only (Tier 3 builds its versions with the same helper).

Refs obs-rust#2143

* docs: Record the source load migration port

rust/README.md gets the obs-core crate row and a port row for
libobs/obs-source-load.c.h: the six hidden functions, what
obs_load_source_type() keeps (every obs_data_*() call and setter in the same
order and number, the source creation, the canvas lookup, the filter
recursion), the C's comparisons kept (NaN through, -0.0 kept, infinity past
FLT_MAX), the 32-bit truncations characterized and not endorsed, why there
is no _rust variant, and what Tier 3 covers. The crate's description and
lib.rs list the module.

port_comparison gets its own bench file, port_comparison/source_load.rs:
1024 loads' worth of saved values (versions either side of 23.2.2 and
33.0.0, with and without the cap, every monitoring type, volumes and
balances in and out of range with a NaN now and then, delays and modes
either side of their ranges) through all six functions, folded into a
checksum both sides must match. On this host (x86_64 Linux, release): Rust
8.92 us, C 14.34 us per 1024 loads; obs_load_source_type() makes these
calls once per source or filter when a scene collection loads, none per
frame.

Fixes obs-rust#2143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: libobs: a NaN or negative source volume isn't rejected and breaks every mix the source is in

2 participants