pub mod manager;
use snapcast_proto::SampleFormat;
use tokio::sync::mpsc;
use tokio::task::JoinHandle;
#[derive(Debug, Clone)]
pub struct PcmChunk {
pub timestamp_usec: i64,
pub data: Vec<u8>,
}
pub struct StreamReader {
pub name: String,
pub format: SampleFormat,
pub rx: mpsc::Receiver<PcmChunk>,
handle: JoinHandle<()>,
}
impl StreamReader {
pub fn new(
name: String,
format: SampleFormat,
rx: mpsc::Receiver<PcmChunk>,
handle: JoinHandle<()>,
) -> Self {
Self {
name,
format,
rx,
handle,
}
}
pub fn stop(&self) {
self.handle.abort();
}
}
impl Drop for StreamReader {
fn drop(&mut self) {
self.handle.abort();
}
}