mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
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.
This commit is contained in:
parent
be16d3babf
commit
bb2477831b
1 changed files with 4 additions and 5 deletions
|
@ -12,9 +12,9 @@ use std::process::exit;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
// 125 ms Period time * 4 periods = 0.5 sec buffer.
|
// 0.5 sec buffer.
|
||||||
const PERIOD_TIME: Duration = Duration::from_millis(125);
|
const PERIOD_TIME: Duration = Duration::from_millis(100);
|
||||||
const NUM_PERIODS: u32 = 4;
|
const BUFFER_TIME: Duration = Duration::from_millis(500);
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
enum AlsaError {
|
enum AlsaError {
|
||||||
|
@ -131,8 +131,7 @@ fn open_device(dev_name: &str, format: AudioFormat) -> Result<(PCM, usize), Alsa
|
||||||
err: e,
|
err: e,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// Deal strictly in time and periods.
|
hwp.set_buffer_time_near(BUFFER_TIME.as_micros() as u32, ValueOr::Nearest)
|
||||||
hwp.set_periods(NUM_PERIODS, ValueOr::Nearest)
|
|
||||||
.map_err(AlsaError::HwParams)?;
|
.map_err(AlsaError::HwParams)?;
|
||||||
|
|
||||||
hwp.set_period_time_near(PERIOD_TIME.as_micros() as u32, ValueOr::Nearest)
|
hwp.set_period_time_near(PERIOD_TIME.as_micros() as u32, ValueOr::Nearest)
|
||||||
|
|
Loading…
Reference in a new issue