diff --git a/crates/pi-natives/src/audio.rs b/crates/pi-natives/src/audio.rs index 0b1e4cbbf..f7902c1cb 100644 --- a/crates/pi-natives/src/audio.rs +++ b/crates/pi-natives/src/audio.rs @@ -27,13 +27,18 @@ use parking_lot::Mutex; use tokio::sync::Notify; const AUDIO_CHANNELS: u32 = 1; +// PulseAudio TCP playback stutters with a 20 ms target buffer; 50 ms absorbs +// transport jitter while preserving interactive latency. +#[cfg(target_os = "linux")] +const PLAYBACK_PERIOD_MS: u32 = 50; +#[cfg(not(target_os = "linux"))] const PLAYBACK_PERIOD_MS: u32 = 20; // miniaudio's PulseAudio backend reserves three periods. Android's OpenSL ES // source emits 125 ms fragments, so Linux capture needs at least 150 ms queued. #[cfg(target_os = "linux")] const CAPTURE_PERIOD_MS: u32 = 50; #[cfg(not(target_os = "linux"))] -const CAPTURE_PERIOD_MS: u32 = PLAYBACK_PERIOD_MS; +const CAPTURE_PERIOD_MS: u32 = 20; const PLAYBACK_DRAIN_CALLBACKS: usize = 2; #[cfg(target_os = "macos")] diff --git a/packages/natives/CHANGELOG.md b/packages/natives/CHANGELOG.md index 08b77df2c..9032916d0 100644 --- a/packages/natives/CHANGELOG.md +++ b/packages/natives/CHANGELOG.md @@ -4,7 +4,7 @@ ### Fixed -- Fixed Linux `AudioCapture` stalling on PulseAudio sources that emit fragments larger than miniaudio's previous 60 ms capture buffer, including Android OpenSL ES microphones reached through a forwarded PulseAudio server. +- Fixed Linux native audio over forwarded PulseAudio servers: capture now handles 125 ms Android fragments without stalling, and playback buffers enough audio to avoid TCP underruns and stuttering. ## [17.1.3] - 2026-07-24