diff --git a/src/audio/mod.rs b/src/audio/mod.rs index bdd4b47..8f960ea 100644 --- a/src/audio/mod.rs +++ b/src/audio/mod.rs @@ -22,7 +22,7 @@ pub struct SoundManager { audio_controls: Receiver, player_chan: Sender, sample_in: Sender>, - pw_signal_in: pipewire::channel::Sender>>, + pw_signal_in: pipewire::channel::Sender>, } pub fn init( diff --git a/src/audio/pw.rs b/src/audio/pw.rs index ca3f4e7..29f1e88 100644 --- a/src/audio/pw.rs +++ b/src/audio/pw.rs @@ -15,7 +15,7 @@ use crate::utils::Error; pub fn init( samples: std::sync::mpsc::Receiver>, - pw_signal: Receiver>>, + pw_signal: Receiver>, ) -> Result<(), Error> { let mainloop = MainLoop::new(None)?; let context = Context::new(&mainloop)?; @@ -38,15 +38,16 @@ pub fn init( Some(mut buf) => { let data = &mut (buf.datas_mut()[0]); let n_iter = if let Some(sample_buf) = data.data() { - let next_samples = samples - .recv() - .expect("Sample sender disconnected unexpectedly"); - if next_samples.len() > sample_buf.len() { - panic!("Buffer too small for given sample chunks"); + if let Ok(next_samples) = samples.try_recv() { + if next_samples.len() > sample_buf.len() { + panic!("Buffer too small for given sample chunks"); + } + let slice = &mut sample_buf[0..next_samples.len()]; + slice.copy_from_slice(&next_samples); + slice.len() + } else { + 0 } - let slice = &mut sample_buf[0..next_samples.len()]; - slice.copy_from_slice(&next_samples); - slice.len() } else { 0 }; diff --git a/src/audio/sound_mgr.rs b/src/audio/sound_mgr.rs index 4b48629..07a6aa2 100644 --- a/src/audio/sound_mgr.rs +++ b/src/audio/sound_mgr.rs @@ -58,7 +58,7 @@ impl SoundManager { .unwrap() .0 .into_inner(); - pw_signal_in.send(Box::new(test_pod)).unwrap(); + pw_signal_in.send(test_pod).unwrap(); Ok(SoundManager { settings, error_chan,