From aaef07e819192b0c204150e8d65eff741fabe1e3 Mon Sep 17 00:00:00 2001 From: sniperrifle2004 Date: Sun, 14 Jun 2020 05:16:59 +0200 Subject: [PATCH] Introduce an appropriate period for the desired buffer --- playback/src/audio_backend/alsa.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/playback/src/audio_backend/alsa.rs b/playback/src/audio_backend/alsa.rs index 8bdcb9d1..c2e06630 100644 --- a/playback/src/audio_backend/alsa.rs +++ b/playback/src/audio_backend/alsa.rs @@ -41,7 +41,8 @@ fn open_device(dev_name: &str) -> Result<(PCM), Box> { hwp.set_format(Format::s16())?; hwp.set_rate(44100, ValueOr::Nearest)?; hwp.set_channels(2)?; - hwp.set_buffer_size_near(22050)?; // ~ 0.5s latency + hwp.set_period_size_near(5512, ValueOr::Nearest)?; // Period of roughly 125ms + hwp.set_buffer_size_near(22048)?; // ~ 0.5s latency pcm.hw_params(&hwp)?; let swp = pcm.sw_params_current()?;