1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-04 10:19:27 +02:00

Merge branch 'dev' into tokio_migration

This commit is contained in:
johannesd3 2021-02-23 14:45:01 +01:00 committed by Johannesd3
commit 678d1777fd
32 changed files with 674 additions and 360 deletions

View file

@ -1,4 +1,5 @@
use super::{Open, Sink};
use crate::audio::AudioPacket;
use std::fs::OpenOptions;
use std::io::{self, Write};
use std::mem;
@ -26,12 +27,15 @@ impl Sink for StdoutSink {
Ok(())
}
fn write(&mut self, data: &[i16]) -> io::Result<()> {
let data: &[u8] = unsafe {
slice::from_raw_parts(
data.as_ptr() as *const u8,
data.len() * mem::size_of::<i16>(),
)
fn write(&mut self, packet: &AudioPacket) -> io::Result<()> {
let data: &[u8] = match packet {
AudioPacket::Samples(data) => unsafe {
slice::from_raw_parts(
data.as_ptr() as *const u8,
data.len() * mem::size_of::<i16>(),
)
},
AudioPacket::OggData(data) => data,
};
self.0.write_all(data)?;