adds docs for BufferSize and fixes buffersize bugs in emscripten and alsa
This commit is contained in:
parent
271cc34f3f
commit
4ce12a69b9
|
@ -905,13 +905,6 @@ fn set_hw_params_from_format<'a>(
|
||||||
BufferSize::Default => (),
|
BufferSize::Default => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this isn't set manually a overlarge buffer may be used causing audio delay
|
|
||||||
let mut hw_params_copy = hw_params.clone();
|
|
||||||
if let Err(_) = hw_params.set_buffer_time_near(100_000, alsa::ValueOr::Nearest) {
|
|
||||||
// Swap out the params with errors for a snapshot taken before the error was introduced.
|
|
||||||
mem::swap(&mut hw_params_copy, &mut hw_params);
|
|
||||||
}
|
|
||||||
|
|
||||||
pcm_handle.hw_params(&hw_params)?;
|
pcm_handle.hw_params(&hw_params)?;
|
||||||
|
|
||||||
Ok(hw_params)
|
Ok(hw_params)
|
||||||
|
|
|
@ -334,7 +334,7 @@ fn audio_callback_fn<D, E>(
|
||||||
// and there may be underflows
|
// and there may be underflows
|
||||||
set_timeout(
|
set_timeout(
|
||||||
|| audio_callback_fn::<D, E>(user_data_ptr, config, sample_format, buffer_size_frames),
|
|| audio_callback_fn::<D, E>(user_data_ptr, config, sample_format, buffer_size_frames),
|
||||||
330,
|
buffer_size_frames * 1000 / sample_rate,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,6 +183,13 @@ pub struct SampleRate(pub u32);
|
||||||
/// The desired number of frames for the hardware buffer.
|
/// The desired number of frames for the hardware buffer.
|
||||||
pub type FrameCount = u32;
|
pub type FrameCount = u32;
|
||||||
|
|
||||||
|
/// The buffer size used by the device.
|
||||||
|
///
|
||||||
|
/// Default is used when no specific buffer size is set and uses the default
|
||||||
|
/// behavior of the given host. Note, the default buffer size may be surprisingly
|
||||||
|
/// large, leading to latency issues. If low latency is desired, Fixed(BufferSize)
|
||||||
|
/// should be used in accordance with the SupportedBufferSize range produced by
|
||||||
|
/// the SupportedStreamConfig API.
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum BufferSize {
|
pub enum BufferSize {
|
||||||
Default,
|
Default,
|
||||||
|
|
Loading…
Reference in New Issue