logging
This commit is contained in:
@@ -127,9 +127,14 @@ pub fn connect_to_vc(
|
|||||||
packet.extend_from_slice(&sample.to_be_bytes());
|
packet.extend_from_slice(&sample.to_be_bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eprintln!(
|
||||||
|
"[vc] mic captured {} samples ({} bytes)",
|
||||||
|
pcm.len(),
|
||||||
|
packet.len()
|
||||||
|
);
|
||||||
let _ = input_socket.send(&packet);
|
let _ = input_socket.send(&packet);
|
||||||
},
|
},
|
||||||
|err| eprintln!("Input stream error: {err}"),
|
|err| eprintln!("[vc] input stream error: {err}"),
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
@@ -148,14 +153,15 @@ pub fn connect_to_vc(
|
|||||||
output_config,
|
output_config,
|
||||||
move |data: &mut [f32], _| {
|
move |data: &mut [f32], _| {
|
||||||
if let Ok(pcm) = audio_rx.try_recv() {
|
if let Ok(pcm) = audio_rx.try_recv() {
|
||||||
|
eprintln!("[vc] playing {} samples", pcm.len());
|
||||||
for (out, sample) in data.iter_mut().zip(pcm.iter()) {
|
for (out, sample) in data.iter_mut().zip(pcm.iter()) {
|
||||||
*out = *sample as f32 / i16::MAX as f32;
|
*out = *sample as f32 / i16::MAX as f32;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data.fill(0.0); // silence if nothing's arrived yet
|
data.fill(0.0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|err| eprintln!("Output stream error: {err}"),
|
|err| eprintln!("[vc] output stream error: {err}"),
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { ClientMethod, ServerMethod } from "./protocol";
|
import { ClientMethod, ServerMethod } from "./protocol";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,6 +16,9 @@ export default class EnclaveWebSocket {
|
|||||||
this.onOpenQueue = new Array();
|
this.onOpenQueue = new Array();
|
||||||
|
|
||||||
this.websocket = new WebSocket(hostname);
|
this.websocket = new WebSocket(hostname);
|
||||||
|
this.websocket.onclose = () => {
|
||||||
|
invoke("disconnect_from_vc");
|
||||||
|
};
|
||||||
this.websocket.onopen = () => {
|
this.websocket.onopen = () => {
|
||||||
this.onOpenQueue.forEach((fun) => fun());
|
this.onOpenQueue.forEach((fun) => fun());
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user