Merge pull request #346 from Heap-Hop/master

optimize audio
This commit is contained in:
RustDesk
2021-12-29 00:11:41 +08:00
committed by GitHub
3 changed files with 40 additions and 24 deletions

View File

@@ -416,6 +416,7 @@ async fn start_pa() {
};
log::info!("pa monitor: {:?}", device);
// systemctl --user status pulseaudio.service
let mut buf: Vec<u8> = vec![0; 480 * 4];
match psimple::Simple::new(
None, // Use the default server
APP_NAME, // Our applications name
@@ -430,14 +431,10 @@ async fn start_pa() {
if let Some(Err(_)) = stream.next_timeout2(1).await {
break;
}
let mut out: Vec<u8> = Vec::with_capacity(480 * 4);
unsafe {
out.set_len(out.capacity());
}
if let Ok(_) = s.read(&mut out) {
if out.iter().filter(|x| **x != 0).next().is_some() {
allow_err!(stream.send(&Data::RawMessage(out)).await);
}
if let Ok(_) = s.read(&mut buf) {
allow_err!(
stream.send(&Data::RawMessage(buf.clone())).await
);
}
},
Err(err) => {