mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-03 09:49:31 +02:00
Sink: pass ownership of the packet on write()
Prevent a copy if the implementation needs to keep the data around.
This commit is contained in:
parent
b1bdf1d7f2
commit
f09be4850e
7 changed files with 17 additions and 16 deletions
|
@ -140,7 +140,7 @@ impl<'a> Sink for PortAudioSink<'a> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn write(&mut self, packet: &AudioPacket, converter: &mut Converter) -> SinkResult<()> {
|
||||
fn write(&mut self, packet: AudioPacket, converter: &mut Converter) -> SinkResult<()> {
|
||||
macro_rules! write_sink {
|
||||
(ref mut $stream: expr, $samples: expr) => {
|
||||
$stream.as_mut().unwrap().write($samples)
|
||||
|
@ -153,15 +153,15 @@ impl<'a> Sink for PortAudioSink<'a> {
|
|||
|
||||
let result = match self {
|
||||
Self::F32(stream, _parameters) => {
|
||||
let samples_f32: &[f32] = &converter.f64_to_f32(samples);
|
||||
let samples_f32: &[f32] = &converter.f64_to_f32(&samples);
|
||||
write_sink!(ref mut stream, samples_f32)
|
||||
}
|
||||
Self::S32(stream, _parameters) => {
|
||||
let samples_s32: &[i32] = &converter.f64_to_s32(samples);
|
||||
let samples_s32: &[i32] = &converter.f64_to_s32(&samples);
|
||||
write_sink!(ref mut stream, samples_s32)
|
||||
}
|
||||
Self::S16(stream, _parameters) => {
|
||||
let samples_s16: &[i16] = &converter.f64_to_s16(samples);
|
||||
let samples_s16: &[i16] = &converter.f64_to_s16(&samples);
|
||||
write_sink!(ref mut stream, samples_s16)
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue