Skip to content

rust: Port libobs/media-io/audio-io.c to obs-media-io on Windows - #745

Merged
zackees merged 7 commits into
obs-rust:masterfrom
nathan-v:port/audio-io-windows
Oct 14, 2026
Merged

zackees merged 7 commits into
obs-rust:masterfrom
nathan-v:port/audio-io-windows

Conversation

@nathan-v

@nathan-v nathan-v commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Windows half of libobs/media-io/audio-io.c. The Unix engine was already on master and stayed off on Windows because the worker lock was a pthread mutex and the C file registers an MMCSS Audio task. This port builds that engine on Windows: a recursive CRITICAL_SECTION, and AvSetMmThreadCharacteristicsW(L"Audio") for the worker's lifetime. ENABLE_RUST_LIBOBS now drops media-io/audio-io.c on Windows too.

Refs #728

The resampler and FFmpeg wrapper stay C. Header inlines stay C.

This PR also deletes docs/lessons.md. This repo does not keep that file.

Intentional differences (also in rust/README.md and the audio_output header):

  • A null input callback is a failed tick. C calls it.
  • A null output callback connects and is skipped. C faults on the next dispatch.
  • A removal that shrinks the input list below the loop index is skipped. C reads the stale darray tail.
  • The stop flag is atomic. C uses os_event_try.
  • The worker is a Rust thread.
  • Windows locks with a CRITICAL_SECTION and registers the MMCSS "Audio" task.

RED then GREEN

  • RED 5ce9437b7 test: fail Windows audio-io open against a stub lock. open_getters_stereo expects audio_output_open to return 0 and gets AUDIO_OUTPUT_FAIL (-2), because RecursiveMutex::init returned an error.
  • GREEN 52d54988d obs-media-io: build audio-io.c on Windows.
  • Later: 3568573ea rustfmt of the Windows link list. docs/lessons.md is removed at HEAD.

Tests

Mutation: RecursiveMutex::init returned an error after a successful InitializeCriticalSectionAndSpinCount. getters_match panicked with rust open: -2. That break was reverted.

Local, on this machine:

  • soldr cargo test --workspace --locked (local-gate rust-test): passed. Audio bins on x86_64-pc-windows-msvc: audio_io 6, audio_io_core 6, audio_io_parity 14, plus the existing inline and layout bins. audio_input_init: Failed to create resampler is the expected blog line from the resample-failure cases.
  • Same lane linked every test binary for x86_64-pc-windows-gnu (--no-run). It does not execute those binaries.
  • soldr cargo fmt --all --check passed after 3568573ea.
  • soldr cargo clippy --workspace --all-targets --locked -- -D warnings passed.
  • clang-format (1973 files, rust/ included) and gersemi (357 files) passed inside the lint lane.
  • Cross clippy (--workspace --exclude obs-c-oracle --lib --bins -D warnings) and cargo check --workspace --tests passed for x86_64-pc-windows-msvc. The same commands for aarch64-apple-darwin stopped while unpacking the Apple SDK: symlink copies failed with error 1314, then The filename or extension is too long. (os error 206). x86_64-apple-darwin was not started. Dylint steps of that lane were not run (see below).

Not run here, so this PR does not claim them and is not stamped:

  • Lint-lane ci/test_*.py (self_test) fails in this environment before fmt/clippy/dylint: CRLF git check-ignore output, the dirty plugins/obs-websocket submodule, and missing tools. Those failures are not from this port. The submodule was left as it was.
  • soldr cargo dylint does not finish on this host. It prints cargo diagnostic capture still running and spawns a storm of short-lived rustup.exe. Copying the downloaded driver to dylint-driver.exe did not change that. GitHub CI should run Dylint.
  • Docker is not installed, so tier2-linux (cmocka OFF/ON and the symbol diff) did not run.
  • No cmocka prefix was found, so rust/tools/tier2-validate/validate.ps1 did not run.
  • The local-gate stamp was not applied. An unstamped push leaves the Linux unit-test jobs on CI.

The claimed label on #728 still needs a maintainer. Do not tick the tracking checkboxes until this merges.

Test plan

  • CI rust-test and rust-cross-lint (includes Dylint)
  • CI Linux Tier 2, ENABLE_RUST_LIBOBS OFF and ON, including test_audio_io
  • Confirm the Windows libobs build drops media-io/audio-io.c when Rust is on and still links audio_output_*

@nathan-v
nathan-v marked this pull request as ready for review October 14, 2026 18:17
@nathan-v
nathan-v requested a review from zackees as a code owner October 14, 2026 18:17
@zackees zackees added the ci-full Run every CI job on this PR, including the release-gating OBS app builds and Flatpak label Oct 14, 2026
Refs obs-rust#728

open_getters_stereo asserts audio_output_open returns 0 and gets
AUDIO_OUTPUT_FAIL (-2), because the Windows RecursiveMutex::init stub
returns an error.
Refs obs-rust#728

The worker lock is a recursive CRITICAL_SECTION, and the thread
registers the MMCSS Audio task. ENABLE_RUST_LIBOBS drops
media-io/audio-io.c on Windows too.

Tier 1 (audio_io, audio_io_core) and Tier 3 (audio_io_parity) pass
on x86_64-pc-windows-msvc. Breaking RecursiveMutex::init so it
returns an error makes getters_match fail with "rust open: -2";
that break was reverted.
soldr cargo dylint on this host never starts rustc and spawns
short-lived rustup.exe processes. Copying the driver to a .exe
name did not stop it.
Darwin cross clippy on this host dies while unpacking the SDK
(symlink privilege 1314, then path length 206). The MSVC target
in that loop passed.
This repo does not keep a lessons file.
audio-io.c includes <Windows.h>. The Ubuntu windows-gnu link
compiles that with a case-sensitive MinGW, which only has
windows.h. A wrapper searched first forwards the capital name.

Refs obs-rust#728

Local-Gate: v1 tree=99d8f537a30ffc1191f65f531a0c15db1060fe46 secs=512 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1792006022,"gate":"rust/all/fmt","host":"linux-x86_64","key":"ebefaf2c6ec7ad1ced392d011a83af264e9fb058251f6171f0c368162a5fee71","lane":"lint","parents":["994d7f7c3226279dc0ac4fdcf98a30608605afe0"],"secs":55,"stamp":"4cb12aefde6751e86a5b86ab939ea0b8","tree":"99d8f537a30ffc1191f65f531a0c15db1060fe46","v":1,"via":"run"}
Ci-Attestation: {"at":1792006022,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"ebefaf2c6ec7ad1ced392d011a83af264e9fb058251f6171f0c368162a5fee71","lane":"lint","parents":["994d7f7c3226279dc0ac4fdcf98a30608605afe0"],"secs":55,"stamp":"94e7a60f338c22f8f4609a4d2d8cc06f","tree":"99d8f537a30ffc1191f65f531a0c15db1060fe46","v":1,"via":"run"}
Ci-Attestation: {"at":1792006022,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"02c494578a57a46596a4051ba975b7636cc97358dd36f1be69fea8296477c985","lane":"rust-test","parents":["994d7f7c3226279dc0ac4fdcf98a30608605afe0"],"secs":126,"stamp":"006a2b7b0d75e764d8cab9c4a9a27391","tree":"99d8f537a30ffc1191f65f531a0c15db1060fe46","v":1,"via":"run"}
Ci-Attestation: {"at":1792006022,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"9355a386d7d47e047c4818ab8214fbb9916ced3333240d0e52c5707bc24b86e3","lane":"cross","parents":["994d7f7c3226279dc0ac4fdcf98a30608605afe0"],"secs":113,"stamp":"70fba730ce8f7f44852fefcbb73596f8","tree":"99d8f537a30ffc1191f65f531a0c15db1060fe46","v":1,"via":"run"}
Ci-Attestation: {"at":1792006022,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"9355a386d7d47e047c4818ab8214fbb9916ced3333240d0e52c5707bc24b86e3","lane":"cross","parents":["994d7f7c3226279dc0ac4fdcf98a30608605afe0"],"secs":113,"stamp":"e1308356b3bd14b171eb0f0b5d3d1839","tree":"99d8f537a30ffc1191f65f531a0c15db1060fe46","v":1,"via":"run"}
Ci-Attestation: {"at":1792006022,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"9355a386d7d47e047c4818ab8214fbb9916ced3333240d0e52c5707bc24b86e3","lane":"cross","parents":["994d7f7c3226279dc0ac4fdcf98a30608605afe0"],"secs":113,"stamp":"94dc94ab6d2ce712ecb52a336d65276d","tree":"99d8f537a30ffc1191f65f531a0c15db1060fe46","v":1,"via":"run"}
Ci-Attestation: {"at":1792006022,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"9355a386d7d47e047c4818ab8214fbb9916ced3333240d0e52c5707bc24b86e3","lane":"cross","parents":["994d7f7c3226279dc0ac4fdcf98a30608605afe0"],"secs":113,"stamp":"39c892d4de0fff84352ed07a0e82cd67","tree":"99d8f537a30ffc1191f65f531a0c15db1060fe46","v":1,"via":"run"}
Ci-Attestation: {"at":1792006022,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"9355a386d7d47e047c4818ab8214fbb9916ced3333240d0e52c5707bc24b86e3","lane":"cross","parents":["994d7f7c3226279dc0ac4fdcf98a30608605afe0"],"secs":113,"stamp":"02872ff13889d75691d286d4b3f66a17","tree":"99d8f537a30ffc1191f65f531a0c15db1060fe46","v":1,"via":"run"}
Ci-Attestation: {"at":1792006022,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"9355a386d7d47e047c4818ab8214fbb9916ced3333240d0e52c5707bc24b86e3","lane":"cross","parents":["994d7f7c3226279dc0ac4fdcf98a30608605afe0"],"secs":113,"stamp":"5fbba209d79e25c63614b371c6adcb5c","tree":"99d8f537a30ffc1191f65f531a0c15db1060fe46","v":1,"via":"run"}
Ci-Attestation: {"at":1792006022,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"3454e4780d4b8feaa0f764f033bd7139d67e7391b94934be0f08e9721e45e57e","lane":"tier2-linux","parents":["994d7f7c3226279dc0ac4fdcf98a30608605afe0"],"secs":218,"stamp":"21c187f9d1df2453e9e227cca653c71f","tree":"99d8f537a30ffc1191f65f531a0c15db1060fe46","v":1,"via":"run"}
@zackees

zackees commented Oct 14, 2026

Copy link
Copy Markdown
Member

Rebased onto master, set ci-full (this changes the Windows build), and ran the stamped local gate. RED (5ce9437b7: audio_output_open returns -2 against the stub lock) / GREEN evidence is yours above; the Windows Rust Tests and Tier 2 jobs confirm GREEN on Windows.

  • Rebased on master, local gate passed; pushed as d41539c.

@zackees
zackees force-pushed the port/audio-io-windows branch from 4635a18 to d41539c Compare October 14, 2026 19:27
@zackees
zackees added this pull request to the merge queue Oct 14, 2026
Merged via the queue into obs-rust:master with commit 1b61353 Oct 14, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-full Run every CI job on this PR, including the release-gating OBS app builds and Flatpak

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants