Skip to content

obs-media-io: Move the audio-io engine out of the safe core into src/ffi - #413

Merged
zackees merged 2 commits into
masterfrom
refactor/294-audio-io-unsafe
Oct 13, 2026
Merged

zackees merged 2 commits into
masterfrom
refactor/294-audio-io-unsafe

Conversation

@zackees

@zackees zackees commented Oct 12, 2026

Copy link
Copy Markdown
Member

Closes #294. Part of #297.

  • RED: drops the module-level #[allow(unsafe_code)] on mod audio_io, so the crate fails with 46 unsafe_code errors.
  • GREEN: audio_io/port.rs moves to src/ffi/audio_output.rs. Every tick calls C function pointers (input and output callbacks), audio_resampler_* handles and libobs os_*/profiler symbols, and shares UnsafeCell state with FFI callers under the recursive lock, so the engine is C-boundary code. audio_io.rs keeps the safe header inlines and re-exports AudioOutput for its Rust callers, so the tests and the compile_fail doctests are unchanged.

The crate now allows unsafe_code only on mod ffi and platform::unix (the pthread mutex, #326).

Not done here: a fully safe engine core, with Rust closures in place of C callbacks and a safe re-entrant lock. That would be a redesign, not a move, and gets its own issue if wanted.

Local gate (lint + Dylint, rust-test, tier2-linux OFF/ON) passed and is stamped. clippy --lib is clean for x86_64-pc-windows-msvc and aarch64-apple-darwin.

The audio-io port's 46 unsafe sites now fail the crate's
deny(unsafe_code).

Refs #294
audio_io/port.rs becomes ffi/audio_output.rs: every tick calls C
callbacks, resampler handles and libobs symbols through raw pointers, so
it belongs with the C boundary. audio_io.rs keeps the safe header
inlines and re-exports the engine, and the crate now allows unsafe_code
only on mod ffi and platform::unix.

Closes #294

Local-Gate: v1 tree=1cffc0bfdbfc81b5824c3e97a74fbd35be5b9b1e secs=241 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791849002,"gate":"rust/all/fmt","host":"linux-x86_64","key":"d834eedcfce3a821bcd0dc4adbe2721cf9084a49947d3986f39296d2cb4e275c","lane":"lint","parents":["1d7dabebb87051327bbc6960d44ff0d31ec88730"],"secs":37,"stamp":"fef10032725e11d5c383d8456dbc01e2","tree":"1cffc0bfdbfc81b5824c3e97a74fbd35be5b9b1e","v":1,"via":"run"}
Ci-Attestation: {"at":1791849002,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"d834eedcfce3a821bcd0dc4adbe2721cf9084a49947d3986f39296d2cb4e275c","lane":"lint","parents":["1d7dabebb87051327bbc6960d44ff0d31ec88730"],"secs":37,"stamp":"2b6c0623a42b4cd172083353cb19ec7f","tree":"1cffc0bfdbfc81b5824c3e97a74fbd35be5b9b1e","v":1,"via":"run"}
Ci-Attestation: {"at":1791849002,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"ba82d0368220d0ae65a92dd3ff970a0a233b376115c067d6711e20db0d0c6528","lane":"rust-test","parents":["1d7dabebb87051327bbc6960d44ff0d31ec88730"],"secs":77,"stamp":"0b1fb8efbe3d7461a41ebf7d48b83eba","tree":"1cffc0bfdbfc81b5824c3e97a74fbd35be5b9b1e","v":1,"via":"run"}
Ci-Attestation: {"at":1791849002,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"edeb3ced96e581c68c0b85d2c4b02e8159e72feee16c0554e54de54154edeab8","lane":"tier2-linux","parents":["1d7dabebb87051327bbc6960d44ff0d31ec88730"],"secs":128,"stamp":"f274ae6acc825d44c628c3a3fe7e164c","tree":"1cffc0bfdbfc81b5824c3e97a74fbd35be5b9b1e","v":1,"via":"run"}
@zackees
zackees merged commit ab55ae4 into master Oct 13, 2026
20 checks passed
@zackees
zackees deleted the refactor/294-audio-io-unsafe branch October 26, 2026 15:46
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.

rust/obs-media-io: move audio_io.rs unsafe out of the safe core into src/ffi

1 participant