Skip to content

Commit 8b2105b

Browse files
committed
Set buffer *after* period
1 parent 614fcbb commit 8b2105b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/backends/alsa/device.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ impl AlsaDevice {
128128

129129
// Prefer the min buffer size, otherwise fall back to the max.
130130
if let Some(buffer_size) = config.buffer_size_range.0.or(config.buffer_size_range.1) {
131-
let buffer_size = hwp.set_buffer_size_near(buffer_size as _)?;
132-
hwp.set_period_size_near(buffer_size / 2, alsa::ValueOr::Nearest)?;
131+
// Set the period size first, to half the desired buffer size.
132+
hwp.set_period_size_near((buffer_size / 2) as i64, alsa::ValueOr::Nearest)?;
133+
// Then, set the buffer size.
134+
hwp.set_buffer_size_near(buffer_size as i64)?;
133135
}
134136

135137
hwp.set_format(pcm::Format::float())?;

0 commit comments

Comments
 (0)