feat: echo cancellation via PipeWire module-echo-cancel
Add an opt-in Echo Cancellation toggle (Settings) that routes the call through PipeWire's module-echo-cancel (WebRTC AEC + noise suppression + AGC) instead of running an in-process canceller. PipeWire already sees both the mic and the speaker monitor, so it handles the echo-reference alignment for free and we avoid a C++ DSP dependency. src/audio/echo_cancel.rs (new): - enable(real_source, real_sink) loads the module via pactl (aec_method=webrtc), bound to the chosen devices with source_master/sink_master (defaults if unset), waits for the virtual nodes to appear, and returns an RAII guard that unloads the module on drop. Best-effort pre-clean of a stale instance from a crashed run. - EC_SOURCE / EC_SINK are the virtual cleaned-mic source and reference sink. core: when echo_cancellation is set on Join, load the module and point capture at EC_SOURCE / playback at EC_SINK; stash the guard in ActiveSession so it unloads on shutdown (after the audio streams release the nodes). Any failure logs + warns the UI and falls back to the direct devices — never blocks the call. config: new echo_cancellation_enabled (serde default false). app: Settings checkbox under Mic Sensitivity, applied on next room join. An ignored live smoke test covers the real load/unload path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -47,6 +47,10 @@ pub struct AppConfig {
|
||||
pub noise_gate_threshold: f32,
|
||||
#[serde(default)]
|
||||
pub network_mode: NetworkMode,
|
||||
/// Route audio through PipeWire's echo-cancel module (AEC + noise suppression).
|
||||
/// Takes effect on the next room join. Off by default.
|
||||
#[serde(default)]
|
||||
pub echo_cancellation_enabled: bool,
|
||||
#[serde(default = "default_true")]
|
||||
pub notifications_enabled: bool,
|
||||
#[serde(default)]
|
||||
@@ -74,6 +78,7 @@ impl Default for AppConfig {
|
||||
output_device: "".to_string(),
|
||||
noise_gate_threshold: 0.01,
|
||||
network_mode: NetworkMode::default(),
|
||||
echo_cancellation_enabled: false,
|
||||
notifications_enabled: true,
|
||||
custom_sound_self_join: None,
|
||||
custom_sound_peer_join: None,
|
||||
|
||||
Reference in New Issue
Block a user