Skip to content

Commit bb24778

Browse files
committed
Don't explicitly set the number of periods
Doing so on configs that have less than the 4 periods we were asking for caused a crash. Instead ask for a buffer time of 500ms.
1 parent be16d3b commit bb24778

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

playback/src/audio_backend/alsa.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use std::process::exit;
1212
use std::time::Duration;
1313
use thiserror::Error;
1414

15-
// 125 ms Period time * 4 periods = 0.5 sec buffer.
16-
const PERIOD_TIME: Duration = Duration::from_millis(125);
17-
const NUM_PERIODS: u32 = 4;
15+
// 0.5 sec buffer.
16+
const PERIOD_TIME: Duration = Duration::from_millis(100);
17+
const BUFFER_TIME: Duration = Duration::from_millis(500);
1818

1919
#[derive(Debug, Error)]
2020
enum AlsaError {
@@ -131,8 +131,7 @@ fn open_device(dev_name: &str, format: AudioFormat) -> Result<(PCM, usize), Alsa
131131
err: e,
132132
})?;
133133

134-
// Deal strictly in time and periods.
135-
hwp.set_periods(NUM_PERIODS, ValueOr::Nearest)
134+
hwp.set_buffer_time_near(BUFFER_TIME.as_micros() as u32, ValueOr::Nearest)
136135
.map_err(AlsaError::HwParams)?;
137136

138137
hwp.set_period_time_near(PERIOD_TIME.as_micros() as u32, ValueOr::Nearest)

0 commit comments

Comments
 (0)