feat(voice): add iOS VAD runtime support

This commit is contained in:
Edison Jwa
2026-05-21 20:51:45 +09:00
parent 171baf6e41
commit 6af4ecab0f
73 changed files with 11529 additions and 1249 deletions
+31 -8
View File
@@ -15,26 +15,36 @@
//! * Push-to-talk: capture stream is permanently open; encoding is
//! gated by an atomic `ptt_active` flag
//!
//! ## What's NOT wired in this Beta
//! ## Voice processing in this Beta
//!
//! * AEC / AGC / NS / HPF DSP chain (DEC-007/008/009/010 — Beta+
//! work; the toggles in `AudioEffects` are honoured by *naming*
//! but the filters are no-ops)
//! * Hot-plug device-change handling
//! * iOS/macOS use Apple's VoiceProcessingIO path, which owns platform
//! AEC / AGC / noise suppression for the shipping route.
//! * Rust owns VoiceActivity transmit gating and exposes a software
//! processor surface for debug/future raw routes.
//! * Hot-plug device-change handling is still platform-specific follow-up work.
//! * Sample-rate adaptation if the device cannot do 48 kHz / mono in
//! the format we request (returns `AudioError::StreamConfig`)
//! * Multi-channel speaker layouts beyond stereo
#![warn(missing_docs)]
pub mod audio_processing;
pub mod debug_wav;
mod engine;
pub mod frame;
pub mod mobile_voice_backend;
pub mod mode_stack;
pub(crate) mod opus_voice;
pub mod processor;
pub mod ptt;
pub mod ptt_backends;
pub mod release_tail;
pub mod route_policy;
pub mod transmit_mode;
pub mod transmit_selector;
pub mod vad;
pub mod voice_activity;
pub(crate) mod voice_render;
#[cfg(target_os = "linux")]
mod sdl_output;
@@ -42,9 +52,16 @@ mod sdl_output;
#[cfg(any(target_os = "ios", target_os = "macos"))]
mod ios_voice_unit;
#[cfg(target_os = "ios")]
pub mod ios_raw_unit;
#[cfg(target_os = "android")]
pub mod android_voice_unit;
pub use audio_processing::{
AudioBackend, AudioProcessingConfig, AudioProcessingStats, AudioRoute, EffectOwner,
IosVoiceProcessingMode, SharedAudioProcessingStats, VadBackend,
};
pub use engine::{AudioEngine, AudioEngineConfig};
// SDD-120 §3 bench seam — `#[doc(hidden)]` re-export so the criterion
@@ -88,14 +105,20 @@ pub enum AudioError {
/// been called before `voice_join` triggers the audio engine.
#[error("android platform not ready: ndk_context not initialised")]
PlatformNotReady,
/// Audio processing config failed validation.
#[error("invalid audio processing config: {0}")]
InvalidAudioProcessingConfig(String),
/// Requested audio processing config is schema-visible but not implemented.
#[error("unsupported audio processing config: {0}")]
UnsupportedAudioProcessingConfig(String),
}
/// Audio-effect toggles. Defaults match DEC-007 (AEC),
/// DEC-008 (AGC), DEC-009 (NS), DEC-010 (HPF) — all enabled.
///
/// Note: in Beta v0.2.0-beta.1 the actual DSP filters are not yet
/// implemented; the struct is kept here as the public API surface so
/// later work can flip an internal flag without breaking callers.
/// On iOS/macOS these map to VoiceProcessingIO-owned effects in the
/// default route. Software processor backends may also consult them
/// on raw/debug routes.
#[derive(Debug, Clone, Copy)]
pub struct AudioEffects {
/// Acoustic echo cancellation (DEC-007).