Skip to content

fix(macos): activate native VoiceProcessingIO and make capture callback safe - #6

Merged
EzraEllette merged 3 commits into
mainfrom
fix/vpio-duplex-device-binding
Sep 25, 2026
Merged

EzraEllette merged 3 commits into
mainfrom
fix/vpio-duplex-device-binding

Conversation

@louis030195

@louis030195 louis030195 commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Requesting MacosVoiceProcessingInputConfig::screenpipe_aec() through the public dynamic cpal::Device silently opened AUHAL. The wrapper inherited the trait default, which discarded the option. Forwarding it exposed further native setup and lifecycle failures.

This forwards the option, builds an uninitialized native VoiceProcessingIO unit, binds microphone/output to the correct buses, keeps duplex output alive with a silent render callback, and verifies required processing properties. The native input callback uses aligned preallocated storage sized after initialization, avoiding the coreaudio-rs format-query/resize callback that deadlocked against AudioOutputUnitStop during hardware retesting. Native render errors now reach CPAL's error callback.

before: VPIO requested -> dynamic Device -> plain AUHAL (ahal)
after:  VPIO requested -> CoreAudio -> native VoiceProcessingIO (vpio)
                                      microphone bus 1 + speaker bus 0
                                      silent render; preallocated capture

Validation on Apple Silicon / macOS 26.6.2, built-in microphone and speakers:

  • Original e7edfa1 plus the new native regression: fails with AudioUnit(InvalidProperty) when checking VPIO. AudioUnit creation trace confirms ahal.
  • Fixed creation trace selects vpio; required bypass/AGC/mute, duplex output, and both device bindings read back correctly.
  • cargo +1.94.0 test --lib: 3 pass, 2 opt-in hardware tests ignored.
  • cargo +1.94.0 check --all-targets: passes.
  • cargo +1.94.0 test --lib live_ -- --ignored --test-threads=1: 2 pass in each of five consecutive runs, covering 20 VPIO start/capture/stop cycles at 16/48/96 kHz and bypass, plus five raw-path checks. Zero callback errors.
  • Real speaker-playback recordings through the public API were repeated, with native capture selected and bounded recorder cleanup. Details and a reusable vpio_probe example are in VPIO-VALIDATION.md.

Draft because activating previously skipped native processing changes actual device behavior. Acoustic leakage was lower in exploratory tests, but ducking affects playback level, so the apparent 25 dB difference is not clean ERLE. A separate unducked native experiment showed about 11 dB lower matched speech in one pair; that SPI is not used in this patch. These figures are not a cross-device quality guarantee. Double-talk, human near-end preservation, Bluetooth/USB/HDMI, route switching, Intel, older macOS, and long meetings still need hardware validation. No private microphone recordings are published.

CI snapshot on the PR head: native macOS, Ubuntu, clippy, rustfmt, Android check, and wasm-bindgen jobs passed. WASI fails before compilation because stable no longer supplies wasm32-wasi; the Emscripten job fails in unchanged wasm bindings. Both job names also failed on the original e7edfa1 main run: https://github.com/screenpipe/cpal/actions/runs/28710085009. Other jobs remain in progress. This is not an all-green CI claim.

Screenpipe integration: screenpipe/screenpipe#7285.

@EzraEllette
EzraEllette marked this pull request as ready for review September 25, 2026 16:09
@EzraEllette
EzraEllette merged commit 814c6a6 into main Sep 25, 2026
30 of 34 checks passed
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.

2 participants