Increase stream initialization delay from 50ms to 150ms

This addresses the 'slow playback' issue on first large sample rate transition
(e.g., 88.2kHz → 44.1kHz). The hardware needs extra time to stabilize when
changing sample rates significantly, especially on cold start.

Root cause:
- First transition 88.2→44.1 kHz: song started slowly
- Subsequent identical transitions: clean
- Affects both ALSA Direct and PipeWire DAC Passthrough
- Hardware 'warm-up' time needed for large rate changes

Fix:
- Increased delay from 50ms to 150ms (still imperceptible to user)
- Gives DAC hardware more time to stabilize clock after rate change
- Extra time especially critical for downward transitions (88.2→44.1)

Testing needed:
- Verify first 88.2→44.1 transition is now clean
- Ensure 150ms delay doesn't create noticeable gap
- Check all other transitions still work
This commit is contained in:
vicrodh committed 2026-01-19 11:39:01 -06:00
1 parent 97c9473790
commit 0a361712ce
1 file changed
+4 -3
+4 -3
View File
@@ -913,9 +913,10 @@ impl Player {
log::info!("✅ Audio stream ready at {}Hz", sample_rate);
}
// Small delay to ensure stream is fully initialized before decoder starts
// This prevents sync gaps when changing sample rates
std::thread::sleep(Duration::from_millis(50));
// Delay to ensure stream is fully initialized before decoder starts
// This prevents sync gaps and allows hardware to stabilize after sample rate changes
// Extra time needed for large sample rate changes (e.g., 88.2kHz → 44.1kHz)
std::thread::sleep(Duration::from_millis(150));
}
Err(e) => {
log::error!("❌ Failed to create stream at {}Hz: {}", sample_rate, e);