src: adopt the log crate and feed logs into the UI
This commit is contained in:
+7
-9
@@ -60,7 +60,6 @@ struct Notify {
|
||||
config: AudioConfig,
|
||||
mic_port: jack::Port<jack::Unowned>,
|
||||
tts_port: jack::Port<jack::Unowned>,
|
||||
log: mpsc::Sender<String>
|
||||
}
|
||||
|
||||
impl NotificationHandler for Notify {
|
||||
@@ -84,10 +83,10 @@ impl NotificationHandler for Notify {
|
||||
|
||||
if let Ok(port_name) = other_port.name() {
|
||||
if are_connected {
|
||||
self.log.blocking_send(format!("{} connected to {}", stream_name, port_name)).unwrap();
|
||||
log::info!("{} connected to {}", stream_name, port_name);
|
||||
target_cfg.push(port_name);
|
||||
} else {
|
||||
self.log.blocking_send(format!("{} disconnected from {}", stream_name, port_name)).unwrap();
|
||||
log::info!("{} disconnected from {}", stream_name, port_name);
|
||||
target_cfg.retain(|x| { x != &port_name} );
|
||||
}
|
||||
|
||||
@@ -97,7 +96,7 @@ impl NotificationHandler for Notify {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn start_audio_input(messages: &mpsc::Sender<String>) -> (AudioInputControl, MicStream, TtsOutStream) {
|
||||
pub async fn start_audio_input() -> (AudioInputControl, MicStream, TtsOutStream) {
|
||||
|
||||
let (exit_tx, exit_rx) = oneshot::channel();
|
||||
|
||||
@@ -117,17 +116,17 @@ pub async fn start_audio_input(messages: &mpsc::Sender<String>) -> (AudioInputCo
|
||||
|
||||
for port in &config.mic_in_connections {
|
||||
if let Ok(_) = client.connect_ports_by_name(&port, &mic_name) {
|
||||
messages.send(format!("Connected mic to {}", port)).await.unwrap();
|
||||
log::info!("Connected mic to {}", port);
|
||||
} else {
|
||||
messages.send(format!("Failed to reconnect mic to {}.", port)).await.unwrap();
|
||||
log::warn!("Failed to reconnect mic to {}.", port);
|
||||
}
|
||||
}
|
||||
|
||||
for port in &config.tts_out_connections {
|
||||
if let Ok(_) = client.connect_ports_by_name(&tts_name, &port) {
|
||||
messages.send(format!("Connected TTS output to {}", port)).await.unwrap();
|
||||
log::info!("Connected TTS output to {}", port);
|
||||
} else {
|
||||
messages.send(format!("Failed to reconnect TTS output to {}.", port)).await.unwrap();
|
||||
log::warn!("Failed to reconnect TTS output to {}.", port);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +134,6 @@ pub async fn start_audio_input(messages: &mpsc::Sender<String>) -> (AudioInputCo
|
||||
config,
|
||||
mic_port: mic_port.clone_unowned(),
|
||||
tts_port: tts_port.clone_unowned(),
|
||||
log: messages.clone()
|
||||
};
|
||||
|
||||
let mut meter = VuMeter::new(rate.into(), 1, None);
|
||||
|
||||
Reference in New Issue
Block a user