Skip to content

Commit

Permalink
fix(playback): fix condition of enabling resample (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
snylonue authored Oct 3, 2024
1 parent dee0e19 commit f75baee
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion anni-playback/src/cpal_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ pub struct CpalOutput {
pub spec: SignalSpec,
pub duration: u64,
pub buffer_signal: Arc<AtomicBool>,
sample_rate: u32,
ring_buffer_writer: BlockingRb<f32, Producer>,
sample_buffer: SampleBuffer<f32>,
resampler: Option<Resampler<f32>>,
Expand Down Expand Up @@ -242,6 +243,7 @@ impl CpalOutput {
spec,
duration,
buffer_signal,
sample_rate: config.sample_rate.0,
ring_buffer_writer,
sample_buffer,
resampler,
Expand All @@ -256,7 +258,7 @@ impl CpalOutput {
return;
}

let need_resample = decoded.spec().rate != self.spec.rate;
let need_resample = decoded.spec().rate != self.sample_rate;
let mut samples = match (need_resample, &mut self.resampler) {
(true, Some(resampler)) => {
// If there is a resampler, then write resampled values
Expand Down

0 comments on commit f75baee

Please sign in to comment.