adapt to windows audio quirks (virtualbox ones at least)
This commit is contained in:
parent
bb974c2015
commit
706ed9db03
2 changed files with 11 additions and 1 deletions
|
@ -59,6 +59,8 @@ impl eframe::App for GUI {
|
|||
ui.label(format!("Right tof: {}", if let Some(tof) = telem.sensors.tof_r {format!("✅ {tof}mm")} else {"❌".into()}));
|
||||
ui.label(format!("Side tof: {}", if let Some(tof) = telem.sensors.tof_s {format!("✅ {tof}mm")} else {"❌".into()}));
|
||||
ui.label(format!("Gyro: {}", if telem.sensors.gyro.is_some() {"✅"} else {"❌"}));
|
||||
|
||||
ui.label(format!("Cam: {:?}", telem.cam_state));
|
||||
} else {
|
||||
ui.label("disconnected");
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
#![feature(iter_collect_into)]
|
||||
use std::{ops::ControlFlow, result, sync::Arc, thread::{self, sleep}, time::Duration};
|
||||
|
||||
|
@ -17,8 +16,14 @@ fn main() -> Result<()> {
|
|||
// assumes pulseaudio system with f32 samples and 2204 sample packets
|
||||
dbg!(cpal::available_hosts());
|
||||
let host = cpal::default_host();
|
||||
#[cfg(target_os = "windows")]
|
||||
let Some(device) = host.devices().unwrap().filter(|device| device.supported_input_configs().unwrap().count() != 0).next() else {
|
||||
panic!("no input devices")
|
||||
};
|
||||
#[cfg(target_os = "linux")]
|
||||
let device = host.devices().unwrap().find(|d|d.name().unwrap() == "pulse").context("no pulse")?;
|
||||
|
||||
|
||||
let config = device.default_input_config()?;
|
||||
|
||||
dbg!(config.sample_format());
|
||||
|
@ -28,7 +33,10 @@ fn main() -> Result<()> {
|
|||
|
||||
const POWER_THRESHOLD: f32 = 5.0;
|
||||
const CLARITY_THRESHOLD: f32 = 0.85;
|
||||
#[cfg(target_os = "linux")]
|
||||
const PACKET_LEN: usize = 2204;
|
||||
#[cfg(target_os = "windows")]
|
||||
const PACKET_LEN: usize = 512;
|
||||
|
||||
let stream = device.build_input_stream(&config.into(),
|
||||
move | data: &[f32], _: &_| {
|
||||
|
|
Loading…
Reference in a new issue