diag(audio): run device enumeration ~every 60s instead of 3s (#996, experiment)

EXPERIMENT BUILD ONLY — not for release. Diagnostic for the macOS ~3s
playback stutter (#996): keep the 3s watcher loop, watchdog and stall
detector unchanged, but run the heavy CoreAudio device enumeration only
every ~60s. If the stutter cadence shifts to ~60s (or stops) on the
reporter's machine, the periodic enumeration is the cause.
This commit is contained in:
Psychotoxical
2026-06-05 15:47:59 +02:00
parent 1c23305887
commit bda2822db5
@@ -140,6 +140,12 @@ pub fn start_device_watcher(engine: &AudioEngine, app: tauri::AppHandle) {
let mut last_stall_recover_at: Option<Instant> = None;
let mut last_poll_at = Instant::now();
let mut watchdog_armed_until: Option<Instant> = None;
// DIAGNOSTIC (issue #996, EXPERIMENT BUILD ONLY — revert before release):
// counts watcher cycles so the heavy CoreAudio enumeration below runs only
// ~every 60s (20 × 3s) instead of every cycle. Tests whether that periodic
// enumeration is the source of the ~3s macOS playback stutter. The 3s loop,
// watchdog and stall detector are left untouched on purpose.
let mut diag_enum_skip: u32 = 0;
loop {
tokio::time::sleep(Duration::from_secs(3)).await;
@@ -224,6 +230,17 @@ pub fn start_device_watcher(engine: &AudioEngine, app: tauri::AppHandle) {
}
}
// DIAGNOSTIC (issue #996, EXPERIMENT BUILD ONLY — revert before release):
// run the heavy CoreAudio enumeration + device-change detection only
// ~every 60s. The stall detector above still runs every 3s, so playback
// recovery is unaffected. If the stutter cadence shifts to ~60s (or
// stops), the periodic enumeration is the culprit.
diag_enum_skip += 1;
if diag_enum_skip < 20 {
continue;
}
diag_enum_skip = 0;
// Enumerate all available output devices and the current default.
// Suppress stderr on Unix to avoid ALSA probing noise (JACK, OSS, dmix).
let (current_default, available) = tauri::async_runtime::spawn_blocking(|| {