mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Avoid unnecessary Vec -> Slice -> Vec
In the case of a resampler bypass
This commit is contained in:
parent
20414e44b8
commit
cea92a9c3a
2 changed files with 4 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -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()?;
|
||||
|
|
Loading…
Reference in a new issue