voice: deep stability audit — FFmpeg crash recovery, activity timeout, reconnect refresh

Gateway (transmitter.ts):
- Auto-stop on FFmpeg crash: non-zero exit triggers stop() to prevent
  silent audio loss and resource leaks
- Voice activity timeout (10s): auto-stops transmitter when no PCM
  received, preventing dead-air CPU waste on backgrounded tabs
- Stderr cap (4KB): prevents unbounded memory growth in long sessions

Gateway (voice.handler.ts):
- Double-check voiceController.getStatus().connected before starting
  transmitter — detects stale player state after gateway disconnect

Frontend (context.tsx):
- Force-refetch voice status on WS reconnect — UI converges in <1s
  instead of waiting up to 4s for SWR poll interval

All: tsc clean, biome clean
This commit is contained in:
asepharyana committed 2026-08-26 23:48:36 +07:00
1 parent 7e0d0d5123
commit a6e2c1fa4f
4 files changed
+68 -4

No files matched your search

@@ -80,6 +80,7 @@ export class PcmPlayer {
ring.write++;
}
// Overflow guard: never let the ring lag more than RING_LEN behind.
// This handles both normal drift and extreme backpressure scenarios.
const lag = ring.write - ring.readPos;
if (lag > RING_LEN - 4096) {
ring.readPos = ring.write - RING_LEN + 4096;