Skip to content

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

Closed

Description

@zackees

#290 denies unsafe_code in the port crates, allowing it only in src/ffi/ and at documented C boundaries. The audio-io port (#289) merged just before it, with 54 unsafe sites in rust/obs-media-io/src/audio_io.rs. They implement the raw-pointer "unsafe lifetime contract" API that the C shims drive, plus the audio thread's shared-state cells.

To land #290 without blocking on a large refactor of a brand-new port, mod audio_io carries a module-level #[allow(unsafe_code)] that points here. This issue tracks removing it:

  • Move the raw-API surface (the pointer-taking functions and their unsafe contracts) into src/ffi/audio_io.rs, so audio_io.rs exposes only a safe owned API.
  • Keep the shared-state synchronization in safe primitives where possible. Any unsafe that must stay needs its own justified, item-level #[allow(unsafe_code)].
  • RED: drop the module-level allow, so the build fails with 54 unsafe_code errors. GREEN: it builds with only src/ffi and item-level allows, and audio_io, audio_io_core, audio_io_parity and Tier 2 test_audio_io (OFF and ON) still pass.

Refs #143, #289, #290.

Activity

  1. zackees commented on Oct 12, 2026

    @zackees
    MemberAuthor

    Claiming: #294. Plan: 1) RED: drop the module-level allow on mod audio_io; 2) GREEN: move the raw-pointer API and the audio thread's shared-state cells out of audio_io/port.rs (since #326) into src/ffi/audio_io.rs, leaving item-level allows only where the C callback contract needs them; 3) the audio_io tests and Tier 2 pass OFF/ON. One PR today.

  2. added
    claimed
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions