fix(natives): buffer forwarded PulseAudio playback

This commit is contained in:
Anatoli Tsinovoy
2026-07-25 22:22:14 +03:00
parent 2a9615510f
commit b8a30a04cd
2 changed files with 7 additions and 2 deletions
+6 -1
View File
@@ -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")]
+1 -1
View File
@@ -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