From c91a91643e75ea7f110ad203c382ff4e24748efd Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Wed, 26 Aug 2026 14:56:11 +0200 Subject: [PATCH] logging --- src-tauri/src/commands/audio.rs | 12 +++++++++--- src/app/ws.ts | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/commands/audio.rs b/src-tauri/src/commands/audio.rs index c32ba92..f8d5054 100644 --- a/src-tauri/src/commands/audio.rs +++ b/src-tauri/src/commands/audio.rs @@ -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())?; diff --git a/src/app/ws.ts b/src/app/ws.ts index 6b08d04..9962d7b 100644 --- a/src/app/ws.ts +++ b/src/app/ws.ts @@ -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()); };