From 30a0c3b479b1ff39ad2bf9fbd58c93634ed418b2 Mon Sep 17 00:00:00 2001 From: Eskil Q Date: Sat, 2 Jan 2021 11:25:29 +0100 Subject: remove AudioStream struct --- mumd/src/audio/input.rs | 35 ----------------------------------- 1 file changed, 35 deletions(-) (limited to 'mumd/src/audio/input.rs') diff --git a/mumd/src/audio/input.rs b/mumd/src/audio/input.rs index febcb17..517c9ce 100644 --- a/mumd/src/audio/input.rs +++ b/mumd/src/audio/input.rs @@ -22,39 +22,4 @@ pub fn callback( } } } -} - -struct AudioStream { - data: Arc, Option)>>, -} - -impl AudioStream { - fn new() -> Self { - Self { - data: Arc::new(Mutex::new((VecDeque::new(), None))) - } - } - - fn insert_sample(&self, sample: T) { - let mut data = self.data.lock().unwrap(); - data.0.push_back(sample); - if let Some(waker) = data.1.take() { - waker.wake(); - } - } -} - -impl Stream for AudioStream { - type Item = T; - - fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - let s = self.get_mut(); - let mut data = s.data.lock().unwrap(); - if data.0.len() > 0 { - Poll::Ready(data.0.pop_front()) - } else { - data.1 = Some(cx.waker().clone()); - Poll::Pending - } - } } \ No newline at end of file -- cgit v1.2.1