mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-28 17:21:52 +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| {
|
.and_then(|sink| {
|
||||||
sink.get_latency()
|
sink.get_latency()
|
||||||
.ok()
|
.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)
|
.unwrap_or(0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,8 +119,7 @@ impl MonoResampler for MonoSincResampler {
|
||||||
|
|
||||||
let delay_line_latency = (interpolation_quality.get_interpolation_coefficients_length()
|
let delay_line_latency = (interpolation_quality.get_interpolation_coefficients_length()
|
||||||
as f64
|
as f64
|
||||||
* spec.resample_factor_reciprocal)
|
* spec.resample_factor_reciprocal) as u64;
|
||||||
.round() as u64;
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
interpolator: WindowedSincInterpolator::new(
|
interpolator: WindowedSincInterpolator::new(
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
|
MS_PER_PAGE,
|
||||||
audio_backend::{Sink, SinkResult},
|
audio_backend::{Sink, SinkResult},
|
||||||
config::PlayerConfig,
|
config::PlayerConfig,
|
||||||
convert::Converter,
|
convert::Converter,
|
||||||
|
@ -36,8 +37,10 @@ impl SamplePipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_latency_pcm(&mut self) -> u64 {
|
pub fn get_latency_ms(&mut self) -> u32 {
|
||||||
self.sink.get_latency_pcm() + self.resampler.get_latency_pcm()
|
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<()> {
|
pub fn start(&mut self) -> SinkResult<()> {
|
||||||
|
|
Loading…
Reference in a new issue