Skip to content

media-io: port audio-io.c to obs-media-io - #35

Open
chriscoveries wants to merge 52 commits into
masterfrom
port/audio-io-next
Open

chriscoveries wants to merge 52 commits into
masterfrom
port/audio-io-next

Conversation

@chriscoveries

Copy link
Copy Markdown
Owner

Fork-internal CI run for the audio-io.c port (RED, GREEN, oracle, layout+Tier3 parity, guard, exports, mutation-checked). Characterization: obs-rust/obs-studio PR obs-rust#120.

chriscoveries and others added 5 commits October 10, 2026 15:45
cmocka test pinning the current C behavior of libobs/media-io/
audio-io.c ahead of the obs-media-io port (Phase 5). audio-io.c is the
smallest media-io unit not already claimed by an open port order.

- open(): AUDIO_OUTPUT_INVALIDPARAM for unset format/name/rate/speakers
  (no thread spawned, *audio untouched); getters mirror audio_output_info
  (interleaved float stereo: 1 plane / 2 ch / 8-byte block; planar
  16-bit 5.1: 6 planes / 6 ch / 2-byte block).
- connect(): NULL/zero conversion fields fall back to the output info;
  duplicate (callback, param) on one mix is refused while the same
  callback with a different param registers a second input; out-of-range
  mix index and NULL audio return false.
- active(): tracks registered mix inputs through connect/disconnect.
- Thread model: open() spawns the input thread immediately and the
  callback fires on the audio clock.
- Characterized crashes (not endorsed): the unguarded NULL getters and,
  with no obs core running, audio_output_open itself die by signal
  (the spawned thread dereferences obs->name_store on entry) - each
  pinned in a forked child with cmocka's signal handlers reset.

The behavioral pins need a running obs core (obs_startup), which needs
a display on Linux; they skip in the headless gate and run under
xvfb-run.

Refs #45

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=f3d2e26bde1bcfec8370af8c615fa43998fc9ae9 secs=350 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791672334,"gate":"rust/all/fmt","host":"linux-x86_64","key":"f06beafdad8c0e6401d54ec504cdbb4c6ff8cc9c99298d7770b1042156188009","lane":"lint","parents":["b3cc16f7cbb177da70d2d0997a15d111f7dee3ec"],"secs":199,"stamp":"68289f5197c34c3b485811e11aef0a06","tree":"f3d2e26bde1bcfec8370af8c615fa43998fc9ae9","v":1,"via":"run"}
Ci-Attestation: {"at":1791672334,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"f06beafdad8c0e6401d54ec504cdbb4c6ff8cc9c99298d7770b1042156188009","lane":"lint","parents":["b3cc16f7cbb177da70d2d0997a15d111f7dee3ec"],"secs":199,"stamp":"ea4878636b524b67d0b5a5c00246cd9b","tree":"f3d2e26bde1bcfec8370af8c615fa43998fc9ae9","v":1,"via":"run"}
Ci-Attestation: {"at":1791672334,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"9b440df8274dd21e1d86abf9f72adc95f209321fa7b3613730625747620dda42","lane":"rust-test","parents":["b3cc16f7cbb177da70d2d0997a15d111f7dee3ec"],"secs":78,"stamp":"9a81bd835884cc8f59413b7b65a44cac","tree":"f3d2e26bde1bcfec8370af8c615fa43998fc9ae9","v":1,"via":"run"}
Ci-Attestation: {"at":1791672334,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"b6e993eabe33d303d6a813f6a7b6c6c5edf09ddebf517c252f712b9d95b33f63","lane":"tier2-linux","parents":["b3cc16f7cbb177da70d2d0997a15d111f7dee3ec"],"secs":71,"stamp":"8e4d35b0e6cf8b077f8de1178e0f2bfa","tree":"f3d2e26bde1bcfec8370af8c615fa43998fc9ae9","v":1,"via":"run"}
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=18904b28bd85ff6ff08ce80f10dae94dda139a76 secs=38 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791675132,"gate":"rust/all/fmt","host":"linux-x86_64","key":"ba65b923f501ad750e65692f42aaa0a23a3021236d6ae0efd3f1c94918d7cee1","lane":"lint","parents":["325a49d29d0d9051e6b473e980fad71b822c6f87"],"secs":5,"stamp":"db7e536db53a4bb710d35628331746f3","tree":"18904b28bd85ff6ff08ce80f10dae94dda139a76","v":1,"via":"run"}
Ci-Attestation: {"at":1791675132,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"ba65b923f501ad750e65692f42aaa0a23a3021236d6ae0efd3f1c94918d7cee1","lane":"lint","parents":["325a49d29d0d9051e6b473e980fad71b822c6f87"],"secs":5,"stamp":"62b64d1aa0d162a22ecf50075452742a","tree":"18904b28bd85ff6ff08ce80f10dae94dda139a76","v":1,"via":"run"}
Ci-Attestation: {"at":1791675132,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"8ab76ba0fdab0ca2f07ef85c35d69bdce29faac588a2f8d7b312b2cd664d174e","lane":"rust-test","parents":["325a49d29d0d9051e6b473e980fad71b822c6f87"],"secs":21,"stamp":"eb5d4333df52d26eb3ebf743f506d30b","tree":"18904b28bd85ff6ff08ce80f10dae94dda139a76","v":1,"via":"run"}
Ci-Attestation: {"at":1791675132,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"ee43101ce8b5a6c42ef660cf7f6f55c3532aaadab25c2ee4811df6d285c824a2","lane":"tier2-linux","parents":["325a49d29d0d9051e6b473e980fad71b822c6f87"],"secs":12,"stamp":"2fa187fac20ed6705d15911748c303f8","tree":"18904b28bd85ff6ff08ce80f10dae94dda139a76","v":1,"via":"run"}
…ier 1 test

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…e path, audio thread (GREEN)

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ports, CMake guard

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=b0d37c50648fedd90d45a53a68682687375723fd secs=38 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791676261,"gate":"rust/all/fmt","host":"linux-x86_64","key":"513bbe2674affe21c0e4bb62291449daf078db08f0afd1a8231ba5359326d7fb","lane":"lint","parents":["0777204d9f936a2e9741dfefb798b605cd1a6de2"],"secs":6,"stamp":"860600ead55f5d4135241a44f340641a","tree":"b0d37c50648fedd90d45a53a68682687375723fd","v":1,"via":"run"}
Ci-Attestation: {"at":1791676261,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"513bbe2674affe21c0e4bb62291449daf078db08f0afd1a8231ba5359326d7fb","lane":"lint","parents":["0777204d9f936a2e9741dfefb798b605cd1a6de2"],"secs":6,"stamp":"f2f120d298dd824d6b5a0fd3248193d0","tree":"b0d37c50648fedd90d45a53a68682687375723fd","v":1,"via":"run"}
Ci-Attestation: {"at":1791676261,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"b26e7cff950126054ff8e439b9048491024a6da880c204bcda54f049530fdae9","lane":"rust-test","parents":["0777204d9f936a2e9741dfefb798b605cd1a6de2"],"secs":23,"stamp":"055233e0bff991cfc781e1ad9c94fd28","tree":"b0d37c50648fedd90d45a53a68682687375723fd","v":1,"via":"run"}
Ci-Attestation: {"at":1791676261,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"3e0d14b2277d8ea03c5a75043d7c71df4d74b33b758b590a4bc921ef80ede97e","lane":"tier2-linux","parents":["0777204d9f936a2e9741dfefb798b605cd1a6de2"],"secs":9,"stamp":"05076951ef38cb25cdaf8189056f21e4","tree":"b0d37c50648fedd90d45a53a68682687375723fd","v":1,"via":"run"}
zackees and others added 4 commits October 10, 2026 19:53
…ind)

.github/workflows/sanitizers.yaml runs rust/tools/sanitize/sanitize.sh once
per tool on ubuntu-26.04. Each job builds the tree with that tool's flags
(ENABLE_RUST_LIBOBS selectable), runs every cmocka test under it, launches OBS
headless under Xvfb with a fresh profile and closes it with SIGINT after a
timeout, then writes triage.py's summary to the job summary and uploads the
logs. It is triggered by workflow_dispatch (tools, launch time, Rust libobs,
fail-on-findings) and by PRs that change the harness.

- sanitize.sh: one script for Ubuntu and NixOS (shell.nix); valgrind runs with
  QT_ENABLE_REGEXP_JIT=0 (the PCRE2 JIT memfd is opaque to it) and full paths.
- install-ubuntu-deps.sh: the Tier 2 image's package list, read from
  rust/tools/linux-validate/Dockerfile, plus valgrind/Xvfb/Mesa/D-Bus.
- triage.py: counts a report only where OBS code is where it happens. TSan
  races must have OBS frames on both accesses; valgrind leaks are ignored after
  a crash. These are the rules used to file obs-rust#128, obs-rust#133 and obs-rust#160.

Refs obs-rust#143

Local-Gate: v1 tree=689bce76047a4fe654972487d26acc006458444b secs=177 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791677636,"gate":"rust/all/fmt","host":"linux-x86_64","key":"2f269309edac4bdcfec213dd1ac4f955d0fc07c9ab43a823ee2504849242caee","lane":"lint","parents":["29e2dfa5cb3ee8187bb78e37703980618e066026"],"secs":15,"stamp":"c5bcc4177ae6beb2bd2776139d126bd4","tree":"689bce76047a4fe654972487d26acc006458444b","v":1,"via":"run"}
Ci-Attestation: {"at":1791677636,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"2f269309edac4bdcfec213dd1ac4f955d0fc07c9ab43a823ee2504849242caee","lane":"lint","parents":["29e2dfa5cb3ee8187bb78e37703980618e066026"],"secs":15,"stamp":"245d40fa95a10eede9c886c760824cc6","tree":"689bce76047a4fe654972487d26acc006458444b","v":1,"via":"run"}
Ci-Attestation: {"at":1791677636,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"16a68186c17f58e2766c2dbe062436d7fb710f35ed72eb3faf1db90acd343b1d","lane":"rust-test","parents":["29e2dfa5cb3ee8187bb78e37703980618e066026"],"secs":43,"stamp":"4a7cd87eb2a7baa50be72ee569262fea","tree":"689bce76047a4fe654972487d26acc006458444b","v":1,"via":"run"}
Ci-Attestation: {"at":1791677636,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"1cc0c2a2f3093a51c0f591ce0003f91f81c96c44631c9b4ead2221445afe3995","lane":"tier2-linux","parents":["29e2dfa5cb3ee8187bb78e37703980618e066026"],"secs":118,"stamp":"1a0fc099a8a5226a3570900284acd8b2","tree":"689bce76047a4fe654972487d26acc006458444b","v":1,"via":"run"}
From the first workflow run (obs-rust#176):

- UBSan prints to stderr even with log_path set, and recovers, so a passing
  test or the app's stderr can carry reports. triage.py now also scans the
  tests' stdout logs and app.log, counting a report seen twice once. This
  surfaced obs-rust#173 and obs-rust#174, which the exit codes and log files hid.
- TSan's own crash reports (ERROR: ThreadSanitizer: SEGV) are counted, not just
  WARNING races.
- Known tool limitations are listed but not counted: under valgrind,
  test_pipe's missing-binary case (posix_spawn runs as a plain fork) and
  test_svt_av1 (VEX temporary storage exhausted).
- A crash in OBS code under valgrind is a finding; --tool= overrides the tool
  that the directory name implies.
- sanitize.sh gives valgrind 240 s between SIGINT and SIGKILL.

Refs obs-rust#143

Local-Gate: v1 tree=6ce7acd50e76b91ceacc4223492de8b5168cfd0a secs=69 lanes=lint:reused@9b503e30ab5a,rust-test:reused@3f31f0ee7558,tier2-linux:run
Ci-Attestation: {"at":1791679651,"gate":"rust/all/fmt","host":"linux-x86_64","key":"9b503e30ab5a1e42eb712e1a4c1ee6ed8eb7dca395f6b148e613506b5e1ed900","lane":"lint","parents":["986e0d1d601052e07301615d44ec84fa61a0a504"],"secs":null,"stamp":"d39dfc8d476574f6ef491d23a621c450","tree":"6ce7acd50e76b91ceacc4223492de8b5168cfd0a","v":1,"via":"reused"}
Ci-Attestation: {"at":1791679651,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"9b503e30ab5a1e42eb712e1a4c1ee6ed8eb7dca395f6b148e613506b5e1ed900","lane":"lint","parents":["986e0d1d601052e07301615d44ec84fa61a0a504"],"secs":null,"stamp":"d09711598f207f5d9fc803a530960f15","tree":"6ce7acd50e76b91ceacc4223492de8b5168cfd0a","v":1,"via":"reused"}
Ci-Attestation: {"at":1791679651,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"3f31f0ee75580fa32253bf463998aef2645b379a5f217d18857a16dda768c645","lane":"rust-test","parents":["986e0d1d601052e07301615d44ec84fa61a0a504"],"secs":null,"stamp":"80872b939dcb70d5e2c4e0f56f82d00e","tree":"6ce7acd50e76b91ceacc4223492de8b5168cfd0a","v":1,"via":"reused"}
Ci-Attestation: {"at":1791680917,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"98e730162a506b503ad495e8f240654ec5fc298a3ecad31b046c19df7c19b700","lane":"tier2-linux","parents":["986e0d1d601052e07301615d44ec84fa61a0a504"],"secs":69,"stamp":"9a438c39712c6aff006d694641146293","tree":"6ce7acd50e76b91ceacc4223492de8b5168cfd0a","v":1,"via":"run"}
…_LIBOBS=ON

rustup's auto-install of rust-toolchain.toml is deprecated (rust-lang/rustup#4836)
and was what broke Tier 2 after the 1.99.0 pin (obs-rust#180); install it explicitly,
as the Tier 2 image now does (obs-rust#185).

Refs obs-rust#143

Local-Gate: v1 tree=cf745e8b9398beee80d989502785c338f51992bc secs=93 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791687772,"gate":"rust/all/fmt","host":"linux-x86_64","key":"9c48a41145f4708d98a900d74ec2ecf4c58436ff012a23d08cd98e76fd12036f","lane":"lint","parents":["d6e212fb5c0f578581356f8f5850a20ba9e38890"],"secs":17,"stamp":"1a34a829bd3c4e83d6c4d4f45de6bb20","tree":"cf745e8b9398beee80d989502785c338f51992bc","v":1,"via":"run"}
Ci-Attestation: {"at":1791687772,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"9c48a41145f4708d98a900d74ec2ecf4c58436ff012a23d08cd98e76fd12036f","lane":"lint","parents":["d6e212fb5c0f578581356f8f5850a20ba9e38890"],"secs":17,"stamp":"354e69df08751212ba17cbc1a14bf4be","tree":"cf745e8b9398beee80d989502785c338f51992bc","v":1,"via":"run"}
Ci-Attestation: {"at":1791687772,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"7a8e339c11cfe3331cbc43e10651bae59647e856536b7bccf7ca151f6ec927ea","lane":"rust-test","parents":["d6e212fb5c0f578581356f8f5850a20ba9e38890"],"secs":41,"stamp":"2e69978320c00db4ae2aa7918b6add44","tree":"cf745e8b9398beee80d989502785c338f51992bc","v":1,"via":"run"}
Ci-Attestation: {"at":1791687772,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"9fc9f5fb384b754a913b3b9656abc68e70a3022f42e3eaf01e5ba966fcdfeafb","lane":"tier2-linux","parents":["d6e212fb5c0f578581356f8f5850a20ba9e38890"],"secs":34,"stamp":"3719087a0c66b49db58d7d9ba6fce886","tree":"cf745e8b9398beee80d989502785c338f51992bc","v":1,"via":"run"}
…loud Tier2

Codex-review-driven additions, all failing on the current port:
- tests/audio_io_core.rs: safe-API core tests (does not compile — the core
  is still unsafe-FFI-shaped), incl. the output-dispatch mutation guard,
  NULL output-callback connect (accepted, skipped — documented deviation
  from the C's crash), NULL input_callback no-op tick (currently panics on
  unwrap), re-entrant disconnect/connect inside an output callback, and an
  allow_clipping clamp check.
- tests/audio_io_parity.rs: proptest over marker values (NaN/out-of-range),
  timestamp deltas, and 1-3 inputs comparing the full output sequence.
- test/cmocka/test_audio_io.c: the four obs_startup-gated cases assert
  instead of skipping so headless Tier 2 can't pass silently.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Copy link
Copy Markdown
Owner Author

Source review of 04b1b81; not compiled or reproduced locally.

Three remaining repair areas:

  1. do_audio_output retains Vec iter_mut/element borrows across a callback, while reentrant connect can reallocate that Vec. Preserve C's reverse-index traversal: reacquire one index each iteration, copy callback/param/resampler/clipping into locals, end all list/element borrows, then invoke the callback while keeping the recursive lock. A whole-list snapshot changes removal semantics

  2. The worker holds &mut AudioOutput for its lifetime, and Drop obtains another exclusive reference before joining. Connect/disconnect also create &mut handles. Use shared access with properly synchronized interior state; a small owner/shared-state split can keep the JoinHandle outside the worker's shared object. Stop/join must complete before exclusive destruction, without holding the input lock. Also initialize the recursive mutex in stable storage, rather than initializing on the stack and moving it

  3. Windows needs an explicit boundary: Rust uses libc pthread APIs and the unconditional audio oracle uses POSIX timing/headers. The smallest bounded option is a documented Unix-first port: cfg-gate implementation/oracle/tests, retain audio-io.c on Windows, and use the existing unix export markers. A full Windows backend is separate work

Acceptance: deterministic C-vs-Rust regressions for callback-driven Vec growth, self-disconnect, earlier-input removal and concurrent connect/disconnect; preserve callback order and close/join lifetime. The current MAGIC-tagged manual ticks still race real worker ticks, so first serialize the driver or use channel-controlled real-worker callbacks. Then run required lint/unit gates, unchanged C tests OFF/ON, layout/export parity and the platform matrix. Current NULL-resampler stubs do not establish successful-resampling parity.

Keep the ownership/reentrancy repair together; portability can be a separate commit. Follow the policy's unsafe-location rule or record an exception before implementation.

chriscoveries and others added 8 commits October 11, 2026 03:56
open() spawns a real audio thread on both sides, whose ~21 ms worker
ticks race the driver's explicit oracle_audio_tick/tick_for_test calls
and the shared TICK recorder. Review comment on fork PR #35:
- DRIVER mutex held for every test body so parallel #[test]s cannot
  interleave into TICK/ORDER.
- Every recorded action now gates on the timestamp: input callbacks
  already filtered start_ts==MAGIC, but output callbacks pushed into
  TICK whenever it was Some; record_output and output_full_* now also
  require data.timestamp in [MAGIC, MAGIC+1e9), which real worker
  ticks (os_gettime_ns ~1e18) never enter.
No production-code change; all 4 tests still pass.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Deterministic C-vs-Rust regressions (fork PR #35 acceptance):
- self_disconnect_parity: oracle removes only itself, the port's
  iter_mut().rev() drops the whole tail — 1 vs 0 inputs left.
- earlier_input_removal_parity: [A,B,C] with B removing A => order
  [3,2,2] (shifted element re-invoked) — locks the index-read
  semantics in for the rewrite.
- vec_growth_parity: a callback connects a 5th input; the oracle's
  fixed bound yields [4,3,2,1], the port yields [4,3,2].
- concurrent_connect_disconnect_parity: churn from another thread
  across 10 driven ticks + quiesced final-tick order.
- audio_io_core.rs call sites move to the new safe API (connect takes
  Option<&audio_convert_info>, disconnect is &self) — fails to compile
  on the current unsafe-FFI-shaped core: RED.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Fork PR #35 review: the worker held &mut AudioOutput for its whole life
while connect/disconnect shims minted another &mut — aliasing UB ahead of
the lock. And do_audio_output held mix.inputs.iter_mut().rev() across
the callback, so a re-entrant connect could realloc the Vec under a live
iterator (self-disconnect dropped the tail: oracle 1 vs port 0 inputs;
push mid-tick lost the last element: [4,3,2] vs oracle [4,3,2,1]).

Restructure, matching the C one-for-one:
- AudioOutput is the owner (info getters, JoinHandle, initialized); the
  state the thread and FFI callers share lives in a Box<Shared> created
  before the recursive pthread mutex is initialized at its final
  address (POSIX forbids moving an initialized mutex).
- The worker gets a &Shared only — no &mut AudioOutput or &mut Shared
  exists after open. connect/disconnect/active/tick_for_test are &self;
  mixes sit behind input_mutex + UnsafeCell with borrows scoped to a
  single statement.
- do_audio_output keeps C's reverse-index traversal: bound fixed at
  entry, inputs[i-1] re-read per iteration, callback/param/resampler/
  allow_clipping copied into locals, every borrow ended, callback
  invoked while still holding the recursive lock. Mid-dispatch removal
  past the loop index is skipped instead of calling freed tail memory
  (documented deviation; the C's stale-tail call has no defined
  equivalent).
- Drop: stop + join complete before the shared box is freed, and the
  join never runs under the input lock.
- NULL input_cb: tick treated as failed (C faults). NULL output cb:
  connect accepted, dead call skipped (C faults next tick). Both
  documented at the top of audio_io.rs.
- Test determinism: a shared DRIVER mutex serializes MAGIC-stamped
  manual ticks in both test files (the real worker never produces MAGIC
  timestamps); the parity TICK record is replaced per driven tick so a
  test that never takes its record cannot poison the next case.

unsafe stays confined to the UnsafeCell/FFI sites with SAFETY comments;
the exception is recorded for the tracking issue.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Unix-first portability per fork PR #35 review: libc exposes no pthread
API on Windows, so the port, its shims, oracle and tests are
#[cfg(unix)] / #![cfg(unix)] and libobs keeps building
media-io/audio-io.c on Windows (same ENABLE_RUST_LIBOBS +
PLATFORM_ID:Windows guard shape as util/utf8.c). The 10 audio_output_*
exports get the ' unix' marker so rust.cmake does not /EXPORT them on
Windows — enforced by obs-util's export_list scan. A Windows backend
behind the same safe API is separate work (noted in audio_io.rs).

Also pins the audio_io_parity proptest-regressions file (repo
convention: bitstream/config_file ship theirs).

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- ffi shims wrapped in the scan-visible #[cfg(unix)] mod unix { } block
  with pub use unix::* (export_list.rs finds markers this way)
- unused mut on &self call sites, drop(ctx) -> final borrow, unsafe
  fn record -> fn, range loop -> enumerate().take(n), nested unsafe
  blocks flattened

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
obs_startup needs an X display; on headless Linux every obs-dependent
case silently skipped (!obs_up -> skip). The fork PR #35 review requires
a Tier 2 that cannot skip: the cases now assert obs_up loudly, and the
test is registered via xvfb-run -a where xvfb exists (validate image
gains the xvfb package) so they actually run — failures like an
always-false audio_output_connect can no longer hide behind a skip.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=c8db6ae56f567359dffd12caa5966158ab439936 secs=33 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791693456,"gate":"rust/all/fmt","host":"linux-x86_64","key":"cd423e03662fdf0d13cd05a924d8451ac1dcaa75ee035f6f256a7b48857f7b95","lane":"lint","parents":["f03b6ed91acbb9db863d37858469f1995b248ad9"],"secs":5,"stamp":"5d0ec5461ad708d9efedb55ff851aefd","tree":"c8db6ae56f567359dffd12caa5966158ab439936","v":1,"via":"run"}
Ci-Attestation: {"at":1791693456,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"cd423e03662fdf0d13cd05a924d8451ac1dcaa75ee035f6f256a7b48857f7b95","lane":"lint","parents":["f03b6ed91acbb9db863d37858469f1995b248ad9"],"secs":5,"stamp":"2127baeef10d9722e392e4e1d8f43ff9","tree":"c8db6ae56f567359dffd12caa5966158ab439936","v":1,"via":"run"}
Ci-Attestation: {"at":1791693456,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"e53b1970f5af9aa3341c8c5341de995d6153585e927c48db3af11d6a8ffd5f3d","lane":"rust-test","parents":["f03b6ed91acbb9db863d37858469f1995b248ad9"],"secs":20,"stamp":"3fcd1fe0ce7b781cbcaf03ea972473c9","tree":"c8db6ae56f567359dffd12caa5966158ab439936","v":1,"via":"run"}
Ci-Attestation: {"at":1791693456,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"2add412b2ec51597e865ca2744b1b89e7e1d3a898d52de9f57597c5ba43a02c1","lane":"tier2-linux","parents":["f03b6ed91acbb9db863d37858469f1995b248ad9"],"secs":8,"stamp":"af2df4e9aa76ea57216a87a6d914f2b6","tree":"c8db6ae56f567359dffd12caa5966158ab439936","v":1,"via":"run"}
Fork PR #35 review items:
- fresh_clamp_snapshot_parity: input cb connects an allow_clipping input
  to a mix that was empty at the active_mixes snapshot. C re-checks
  !mix->inputs.num at clamp time, so the new mix is clamped and the
  unclamped row carries the marker (recorded 2.5f); the port skips it
  behind the stale mask (recorded 0.0).
- resample_parity: a rate-differing conversion must create a resampler
  and run the resample path; the NULL stub refuses the connect on both
  sides, so the assertion fails until a real resampler exists.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The C's clamp pass checks !mix->inputs.num at clamp time — after the
input callback ran — so a mix that gained an input mid-callback is
clamped anyway. The port reused the mask snapshotted for the callback,
skipping the fresh mix and leaving its buffer_unclamped zeroed.
input_and_output now takes a second locked snapshot for the clamp pass;
active_mixes stays the callback's mask. fresh_clamp_snapshot_parity goes
RED->GREEN (2.5f marker now reaches the unclamped row on both sides).

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

chriscoveries commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner Author

Source review refreshed to e8edca2cdd5f59a7fc5091a4e998e5603c264e61; no local compilation or reproduction.

Resolved ordering: FFI close now calls stop_and_join before reconstructing the Box, and the parity fixture now exercises that FFI path. This is the right direction; retain it. The earlier AtomicPtr publication, fail-closed churn gates and bounded startup waits also remain fixed.

Remaining ownership boundary: thread is still a plain Option:470–473, and stop_and_join mutates it with take():1050–1059. Meanwhile callback connect/disconnect/active construct a whole &AudioOutput:226–289. If a callback is inside one of those calls when external close takes the slot, the write overlaps memory covered by that shared owner reference. Being disjoint from shared is insufficient: thread is still inside the borrowed owner and outside UnsafeCell. This is a source-derived aliasing issue under Rust's shared-reference rules, not a reproduced failure.

The smallest repair can keep the new ordering: use an appropriately interior-mutable lifecycle slot with explicit sole-close discipline, or arrange callback operations to borrow only Shared without constructing &AudioOutput. Do not hold the input lock across join. Also resolve the separate direct Rust Drop path:1072–1093: it still obtains &mut AudioOutput before joining, while public open/connect allow a boxed owner and callback re-entry. The comment that callers accept the C caveat does not establish a sound Rust shutdown-before-drop contract. Keep self-close forbidden, but describe Rust self-join according to JoinHandle's documented possible panic, rather than claiming the safe join call is intrinsically UB.

The new overlap regression needs two corrections:

  1. STOP_AND_JOIN_BEGINS is process-global, while the callback waits only for a nonzero count. Other tests in this same binary already close outputs, so an earlier or concurrent close can release this callback before this handle's closer starts. Use a per-output hook/token and an entered/release/completed handshake. A global baseline alone still permits another concurrent closer to satisfy it. Acceptance: close a different output first and concurrently, and verify neither releases the parked target callback.
  2. Timeout assertions at lines 394 and 409 can unwind and free ctx while raw pointers remain in use. The first path never closes the opened handle; the second drops/detaches close_t. For example, pause the closer after audio_output_close returns but before its closed.store, then let the main deadline expire. Retain context through worker and closer completion on every exit. A subprocess timeout is a bounded way to test deliberately broken shutdown without freeing live callback state. This is fixture failure-path analysis, not an observed runtime failure.

Remaining acceptance from the previous pass: compare all three counters after close, rather than only the self-disconnecting count; either force lock contention with a held callback or describe the churn test as inter-tick churn. The C/Rust controlled shutdown comparison, combined audio/threading-oracle symbol-origin check and unsafe-location policy decision remain separate gates. Earlier owner consolidation c5af339d remains a commit-local net 112-line reduction, not repository-wide savings.

A smaller fixture simplification is available in this head's ICF workaround: store/reuse one callback value per C/Rust side and distinguish the two inputs with different stable, live non-zero-sized parameter tokens. Their callbacks currently ignore the parameter. This uses the existing (callback, param) identity instead of duplicate callback bodies plus black_box markers; Rust does not promise distinct identities for equivalent function bodies. Proposed simplification, not an observed failure of the new workaround.

CI-observed for parent 2785f6a, not the new e8edca2 head: run 38143075958, gate 114480736064 and Tier 2 114480736369 have source checkout ref: and final git log -1 at 2785f6a0ab4827f380ddb82a4b31bd58cab415d6, separately from ci-main. Ordinary tests passed: audio_io 6/6 including the new overlap test, audio_io_core 6/6, audio_io_parity 14/14, Linux C 72/72 OFF and ON, and identical 1,752-symbol exports. These results do not establish aliasing soundness, that the global seam forced this handle's overlap, safe timeout cleanup, native Windows/macOS results or sanitizer cleanliness. The e8edca2 commit reports local debug/release success; I have not independently verified new-head execution.

chriscoveries and others added 9 commits October 11, 2026 05:44
A single UnsafeCell<[AudioMix;6]> meant a &mut on the input registry and
an unlocked &mut on a mix buffer came from one cell — a broad mutable
borrow pattern that overlapped the tick's buffer fill/clamp. Each mix
field is now its own cell: inputs (registry, only under input_mutex)
and buffer/buffer_unclamped (touched only by the thread running the
tick, outside the lock). Cell pointers are taken as raw pointers where
no borrow is needed (do_audio_output's buf_ptr). No behavior change:
all non-RED tests stay green.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Fork PR #35 items 3+4: explicit test ticks raced the real audio thread —
a worker tick could interleave between an oracle tick and the matching
port tick, mutating buffers and the registry under the same state the
test was reading. Every driven-tick test now runs on a no-worker pair:
oracle_audio_output_open_no_thread (same object minus stop_event and
pthread; close destroys the mutex then frees inputs like the C) and
AudioOutput::open_no_worker (open minus spawn). The concurrent test
still exercises cross-thread connect/disconnect through the hammer
threads; only the tick is exclusive. Shared TICK/ORDER statics are
drained after closes via close_pair so nothing leaks between tests.
audio_io.rs's input_thread_runs keeps the real worker — the thread is
its subject.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… update

Replace the NULL resampler stubs with a deterministic nearest-sample
resampler (rate-scaled frame count, growable per-plane buffers) so the
parity suite exercises the real resample path: resample_parity connects
a 24k input on a 48k output and observes 512 frames of the 1024 tick,
proving conversion ran identically on both sides. Tier-1
connect_disconnect now expects the differing-conversion connect to
succeed (resampler exists) and disconnects the extra input.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=b49fdf74aa9dbf095b003123e5427c66b13acb7f secs=32 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791698572,"gate":"rust/all/fmt","host":"linux-x86_64","key":"82c20578a8d5f5274fcf050c859f0f952ff67f2e1c3853bee3359a61ed3b002a","lane":"lint","parents":["9bf4117ebc284940925be6aab89d55dd53ad03ed"],"secs":5,"stamp":"5f891de347cb6072efc902ed6436d868","tree":"b49fdf74aa9dbf095b003123e5427c66b13acb7f","v":1,"via":"run"}
Ci-Attestation: {"at":1791698572,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"82c20578a8d5f5274fcf050c859f0f952ff67f2e1c3853bee3359a61ed3b002a","lane":"lint","parents":["9bf4117ebc284940925be6aab89d55dd53ad03ed"],"secs":5,"stamp":"5391fc479d9be49eae07d5c668e8afda","tree":"b49fdf74aa9dbf095b003123e5427c66b13acb7f","v":1,"via":"run"}
Ci-Attestation: {"at":1791698572,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"4d1f436d4c7ccc8af42591f1fd35945e2eef7cefa0117c9645dc46ba630ef6cb","lane":"rust-test","parents":["9bf4117ebc284940925be6aab89d55dd53ad03ed"],"secs":16,"stamp":"236331555a6a7ad8284d4ba974f4a8ce","tree":"b49fdf74aa9dbf095b003123e5427c66b13acb7f","v":1,"via":"run"}
Ci-Attestation: {"at":1791698572,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"54ef1a4927d255af7c83c658dca360627fe7d1ba65a20db8c0db3763fa9cd738","lane":"tier2-linux","parents":["9bf4117ebc284940925be6aab89d55dd53ad03ed"],"secs":12,"stamp":"052a4f5fc7fca78448936f58610510cb","tree":"b49fdf74aa9dbf095b003123e5427c66b13acb7f","v":1,"via":"run"}
push.yaml's tag pipeline is upstream OBS's: it ships the ENABLE_RUST_LIBOBS=OFF
builds, takes only OBS version tags, and its create-release job waits on
Windows signing that only runs under obsproject. release-rust.yaml is a
workflow_dispatch that:

- checks the version against rust/libobs-rust/Cargo.toml and that the
  obs-studio-rust-v<version> tag is free;
- builds Linux x86_64, macOS arm64 and Windows x64 the way obs-rust/obs-smoke
  does (ENABLE_RUST_LIBOBS default flipped to ON, same soldr as CI);
- fails unless libobs contains Rust code and the Linux build reports
  "OBS-Studio-Rust <version>";
- with publish (the default), creates an unsigned pre-release with the three
  packages and SHA256SUMS. The release creates the tag, so push.yaml's tag
  pipeline doesn't start; publish=false is a full dry run.

Fixes obs-rust#214

Local-Gate: v1 tree=c88009c3d7f390aec7913d20a04f1f07c0ca82f1 secs=110 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791702999,"gate":"rust/all/fmt","host":"linux-x86_64","key":"3f8e4d48a82be15a745f35b7375ac89d97189d1979d5c54b0fbfee66c400374c","lane":"lint","parents":["ce08e85d949038f4455298218f6e416584105106"],"secs":15,"stamp":"a1271225616fbf74bb736f86cd4b499b","tree":"c88009c3d7f390aec7913d20a04f1f07c0ca82f1","v":1,"via":"run"}
Ci-Attestation: {"at":1791702999,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"3f8e4d48a82be15a745f35b7375ac89d97189d1979d5c54b0fbfee66c400374c","lane":"lint","parents":["ce08e85d949038f4455298218f6e416584105106"],"secs":15,"stamp":"59b77b2c730aadeaf2de583b9abe7837","tree":"c88009c3d7f390aec7913d20a04f1f07c0ca82f1","v":1,"via":"run"}
Ci-Attestation: {"at":1791702999,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"bce48527427fe222dab4134237ee291f818ae26ac5ce1c96f6504f9d215c4c09","lane":"rust-test","parents":["ce08e85d949038f4455298218f6e416584105106"],"secs":30,"stamp":"e2600d93dc82bbba906b2a6eec487b18","tree":"c88009c3d7f390aec7913d20a04f1f07c0ca82f1","v":1,"via":"run"}
Ci-Attestation: {"at":1791702999,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"e97cbb58f40bc5612ca556e630e881afc714f7b13f0ce1a58e00adff6df99041","lane":"tier2-linux","parents":["ce08e85d949038f4455298218f6e416584105106"],"secs":65,"stamp":"131e4f3592a1d616d063e88890748f8d","tree":"c88009c3d7f390aec7913d20a04f1f07c0ca82f1","v":1,"via":"run"}
On Wayland the libobs hotkey thread is never told that a key is held:
obs_nix_wayland_hotkeys_platform_is_pressed() always returns false. The
thread polls every 25 ms and releases every binding whose key it cannot
see, so with OBS focused push-to-talk drops right after Qt injects the
press (upstream #10701).

Add obs_nix_hotkey_state, the key state the hotkey thread will read on
Wayland, fed by keys and modifiers held while OBS has keyboard focus. It
is a stub here that behaves like Wayland today.

test_wayland_hotkeys runs the real hotkey thread (obs-hotkey.c on an
isolated core) and plays the wl_keyboard listener and the Qt key filter.

RED: 2 of 4 fail:
- focused_key_holds_push_to_talk: "focused push-to-talk released while
  the key is held (releases 1)"
- focused_modifiers_hold_combination: Ctrl+Shift+F13 released while held
focus_loss_releases_keys and nothing_reported_releases pass (they pin
today's release behaviour).

Reported upstream by rootgordon (#10701).

Refs obs-rust#210.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The libobs hotkey thread polls obs_hotkeys_platform_is_pressed() every
25 ms and releases any binding whose key is not reported as held. On
Wayland that function always returned false, so with OBS focused the
press that Qt injects was undone within 25 ms: push-to-talk only opened
for its release delay (upstream #10701).

Report what Wayland does tell us. obs_nix_hotkey_state records the keys
and modifiers held while an OBS window has keyboard focus, from the
wl_keyboard listener the platform already had, and is cleared when focus
leaves (no release events follow then). is_pressed() answers from it,
as X11 answers from the server. Out of focus nothing changes: Wayland
sends no key events then.

Changes take obs->hotkeys.mutex so they land between poll cycles, so the
mutex is now initialised before the platform layer. The platform also
releases its seat, keyboard and registry on free, as their listeners
point at the freed context.

Root cause identified upstream by thomasza92 in
obsproject/obs-studio#13387, following the analysis on #10701; the mutex
ordering follows aurelleb's obsproject/obs-studio#13661. Reported by
rootgordon.

test_wayland_hotkeys: 4/4 pass (RED: 2/4).

Fixes obs-rust#210.

Co-Authored-By: Aurelle <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Local-Gate: v1 tree=596f93ec437e6ff9f8f95f6ad714a9c172321565 secs=139 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791703567,"gate":"rust/all/fmt","host":"linux-x86_64","key":"09ca4dcde655140f9e3c5b19d913ec82ae3d6d9623dfb37cec39fa6e34367066","lane":"lint","parents":["a07f661139270888843eee9c0a3412670d2dd0e5"],"secs":54,"stamp":"1538831521bad0e9513812fed94330a6","tree":"596f93ec437e6ff9f8f95f6ad714a9c172321565","v":1,"via":"run"}
Ci-Attestation: {"at":1791703567,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"09ca4dcde655140f9e3c5b19d913ec82ae3d6d9623dfb37cec39fa6e34367066","lane":"lint","parents":["a07f661139270888843eee9c0a3412670d2dd0e5"],"secs":54,"stamp":"c81aa36954f9c37fd6de3d5b42266631","tree":"596f93ec437e6ff9f8f95f6ad714a9c172321565","v":1,"via":"run"}
Ci-Attestation: {"at":1791703567,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"49295e7a48240f05a4abe0a792a1081869c52a3f120bc6f37dba766236cee958","lane":"rust-test","parents":["a07f661139270888843eee9c0a3412670d2dd0e5"],"secs":30,"stamp":"674bf77d929ba69894deff377af95825","tree":"596f93ec437e6ff9f8f95f6ad714a9c172321565","v":1,"via":"run"}
Ci-Attestation: {"at":1791703567,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"3461a03f5f791a6021ac0fd2e068e190904e9a062ecb655475786d193132e440","lane":"tier2-linux","parents":["a07f661139270888843eee9c0a3412670d2dd0e5"],"secs":54,"stamp":"cd39e83dad7b791fe5c79a011bdfbe09","tree":"596f93ec437e6ff9f8f95f6ad714a9c172321565","v":1,"via":"run"}
When a v4l2loopback device has a fixed format of another size, for
example after `v4l2loopback-ctl set-caps /dev/video10 "YUYV:640x480"`
with OBS outputting 1280x720, the virtual camera shows interleaved,
distorted rows and never the bottom of the picture (upstream
obsproject/obs-studio#12081, reported by stephematician). VIDIOC_S_FMT
answers with the format the device keeps, but try_connect() ignores it
and keeps scaling to and writing frames of the OBS output size, so
every 1280-pixel row fills two 640-pixel rows on the device.

Move the decision of what to write after VIDIOC_S_FMT into
vcam-format.c, free of ioctls. The function keeps today's behaviour
(use the requested size, accept any pixel format), so 3 of the 4 tests
fail:

- fixed_smaller_device_gets_frames_of_its_size
- fixed_larger_device_gets_frames_of_its_size
- device_fixed_to_other_pixel_format_is_refused

Refs obs-rust#212.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
VIDIOC_S_FMT answers with the format the device will use, which is not
always the one OBS asked for: a v4l2loopback device fixed with
`v4l2loopback-ctl set-caps`, or one a reader already holds open, keeps
its own size. Scale the output to that size and write frames of that
size, and skip a device whose kept pixel format is not YUYV, instead of
writing 1280x720 frames into a 640x480 device and getting interleaved,
distorted rows (upstream obsproject/obs-studio#12081). Log the scaling
when the device size differs from the output size.

Based on upstream obsproject/obs-studio#12082 by stephematician.

fixed_smaller_device_gets_frames_of_its_size,
fixed_larger_device_gets_frames_of_its_size and
device_fixed_to_other_pixel_format_is_refused now pass; 4 of 4 tests
pass.

Fixes obs-rust#212.

Co-Authored-By: stephematician <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Local-Gate: v1 tree=3e5ec05a822538fda3c2eb293c2821db45441718 secs=176 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791703747,"gate":"rust/all/fmt","host":"linux-x86_64","key":"e74fefb1355913fc11abd8982416ca180c5ba47d93b46c650ef4e7e5841e4978","lane":"lint","parents":["9fb8b52c5606894c153a4151f5ed2a5d33bd0d7c"],"secs":81,"stamp":"ddbdf370eb88d8540703cc21addf8c00","tree":"3e5ec05a822538fda3c2eb293c2821db45441718","v":1,"via":"run"}
Ci-Attestation: {"at":1791703747,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"e74fefb1355913fc11abd8982416ca180c5ba47d93b46c650ef4e7e5841e4978","lane":"lint","parents":["9fb8b52c5606894c153a4151f5ed2a5d33bd0d7c"],"secs":81,"stamp":"371315116981320709780d48e9efd45a","tree":"3e5ec05a822538fda3c2eb293c2821db45441718","v":1,"via":"run"}
Ci-Attestation: {"at":1791703747,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"a3c4838fde66eb1a851cc0f55e4fed7b87ab331f724289b76dd75d4a67ea0146","lane":"rust-test","parents":["9fb8b52c5606894c153a4151f5ed2a5d33bd0d7c"],"secs":37,"stamp":"491a7bb052e25bb48dac7261d3156e74","tree":"3e5ec05a822538fda3c2eb293c2821db45441718","v":1,"via":"run"}
Ci-Attestation: {"at":1791703748,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"5e5d1e3cfe8f9879bcf69c24b7953f60363a4bd8a3d4f1fb03684969d0a35b9d","lane":"tier2-linux","parents":["9fb8b52c5606894c153a4151f5ed2a5d33bd0d7c"],"secs":58,"stamp":"aed308c225e9d49f530eea9c50acba9e","tree":"3e5ec05a822538fda3c2eb293c2821db45441718","v":1,"via":"run"}
libobs: Keep Wayland push-to-talk pressed while the key is held
zackees and others added 26 commits October 11, 2026 00:40
Runs daily (09:00 UTC) and on demand with no inputs. Tags
obs-studio-rust-v<crate version>-beta.<YYYYMMDD>, skips a day that already has
one, and ships whichever platforms built and verified; it fails only if none
did.

Refs obs-rust#214

Local-Gate: v1 tree=f560bcd7434661ce5ddf087ad85cf04222766ccf secs=142 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791704427,"gate":"rust/all/fmt","host":"linux-x86_64","key":"6f3d0266fe37163431433ca3d2b30080f48d7392f6d4cfb7ee719f1553cde57b","lane":"lint","parents":["4272b8aaa80bd3c0ce6d9d27566748fc67f7c647"],"secs":65,"stamp":"dfa2da23477f69e160898063007eb327","tree":"f560bcd7434661ce5ddf087ad85cf04222766ccf","v":1,"via":"run"}
Ci-Attestation: {"at":1791704427,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"6f3d0266fe37163431433ca3d2b30080f48d7392f6d4cfb7ee719f1553cde57b","lane":"lint","parents":["4272b8aaa80bd3c0ce6d9d27566748fc67f7c647"],"secs":65,"stamp":"c5006415069523678e4a00c751a04057","tree":"f560bcd7434661ce5ddf087ad85cf04222766ccf","v":1,"via":"run"}
Ci-Attestation: {"at":1791704427,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"d3dd31d9d12cbfbe21eee142c7702308e6e748f8ca5ba7ce6e2425b60b1560d7","lane":"rust-test","parents":["4272b8aaa80bd3c0ce6d9d27566748fc67f7c647"],"secs":24,"stamp":"2c80341527f8657036c0e27eedcbf894","tree":"f560bcd7434661ce5ddf087ad85cf04222766ccf","v":1,"via":"run"}
Ci-Attestation: {"at":1791704427,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"ba9cb4f91b501ddf503ddcd18ec0b11195da57217bb958690574a6b7e044944a","lane":"tier2-linux","parents":["4272b8aaa80bd3c0ce6d9d27566748fc67f7c647"],"secs":52,"stamp":"b672dda32d570948f649c4ff8cdb1bcf","tree":"f560bcd7434661ce5ddf087ad85cf04222766ccf","v":1,"via":"run"}
infra: Release workflow for OBS-Studio-Rust app builds
linux-v4l2: Write virtual camera frames in the size the device kept
infra: Dispatchable sanitizer workflow (ASan/UBSan, TSan, valgrind)
The release workflow (obs-rust#215) tags obs-studio-rust-v*, and obs-stream-rust
has its own v* tags. versionconfig.cmake runs git describe --tags, which
picks the nearest tag of any name, so every macOS build now fails with
'VERSION "obs-studio-rust-v0.1.0" format invalid'.
test_newer_rust_app_tags_are_ignored gets 'obs-stream-rust-v0.1.0'
instead of 33.0.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
git describe now matches [0-9]*.[0-9]*.[0-9]* tags only, so the
obs-studio-rust-v* and obs-stream-rust-v* release tags no longer become
OBS_VERSION. On master this yields 33.0.0-beta6-389-ge226c3d25 again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=6508a45a08599f299f39114cb11353d048048271 secs=209 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791706671,"gate":"rust/all/fmt","host":"linux-x86_64","key":"daa1e8d0b6205a1487fa6e90a16e357f98aecf4499e82a72b8f8d3dd43443ff0","lane":"lint","parents":["34edeca88f45ac6c6e45b1a3804473a30e02da29"],"secs":86,"stamp":"3e9900df8fb872add172b73729a82f36","tree":"6508a45a08599f299f39114cb11353d048048271","v":1,"via":"run"}
Ci-Attestation: {"at":1791706671,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"daa1e8d0b6205a1487fa6e90a16e357f98aecf4499e82a72b8f8d3dd43443ff0","lane":"lint","parents":["34edeca88f45ac6c6e45b1a3804473a30e02da29"],"secs":86,"stamp":"cc03e6d6bd8d392fa642dda2d63a3c00","tree":"6508a45a08599f299f39114cb11353d048048271","v":1,"via":"run"}
Ci-Attestation: {"at":1791706671,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"e66f2e4846ea88cb11f6ba62f22338f31fafec384961c249ff628aa428ddb52e","lane":"rust-test","parents":["34edeca88f45ac6c6e45b1a3804473a30e02da29"],"secs":43,"stamp":"190bf76ae51f1f036eacb34ae877a6a4","tree":"6508a45a08599f299f39114cb11353d048048271","v":1,"via":"run"}
Ci-Attestation: {"at":1791706671,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"f4c368db7e0b440163e58f9e223f549d0cd560382aa5b70c0ace190f258da97b","lane":"tier2-linux","parents":["34edeca88f45ac6c6e45b1a3804473a30e02da29"],"secs":80,"stamp":"5fc4afce6f979d5efdf0d8b21374cf42","tree":"6508a45a08599f299f39114cb11353d048048271","v":1,"via":"run"}
cmake: Only take OBS version tags for the OBS version
obs_avc_keyframe and obs_hevc_keyframe crash on an empty packet whose
data is NULL. The VA-API encoder passes one when an encoder's first
packet holds only parameter sets: obs_extract_avc_headers moves every
unit into the header and leaves no packet data. The start-code search
then computes end - 3 from a NULL end and reads address 0.

Reported upstream as obsproject/obs-studio#13316 by vicho314.

Refs obs-rust#216.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
obs_nal_find_startcode now returns end for an empty range before the
search computes end - 3, as the Rust port in obs-codec already does, so
obs_avc_keyframe and obs_hevc_keyframe return false for (NULL, 0)
instead of reading address 0.

The VA-API encoder no longer outputs a packet when the first encoded
packet holds only parameter sets: they are kept as the header and the
packet is skipped, rather than sent on with NULL data.

Refs obsproject/obs-studio#13316, reported by vicho314.

Fixes obs-rust#216.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Local-Gate: v1 tree=a2933bdf713491cb123d7a77a223dfc081c570d2 secs=129 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791707416,"gate":"rust/all/fmt","host":"linux-x86_64","key":"753adfb004ec6d5317032fe23f5f9a25e22b1c1a178219c3ce4056947d9855ef","lane":"lint","parents":["ee9d21114da7b4107a7c6145bdfdea594a13fe51"],"secs":54,"stamp":"2d9023ca3eead0d69b12bd5463eaadbe","tree":"a2933bdf713491cb123d7a77a223dfc081c570d2","v":1,"via":"run"}
Ci-Attestation: {"at":1791707416,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"753adfb004ec6d5317032fe23f5f9a25e22b1c1a178219c3ce4056947d9855ef","lane":"lint","parents":["ee9d21114da7b4107a7c6145bdfdea594a13fe51"],"secs":54,"stamp":"fecbddbbfceeb6bfabcdb119599d0e57","tree":"a2933bdf713491cb123d7a77a223dfc081c570d2","v":1,"via":"run"}
Ci-Attestation: {"at":1791707416,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"d82c61414ebf992a4b813c7ecf06b34a00feb7cd77a39b767e1f6b61a17a8d31","lane":"rust-test","parents":["ee9d21114da7b4107a7c6145bdfdea594a13fe51"],"secs":30,"stamp":"07ac077319c19861edc8cb01db086c23","tree":"a2933bdf713491cb123d7a77a223dfc081c570d2","v":1,"via":"run"}
Ci-Attestation: {"at":1791707416,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"762ce104c31dfe5b52996591e421813dcb2f9821f5a8a9b066f4d3ac0bbea08d","lane":"tier2-linux","parents":["ee9d21114da7b4107a7c6145bdfdea594a13fe51"],"secs":44,"stamp":"7da405d76263cbc3954a9236c22c748b","tree":"a2933bdf713491cb123d7a77a223dfc081c570d2","v":1,"via":"run"}
obs_get_output_supported_video_codecs(NULL) and the other id-keyed
output getters reach find_output(), which runs strcmp() on the id. The
Settings window passes NULL there when no registered output supports
the stream protocol, which crashes OBS (obsproject/obs-studio#12843,
reported by HanabishiRecca).

The test registers one output type, then calls each getter with NULL in
a forked child and expects the not-found value instead of a crash.

Refs obs-rust#217.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
When no registered output supports the stream protocol,
obs_enum_output_types_with_protocol() never calls back, and the Settings
window passed its uninitialized `output` pointer (in practice NULL) to
obs_get_output_supported_video/audio_codecs(). find_output() then ran
strcmp() on it and OBS crashed while opening Settings
(obsproject/obs-studio#12843, reported by HanabishiRecca).

Initialize the frontend's output id to nullptr, and make find_output()
treat a NULL id as not found so every id-keyed output getter returns its
not-found value instead of crashing. The frontend already handles a NULL
codec list by not filtering encoders.

Fixes obs-rust#217.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Local-Gate: v1 tree=bfd01413d2e2181540fe7c1d543605f8fcf4b94e secs=139 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791707559,"gate":"rust/all/fmt","host":"linux-x86_64","key":"f487ee6ddd2034f123e07ec0be5332e6c7110ac789e9d66d148c12a346bf7808","lane":"lint","parents":["0a800516cdf38a05cba21de15c942c436c40d0e5"],"secs":53,"stamp":"e994bdf6dbb1567af2f64d6c4079e2f5","tree":"bfd01413d2e2181540fe7c1d543605f8fcf4b94e","v":1,"via":"run"}
Ci-Attestation: {"at":1791707559,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"f487ee6ddd2034f123e07ec0be5332e6c7110ac789e9d66d148c12a346bf7808","lane":"lint","parents":["0a800516cdf38a05cba21de15c942c436c40d0e5"],"secs":53,"stamp":"160692bcdd3ad07573f6fde4c3b8491c","tree":"bfd01413d2e2181540fe7c1d543605f8fcf4b94e","v":1,"via":"run"}
Ci-Attestation: {"at":1791707559,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"bb313a18e33e93c590f3d3d37b54eb0c722b9a7db3be29b908c54ff5c8477ea8","lane":"rust-test","parents":["0a800516cdf38a05cba21de15c942c436c40d0e5"],"secs":33,"stamp":"80dc336476ed8ac953c0273373445133","tree":"bfd01413d2e2181540fe7c1d543605f8fcf4b94e","v":1,"via":"run"}
Ci-Attestation: {"at":1791707559,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"6232872e9547a08b8ba4ec77a9f3ecb04cc0fa21633c9197d34edfcee2aa51f7","lane":"tier2-linux","parents":["0a800516cdf38a05cba21de15c942c436c40d0e5"],"secs":53,"stamp":"d5b27c3d34bdd3aa1902e1cc7e1ffea0","tree":"bfd01413d2e2181540fe7c1d543605f8fcf4b94e","v":1,"via":"run"}
libobs, obs-ffmpeg: Handle an empty packet in the keyframe checks
libobs, frontend: Don't crash on a NULL output id in Settings
input_thread_runs destroyed g_input_event and read the callback's
counter before audio_output_close — a late callback could signal a
freed event. Close (stop+join) first, then destroy.

Lane: rd4
Signed-Agent: devin-rd4
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
open/open_no_worker/connect/tick_for_test take pointers whose validity
outlives the call (name, input_param, callback context) or impose a
single-driver rule the type system can't express — mark them unsafe
with per-function contracts and compile_fail doctests proving the
unchecked call does not compile. FFI docs state the same contract;
disconnect/active/drop retain nothing and stay safe.

Lane: rd4
Signed-Agent: devin-rd4
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…se parity

Oracle double now carries a sub-frame remainder (residue -> nonzero
ts_offset on non-integer ratios) and rejects format/speaker changes at
create like a real converter — resample_ts_offset_parity pins the
data.timestamp -= offset shift, resample_failure_parity the rejection.

- activation_during_input_parity: a connect inside input_cb dispatches
  on the same tick while the mask already handed out predates it.
- concurrent_connect_disconnect_parity: churn is gated to the locked
  dispatch window (callback ran -> recursive mutex held) and joined
  before the next tick, so ops never race the unlocked clamp reads.
- real_worker_close_join: a live worker + self-disconnecting callback;
  close stops and joins before any context is freed.

Lane: rd4
Signed-Agent: devin-rd4
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=3deaf202caebba49a31df72328003393bff9d424 secs=40 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791709931,"gate":"rust/all/fmt","host":"linux-x86_64","key":"12e2db5dcec2ad5866f75b7049c539447c5923940dfab27c21ef8e4f51413601","lane":"lint","parents":["5a934b5307bb7e1fc82406eafd01e72d3a4c95e1"],"secs":5,"stamp":"b267001d4913f2398c18d9e9032a88be","tree":"3deaf202caebba49a31df72328003393bff9d424","v":1,"via":"run"}
Ci-Attestation: {"at":1791709931,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"12e2db5dcec2ad5866f75b7049c539447c5923940dfab27c21ef8e4f51413601","lane":"lint","parents":["5a934b5307bb7e1fc82406eafd01e72d3a4c95e1"],"secs":5,"stamp":"e8f64cfe304bd441143e080343e010a4","tree":"3deaf202caebba49a31df72328003393bff9d424","v":1,"via":"run"}
Ci-Attestation: {"at":1791709931,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"a497b4d6be21863cb6ffb8b5cbbdff534add660faaf07d92b2406dc78ae6aca6","lane":"rust-test","parents":["5a934b5307bb7e1fc82406eafd01e72d3a4c95e1"],"secs":21,"stamp":"69db5bda5c33f9101fc53a1959086976","tree":"3deaf202caebba49a31df72328003393bff9d424","v":1,"via":"run"}
Ci-Attestation: {"at":1791709931,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"d0acbd63cb2072143fbe1785e852c09316d659cc48fe36fda31b449c4d173ae4","lane":"tier2-linux","parents":["5a934b5307bb7e1fc82406eafd01e72d3a4c95e1"],"secs":14,"stamp":"2f9e75980b1f251aa19e3008c37c5cd6","tree":"3deaf202caebba49a31df72328003393bff9d424","v":1,"via":"run"}
dstr_left() resizes the destination to pos and then memcpys pos bytes
into it. With pos == 0 the destination array is NULL, and memcpy(NULL,
src, 0) is undefined behaviour. os_generate_formatted_filename() hits
it whenever the format starts with a token (obs-rust#174). test_dstr_zero_len
compiles dstr.c with UBSan aborting on the first report:

  dstr.c:523:3: runtime error: null pointer passed as argument 1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dstr_left() now only memcpys when there is something to copy, so it
never passes the NULL array of an empty dstr to memcpy.
test_dstr_zero_len passes under UBSan.

Fixes obs-rust#174

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=d9265b58d85924f6af1ed9ca903e488a47dc8a0a secs=155 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791710344,"gate":"rust/all/fmt","host":"linux-x86_64","key":"0df2bf9fd1bcc0ef660bcf0a6dc3556735595ddf72c20223cf6d9dee8f539118","lane":"lint","parents":["bfc8c1dc5d93c69cb8316d73c272b998bda7bfcc"],"secs":62,"stamp":"ab00892bc3b3cbdf0a6b670cb9577623","tree":"d9265b58d85924f6af1ed9ca903e488a47dc8a0a","v":1,"via":"run"}
Ci-Attestation: {"at":1791710344,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"0df2bf9fd1bcc0ef660bcf0a6dc3556735595ddf72c20223cf6d9dee8f539118","lane":"lint","parents":["bfc8c1dc5d93c69cb8316d73c272b998bda7bfcc"],"secs":62,"stamp":"5ed7bc8aa223d36d827b3f029e7ff4f2","tree":"d9265b58d85924f6af1ed9ca903e488a47dc8a0a","v":1,"via":"run"}
Ci-Attestation: {"at":1791710344,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"df0baa52b476dd471641ecdd0bf0c33cb12e3844a8e028590f2a47525091ed1c","lane":"rust-test","parents":["bfc8c1dc5d93c69cb8316d73c272b998bda7bfcc"],"secs":33,"stamp":"09861dc608962f9765648120817c3dc5","tree":"d9265b58d85924f6af1ed9ca903e488a47dc8a0a","v":1,"via":"run"}
Ci-Attestation: {"at":1791710344,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"76d009956b90b8068571e386a3104292cdebbdd005cf62a37a0399967457b98b","lane":"tier2-linux","parents":["bfc8c1dc5d93c69cb8316d73c272b998bda7bfcc"],"secs":60,"stamp":"fb7214a9d5b44eed6d4085b558c2c25d","tree":"d9265b58d85924f6af1ed9ca903e488a47dc8a0a","v":1,"via":"run"}
libobs/util: Skip the copy in dstr_left when pos is 0
GCC 14 makes -Wincompatible-pointer-types an error: the double's own
struct type mismatched audio_resampler_t at create/destroy/resample.
The struct now completes the opaque declaration from audio-resampler.h,
so the types are identical and no casts are needed. Verified under
gcc -Werror=incompatible-pointer-types and clang -Werror=incompatible-pointer-types.

Lane: rd4
Signed-Agent: devin-rd4
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=883acc0ae187962834897dfa736ac97fdc0f2ba1 secs=38 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791712047,"gate":"rust/all/fmt","host":"linux-x86_64","key":"d87b23f69ab124aef39668b39ec6e01d97c751d68b1a4171250b92066aebcdc6","lane":"lint","parents":["df347c1bbee63de4abab59a3ee8bfda079be14a3"],"secs":7,"stamp":"515326def0c3ec53832985b776bf7f1b","tree":"883acc0ae187962834897dfa736ac97fdc0f2ba1","v":1,"via":"run"}
Ci-Attestation: {"at":1791712047,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"d87b23f69ab124aef39668b39ec6e01d97c751d68b1a4171250b92066aebcdc6","lane":"lint","parents":["df347c1bbee63de4abab59a3ee8bfda079be14a3"],"secs":7,"stamp":"1514157836b8068cc4bb5ba40165cbae","tree":"883acc0ae187962834897dfa736ac97fdc0f2ba1","v":1,"via":"run"}
Ci-Attestation: {"at":1791712047,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"d652d839e07c699e3ee620d45561731af845a7bc28e51e5c9d4642813dbda4f8","lane":"rust-test","parents":["df347c1bbee63de4abab59a3ee8bfda079be14a3"],"secs":19,"stamp":"bcf30e46b6b31179519c89a1b26ee877","tree":"883acc0ae187962834897dfa736ac97fdc0f2ba1","v":1,"via":"run"}
Ci-Attestation: {"at":1791712047,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"b41e9dc66337249891789424c3096e1811ff13a739b9fc3bfe7d7a89c9974f6b","lane":"tier2-linux","parents":["df347c1bbee63de4abab59a3ee8bfda079be14a3"],"secs":12,"stamp":"55193fb14542f25b4fd170a0bd1a3870","tree":"883acc0ae187962834897dfa736ac97fdc0f2ba1","v":1,"via":"run"}
Adopt the rust-exports.d and tests.d fragment layouts (obs-rust#137):
the 10 audio_output_* exports move to
libobs/cmake/rust-exports.d/obs-media-io-audio_io.txt, and the cmocka
registration (with its xvfb wrapper) to tests.d/test_audio_io.cmake.
The oracle's audio_io.c is audio_io_posix.c so the oracle glob's
*_posix.c Unix gate keeps it off Windows, matching the cfg(unix) module.
The oracle glob compiles it automatically; build.rs drops the explicit
file list.

rust/obs-media-io merges both audio_io.rs sides: the upstream header
types and static-inline helpers stay platform-neutral, and the
audio-io.c port lives in the same file under #[cfg(unix)] mod port,
re-exported flat. The ffi module likewise keeps the upstream struct
mirrors and enum helpers and adds the ten EXPORTed shims in
#[cfg(unix)] mod unix. Duplicated consts, struct mirrors and inline
helpers collapse to the upstream copies; the port calls the shared
c_int->enum helpers and obs_util::util_uint64::mul_div64.

Lane: rd4
Signed-Agent: devin-rd4
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The oracle's layout accessors duplicated the audio_io_inlines oracle's:
upstream's owns them, so audio_io_layout.rs reads those. And rustfmt
indents the port module's body.

Lane: rd4
Signed-Agent: devin-rd4
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=fd7b032aaeaa4a20a3f4fac726aa88ebd0c96d68 secs=117 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791714967,"gate":"rust/all/fmt","host":"linux-x86_64","key":"ce9fa2fc8a0a057375c497b89b5b42a6379142f8897dbb2df02f2e1ac69b9776","lane":"lint","parents":["dc768fd2d99009cba95ccec8d8ccd97531804fc2"],"secs":10,"stamp":"7c5555b53bdba314cf70c09bd9f02bf9","tree":"fd7b032aaeaa4a20a3f4fac726aa88ebd0c96d68","v":1,"via":"run"}
Ci-Attestation: {"at":1791714967,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"ce9fa2fc8a0a057375c497b89b5b42a6379142f8897dbb2df02f2e1ac69b9776","lane":"lint","parents":["dc768fd2d99009cba95ccec8d8ccd97531804fc2"],"secs":10,"stamp":"6ae0156b3e0c8350fa0777dee40ffe5c","tree":"fd7b032aaeaa4a20a3f4fac726aa88ebd0c96d68","v":1,"via":"run"}
Ci-Attestation: {"at":1791714967,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"8df9729e655d9f89bf7ab970b1aa69dd376a73708ca83aae6018ef14581d83ba","lane":"rust-test","parents":["dc768fd2d99009cba95ccec8d8ccd97531804fc2"],"secs":18,"stamp":"71700460c8159f5190b87fda3e587c22","tree":"fd7b032aaeaa4a20a3f4fac726aa88ebd0c96d68","v":1,"via":"run"}
Ci-Attestation: {"at":1791714967,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"4c1ee537dfc4bb7e4f53a8a4cb931dcf2abcb039f0e162a3043e8a826d5f9aae","lane":"tier2-linux","parents":["dc768fd2d99009cba95ccec8d8ccd97531804fc2"],"secs":88,"stamp":"00c890af3e4e607853663c9617233823","tree":"fd7b032aaeaa4a20a3f4fac726aa88ebd0c96d68","v":1,"via":"run"}
…lose contract

- wait_churn and both churn-thread dispatch gates now assert on a 30s
  deadline instead of silently proceeding when the gate never arrives.
- RealCtx.audio is an AtomicPtr published before connect; the callback
  reads it under the held input lock — no torn post-open write.
- real_worker_close_join spins on the callback counters (bounded, fails
  on timeout) instead of fixed sleeps; a post-close alarm window stays.
- FFI close/connect Safety docs narrowed: re-entrant audio_output_close
  from inside a callback is UB (joining the calling worker thread), as
  pthread_join on the calling thread is UB in the C. Docs now state that
  the join is a full barrier so no callback can run during/after close.

Lane: rd4
Signed-Agent: devin-rd4
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=4c73a4f40e383b3d5acae87d73d1fc6de5e4b12a secs=63 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791718243,"gate":"rust/all/fmt","host":"linux-x86_64","key":"d62db07db9fcb5b392320283755c59eee1365cb9245facd2f82cb4dd0bcd38ea","lane":"lint","parents":["c5af339d2226f22ec85fae4cf7f4955880573aa6"],"secs":11,"stamp":"cc1cfb5df1655b82d83d20ea8af85e29","tree":"4c73a4f40e383b3d5acae87d73d1fc6de5e4b12a","v":1,"via":"run"}
Ci-Attestation: {"at":1791718243,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"d62db07db9fcb5b392320283755c59eee1365cb9245facd2f82cb4dd0bcd38ea","lane":"lint","parents":["c5af339d2226f22ec85fae4cf7f4955880573aa6"],"secs":11,"stamp":"362cafe3bc7c21aa69cba838f7cd6de4","tree":"4c73a4f40e383b3d5acae87d73d1fc6de5e4b12a","v":1,"via":"run"}
Ci-Attestation: {"at":1791718243,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"1b3f94e3965519b8db69df13ddfd4df77dc85b2e168d0e4a4e764db52f275823","lane":"rust-test","parents":["c5af339d2226f22ec85fae4cf7f4955880573aa6"],"secs":18,"stamp":"f82fd7ff7d60d17584b6057b697ec756","tree":"4c73a4f40e383b3d5acae87d73d1fc6de5e4b12a","v":1,"via":"run"}
Ci-Attestation: {"at":1791718243,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"400f42cab778f7c7dc7372636b2f28dc5e15887e60bf81a59653f52bf66d32a0","lane":"tier2-linux","parents":["c5af339d2226f22ec85fae4cf7f4955880573aa6"],"secs":34,"stamp":"a75490453eb982e8935a62988124052b","tree":"4c73a4f40e383b3d5acae87d73d1fc6de5e4b12a","v":1,"via":"run"}
audio_output_close rebuilt the owning Box first, so Drop's &mut
AudioOutput was live for the whole join while an in-flight callback
could still hold &Shared through re-entrant connect/disconnect —
aliasing UB the C does not have. Stop and join through the raw pointer
instead; only then reconstruct the Box, so Drop's join is a no-op on the
FFI path and only frees resamplers.

Adds a debug-only stop_and_join_begins seam and a forced-interleaving
test: the callback parks until close reaches its join point, then runs
a re-entrant disconnect. Under the old close the test fails on a 30 s
deadline (the seam is never observed); with the fix it passes.
… ICF

fresh_clamp_snapshot_parity failed only under --release: fs_new_* and
fs_clamped_* had byte-identical bodies, the linker folded them into one
function pointer, and the C's per-mix (callback, param) duplicate check
then refused the second connect — the clamped sibling never existed, so
only the raw-2.5 call was recorded. Not a float divergence. Distinct
black_box immediates keep each callback's code distinct; the recorded
behaviour is unchanged. Debug and release both pass.
…w it

Record stop_and_join_begins() at the moment the callback calls
disconnect and assert >= 1: the test now fails if disconnect ever runs
before close reaches its join, instead of merely passing when the
overlap happens. Removing the barrier wait makes it fail — checked and
reverted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants