This commit is contained in:
2026-08-26 14:56:11 +02:00
parent f6cfea1621
commit c91a91643e
2 changed files with 13 additions and 3 deletions
+9 -3
View File
@@ -127,9 +127,14 @@ pub fn connect_to_vc(
packet.extend_from_slice(&sample.to_be_bytes());
}
eprintln!(
"[vc] mic captured {} samples ({} bytes)",
pcm.len(),
packet.len()
);
let _ = input_socket.send(&packet);
},
|err| eprintln!("Input stream error: {err}"),
|err| eprintln!("[vc] input stream error: {err}"),
None,
)
.map_err(|e| e.to_string())?;
@@ -148,14 +153,15 @@ pub fn connect_to_vc(
output_config,
move |data: &mut [f32], _| {
if let Ok(pcm) = audio_rx.try_recv() {
eprintln!("[vc] playing {} samples", pcm.len());
for (out, sample) in data.iter_mut().zip(pcm.iter()) {
*out = *sample as f32 / i16::MAX as f32;
}
} 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,
)
.map_err(|e| e.to_string())?;
+4
View File
@@ -1,3 +1,4 @@
import { invoke } from "@tauri-apps/api/core";
import { ClientMethod, ServerMethod } from "./protocol";
/**
@@ -15,6 +16,9 @@ export default class EnclaveWebSocket {
this.onOpenQueue = new Array();
this.websocket = new WebSocket(hostname);
this.websocket.onclose = () => {
invoke("disconnect_from_vc");
};
this.websocket.onopen = () => {
this.onOpenQueue.forEach((fun) => fun());
};