diff --git a/playback/src/audio_backend/alsa.rs b/playback/src/audio_backend/alsa.rs index 41c75ed6..9dd3ea0c 100644 --- a/playback/src/audio_backend/alsa.rs +++ b/playback/src/audio_backend/alsa.rs @@ -7,7 +7,6 @@ use alsa::device_name::HintIter; use alsa::pcm::{Access, Format, HwParams, PCM}; use alsa::{Direction, ValueOr}; use std::cmp::min; -use std::cmp::Ordering; use std::process::exit; use std::time::Duration; use thiserror::Error; @@ -226,16 +225,8 @@ impl Sink for AlsaSink { let (pcm, bytes_per_period) = open_device(&self.device, self.format)?; self.pcm = Some(pcm); - match self.period_buffer.capacity().cmp(&bytes_per_period) { - Ordering::Greater => { - self.period_buffer.truncate(bytes_per_period); - self.period_buffer.shrink_to_fit(); - } - Ordering::Less => { - let extra = bytes_per_period - self.period_buffer.len(); - self.period_buffer.reserve_exact(extra); - } - Ordering::Equal => (), + if self.period_buffer.capacity() != bytes_per_period { + self.period_buffer = Vec::with_capacity(bytes_per_period); } // Should always match the "Period Buffer size in bytes: " trace! message.