mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Convert get_latency_pcm to get_latency_ms in sample_pipeline
This commit is contained in:
parent
9861a582a6
commit
3bcf5498d2
3 changed files with 7 additions and 5 deletions
|
@ -137,7 +137,7 @@ impl Sink for PulseAudioSink {
|
|||
.and_then(|sink| {
|
||||
sink.get_latency()
|
||||
.ok()
|
||||
.map(|micro_sec| (micro_sec.as_secs_f64() * SAMPLE_RATE as f64).round() as u64)
|
||||
.map(|micro_sec| (micro_sec.as_secs_f64() * SAMPLE_RATE as f64) as u64)
|
||||
})
|
||||
.unwrap_or(0)
|
||||
}
|
||||
|
|
|
@ -119,8 +119,7 @@ impl MonoResampler for MonoSincResampler {
|
|||
|
||||
let delay_line_latency = (interpolation_quality.get_interpolation_coefficients_length()
|
||||
as f64
|
||||
* spec.resample_factor_reciprocal)
|
||||
.round() as u64;
|
||||
* spec.resample_factor_reciprocal) as u64;
|
||||
|
||||
Self {
|
||||
interpolator: WindowedSincInterpolator::new(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::{
|
||||
MS_PER_PAGE,
|
||||
audio_backend::{Sink, SinkResult},
|
||||
config::PlayerConfig,
|
||||
convert::Converter,
|
||||
|
@ -36,8 +37,10 @@ impl SamplePipeline {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_latency_pcm(&mut self) -> u64 {
|
||||
self.sink.get_latency_pcm() + self.resampler.get_latency_pcm()
|
||||
pub fn get_latency_ms(&mut self) -> u32 {
|
||||
let total_latency_pcm = self.sink.get_latency_pcm() + self.resampler.get_latency_pcm();
|
||||
|
||||
(total_latency_pcm as f64 * MS_PER_PAGE) as u32
|
||||
}
|
||||
|
||||
pub fn start(&mut self) -> SinkResult<()> {
|
||||
|
|
Loading…
Reference in a new issue