cleaner handling, remove unneeded Box on audio info
This commit is contained in:
parent
2c66db4205
commit
7e56d50898
3 changed files with 12 additions and 11 deletions
|
@ -22,7 +22,7 @@ pub struct SoundManager {
|
|||
audio_controls: Receiver<AudioEvent>,
|
||||
player_chan: Sender<PlayerEvent>,
|
||||
sample_in: Sender<Vec<u8>>,
|
||||
pw_signal_in: pipewire::channel::Sender<Box<Vec<u8>>>,
|
||||
pw_signal_in: pipewire::channel::Sender<Vec<u8>>,
|
||||
}
|
||||
|
||||
pub fn init(
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::utils::Error;
|
|||
|
||||
pub fn init(
|
||||
samples: std::sync::mpsc::Receiver<Vec<u8>>,
|
||||
pw_signal: Receiver<Box<Vec<u8>>>,
|
||||
pw_signal: Receiver<Vec<u8>>,
|
||||
) -> 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
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue