Skip to content

Commit

Permalink
minor(audio::input): resampling buf sizes: keep input >= output
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-msp committed Apr 15, 2024
1 parent 66815b0 commit f28d026
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/audio/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ where
let resampler = FftFixedOut::new(input_rate, 16_000, chunk_size_out, 1, channels)?;

Ok(Self {
buffer: Vec::with_capacity(resampler.nbr_channels() * resampler.input_frames_next()),
buffer: Vec::with_capacity(
chunk_size_out.max(resampler.nbr_channels() * resampler.input_frames_max()),
),
config,
resampler,
sink,
Expand Down Expand Up @@ -328,7 +330,7 @@ impl<O: MySample> Processor<f32, O> {
}

fn input_buffer(&self) -> Vec<f32> {
let cap = self.resampler.nbr_channels() * self.resampler.input_frames_max();
let cap = self.buffer.capacity();
log::trace!("Allocating input buffer with capacity: {}", cap);
Vec::with_capacity(cap)
}
Expand Down

0 comments on commit f28d026

Please sign in to comment.