mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-12-03 03:19:27 +08:00
This commit is contained in:
parent
589177fc94
commit
3d39d9c27c
@ -36,35 +36,31 @@ mod pa_impl {
|
|||||||
use super::*;
|
use super::*;
|
||||||
#[tokio::main(flavor = "current_thread")]
|
#[tokio::main(flavor = "current_thread")]
|
||||||
pub async fn run(sp: GenericService) -> ResultType<()> {
|
pub async fn run(sp: GenericService) -> ResultType<()> {
|
||||||
if let Ok(mut stream) = crate::ipc::connect(1000, "_pa").await {
|
hbb_common::sleep(0.1).await; // one moment to wait for _pa ipc
|
||||||
let mut encoder =
|
let mut stream = crate::ipc::connect(1000, "_pa").await?;
|
||||||
Encoder::new(crate::platform::linux::PA_SAMPLE_RATE, Stereo, LowDelay)?;
|
let mut encoder = Encoder::new(crate::platform::linux::PA_SAMPLE_RATE, Stereo, LowDelay)?;
|
||||||
allow_err!(
|
allow_err!(
|
||||||
stream
|
stream
|
||||||
.send(&crate::ipc::Data::Config((
|
.send(&crate::ipc::Data::Config((
|
||||||
"audio-input".to_owned(),
|
"audio-input".to_owned(),
|
||||||
Some(Config::get_option("audio-input"))
|
Some(Config::get_option("audio-input"))
|
||||||
)))
|
)))
|
||||||
.await
|
.await
|
||||||
);
|
);
|
||||||
while sp.ok() {
|
while sp.ok() {
|
||||||
sp.snapshot(|sps| {
|
sp.snapshot(|sps| {
|
||||||
sps.send(create_format_msg(crate::platform::linux::PA_SAMPLE_RATE, 2));
|
sps.send(create_format_msg(crate::platform::linux::PA_SAMPLE_RATE, 2));
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
if let Some(data) = stream.next_timeout2(1000).await {
|
if let Some(data) = stream.next_timeout2(1000).await {
|
||||||
match data? {
|
match data? {
|
||||||
Some(crate::ipc::Data::RawMessage(bytes)) => {
|
Some(crate::ipc::Data::RawMessage(bytes)) => {
|
||||||
let data = unsafe {
|
let data = unsafe {
|
||||||
std::slice::from_raw_parts::<f32>(
|
std::slice::from_raw_parts::<f32>(bytes.as_ptr() as _, bytes.len() / 4)
|
||||||
bytes.as_ptr() as _,
|
};
|
||||||
bytes.len() / 4,
|
send_f32(data, &mut encoder, &sp);
|
||||||
)
|
|
||||||
};
|
|
||||||
send_f32(data, &mut encoder, &sp);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
src/ui/cm.rs
12
src/ui/cm.rs
@ -405,12 +405,13 @@ async fn start_pa() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let spec = pulse::sample::Spec {
|
let spec = pulse::sample::Spec {
|
||||||
format: pulse::sample::Format::F32be,
|
format: pulse::sample::Format::F32le,
|
||||||
channels: 2,
|
channels: 2,
|
||||||
rate: crate::platform::linux::PA_SAMPLE_RATE,
|
rate: crate::platform::linux::PA_SAMPLE_RATE,
|
||||||
};
|
};
|
||||||
log::info!("pa monitor: {:?}", device);
|
log::info!("pa monitor: {:?}", device);
|
||||||
if let Ok(s) = psimple::Simple::new(
|
// systemctl --user status pulseaudio.service
|
||||||
|
match psimple::Simple::new(
|
||||||
None, // Use the default server
|
None, // Use the default server
|
||||||
APP_NAME, // Our application’s name
|
APP_NAME, // Our application’s name
|
||||||
pulse::stream::Direction::Record, // We want a record stream
|
pulse::stream::Direction::Record, // We want a record stream
|
||||||
@ -420,7 +421,7 @@ async fn start_pa() {
|
|||||||
None, // Use default channel map
|
None, // Use default channel map
|
||||||
None, // Use default buffering attributes
|
None, // Use default buffering attributes
|
||||||
) {
|
) {
|
||||||
loop {
|
Ok(s) => loop {
|
||||||
if let Some(Err(_)) = stream.next_timeout2(1).await {
|
if let Some(Err(_)) = stream.next_timeout2(1).await {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -433,9 +434,10 @@ async fn start_pa() {
|
|||||||
allow_err!(stream.send(&Data::RawMessage(out)).await);
|
allow_err!(stream.send(&Data::RawMessage(out)).await);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
log::error!("Could not create simple pulse: {}", err);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
log::error!("Could not create simple pulse");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user