Avoid unnecessary Vec -> Slice -> Vec

In the case of a resampler bypass
This commit is contained in:
JasonLG1979 2023-06-27 19:21:02 -05:00
parent 20414e44b8
commit cea92a9c3a
2 changed files with 4 additions and 4 deletions

View file

@ -410,15 +410,15 @@ impl StereoInterleavedResampler {
self.latency_pcm
}
pub fn resample(&mut self, input_samples: &[f64]) -> Option<Vec<f64>> {
pub fn resample(&mut self, input_samples: Vec<f64>) -> Option<Vec<f64>> {
match &mut self.resampler {
// Bypass is basically a no-op.
Resampler::Bypass => Some(input_samples.to_vec()),
Resampler::Bypass => Some(input_samples),
Resampler::Worker {
left_resampler,
right_resampler,
} => {
let (left_samples, right_samples) = Self::deinterleave_samples(input_samples);
let (left_samples, right_samples) = Self::deinterleave_samples(&input_samples);
left_resampler.resample(left_samples);
right_resampler.resample(right_samples);

View file

@ -69,7 +69,7 @@ impl SamplePipeline {
pub fn write(&mut self, packet: AudioPacket) -> SinkResult<()> {
if let AudioPacket::Samples(samples) = packet {
self.resampler
.resample(&samples)
.resample(samples)
.map(|processed_samples| self.normaliser.normalise(processed_samples))
.map(|new_packet| self.sink.write(new_packet, &mut self.converter))
.transpose()?;