Adds a direct WASAPI microphone capture path for the Windows desktop build that opens the default communications endpoint via IMMDeviceEnumerator -> IAudioClient2 -> SetClientProperties with AudioCategory_Communications, turning on Windows's communications audio processing chain (AEC, noise suppression, automatic gain control). The communications AEC operates at the OS level and uses the system render mix as the reference signal, so echo from our existing CPAL playback stream is cancelled automatically with no per-process reference plumbing. Architecture: - New crates/wzp-client/src/audio_wasapi.rs module (~280 lines). Event-driven capture loop on a dedicated thread; pushes PCM into the same lock-free AudioRing used by the CPAL path. Same public API as audio_io::AudioCapture so downstream code is unchanged. - New `windows-aec` feature in wzp-client that pulls in the `windows` crate (Microsoft's official Rust COM bindings) gated to target_os = "windows" only. Enabling the feature on non-Windows targets is a no-op since both the module and the dep are cfg(target_os = "windows"). - lib.rs re-exports WasapiAudioCapture as AudioCapture when the feature is on, otherwise falls back to the CPAL AudioCapture. AudioPlayback is always the CPAL one — no reason to swap it. - desktop/src-tauri/Cargo.toml Windows target enables the new feature: `features = ["audio", "windows-aec"]`. Implementation notes: - Uses eCommunications role (not eConsole) for GetDefaultAudioEndpoint — the user-configured "communications" device that Teams/Zoom pick up, and the one Windows's AEC is tuned for. - Requests 48 kHz mono i16 with AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM + SRC_DEFAULT_QUALITY so Windows handles any format conversion in the audio engine instead of rejecting our format. - Event-driven with SetEventHandle / WaitForSingleObject — no polling, minimal CPU cost between packets. - 200 ms wait timeout so the capture thread polls `running` often enough for Drop to stop cleanly even if the audio engine stalls (e.g. device unplug). Task #24. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
78 lines
2.7 KiB
TOML
78 lines
2.7 KiB
TOML
[package]
|
|
name = "wzp-client"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
rust-version.workspace = true
|
|
description = "WarzonePhone client library — for Android (JNI) and Windows desktop"
|
|
|
|
[dependencies]
|
|
wzp-proto = { workspace = true }
|
|
wzp-codec = { workspace = true }
|
|
wzp-fec = { workspace = true }
|
|
wzp-crypto = { workspace = true }
|
|
wzp-transport = { workspace = true }
|
|
tokio = { workspace = true }
|
|
tracing = { workspace = true }
|
|
tracing-subscriber = { workspace = true }
|
|
async-trait = { workspace = true }
|
|
bytes = { workspace = true }
|
|
anyhow = "1"
|
|
serde = { workspace = true }
|
|
serde_json = "1"
|
|
chrono = "0.4"
|
|
rustls = { version = "0.23", default-features = false, features = ["ring", "std"] }
|
|
cpal = { version = "0.15", optional = true }
|
|
libc = "0.2"
|
|
|
|
# coreaudio-rs is Apple-framework-only; gate it to macOS so enabling
|
|
# the `vpio` feature from a non-macOS target builds cleanly instead of
|
|
# pulling in a crate that can only link against Apple frameworks.
|
|
[target.'cfg(target_os = "macos")'.dependencies]
|
|
coreaudio-rs = { version = "0.11", optional = true }
|
|
|
|
# Windows-only: direct WASAPI bindings for the `windows-aec` feature.
|
|
# `windows` is Microsoft's official Rust COM bindings crate. We pull in
|
|
# only the audio + COM subfeatures we need — the crate is organized as
|
|
# a massive optional-feature tree, so enabling just these keeps compile
|
|
# times reasonable (~5s for these features vs ~60s for the full crate).
|
|
[target.'cfg(target_os = "windows")'.dependencies]
|
|
windows = { version = "0.58", optional = true, features = [
|
|
"Win32_Foundation",
|
|
"Win32_Media_Audio",
|
|
"Win32_System_Com",
|
|
"Win32_System_Com_StructuredStorage",
|
|
"Win32_System_Threading",
|
|
"Win32_System_Variant",
|
|
] }
|
|
|
|
[features]
|
|
default = []
|
|
audio = ["cpal"]
|
|
# vpio enables coreaudio-rs but that dep is itself gated to macOS above,
|
|
# so enabling this feature on Windows/Linux is a no-op (the audio_vpio
|
|
# module is also #[cfg(target_os = "macos")] in lib.rs).
|
|
vpio = ["dep:coreaudio-rs"]
|
|
# windows-aec enables a direct WASAPI capture backend that opens the
|
|
# microphone under AudioCategory_Communications, turning on Windows's
|
|
# OS-level communications audio processing (AEC + noise suppression +
|
|
# AGC). The `windows` dep is itself target-gated to Windows above, so
|
|
# enabling this feature on non-Windows targets is a no-op (the
|
|
# audio_wasapi module is also #[cfg(target_os = "windows")] in lib.rs).
|
|
windows-aec = ["dep:windows"]
|
|
|
|
[[bin]]
|
|
name = "wzp-client"
|
|
path = "src/cli.rs"
|
|
|
|
[[bin]]
|
|
name = "wzp-bench"
|
|
path = "src/bench_cli.rs"
|
|
|
|
[dev-dependencies]
|
|
tokio = { workspace = true }
|
|
wzp-relay = { path = "../wzp-relay" }
|
|
wzp-crypto = { workspace = true }
|
|
wzp-proto = { workspace = true }
|
|
async-trait = { workspace = true }
|