snapcast_server/stream/
mod.rs1pub mod manager;
4
5use snapcast_proto::SampleFormat;
6use tokio::sync::mpsc;
7use tokio::task::JoinHandle;
8
9#[derive(Debug, Clone)]
11pub struct PcmChunk {
12 pub timestamp_usec: i64,
14 pub data: Vec<u8>,
16}
17
18pub struct StreamReader {
20 pub name: String,
22 pub format: SampleFormat,
24 pub rx: mpsc::Receiver<PcmChunk>,
26 handle: JoinHandle<()>,
28}
29
30impl StreamReader {
31 pub fn new(
33 name: String,
34 format: SampleFormat,
35 rx: mpsc::Receiver<PcmChunk>,
36 handle: JoinHandle<()>,
37 ) -> Self {
38 Self {
39 name,
40 format,
41 rx,
42 handle,
43 }
44 }
45
46 pub fn stop(&self) {
48 self.handle.abort();
49 }
50}
51
52impl Drop for StreamReader {
53 fn drop(&mut self) {
54 self.handle.abort();
55 }
56}