Skip to content

fix: add audio device probe and afplay timeout to VoiceServer#951

Open
MarvinDontPanic wants to merge 1 commit intodanielmiessler:mainfrom
MarvinDontPanic:fix/voiceserver-audio-probe
Open

fix: add audio device probe and afplay timeout to VoiceServer#951
MarvinDontPanic wants to merge 1 commit intodanielmiessler:mainfrom
MarvinDontPanic:fix/voiceserver-audio-probe

Conversation

@MarvinDontPanic
Copy link

Summary

Two related reliability fixes for VoiceServer on macOS:

  • Audio device probe at startup: Plays a near-silent system sound (Tink.aiff at 1% volume) with a 3-second timeout. If afplay hangs (no output device, virtual audio, or running under launchd without an audio session), all voice playback is disabled for the session rather than hanging the server
  • afplay timeout per-clip: 10-second timeout on each playback call with a settled-flag pattern to prevent resolve/reject races. Most TTS clips are 1-3s, so 10s catches hung audio devices without cutting off legitimate long utterances

Problem

Without these fixes, afplay hangs indefinitely when no audio output device is available, blocking the notification server's /notify endpoint. This commonly happens when:

  • Running VoiceServer as a system service (launchd) without an audio session
  • Virtual audio devices that accept connections but don't produce output
  • Headless environments or SSH sessions

File Changed

Releases/v4.0.3/.claude/VoiceServer/server.ts

Test plan

  • Start VoiceServer with working audio → probe reports "output device available", playback works
  • Start VoiceServer without audio output → probe reports "no usable output device", /notify returns success but skips playback
  • Send a notification during audio device disconnect → timeout fires after 10s instead of hanging

🤖 Generated with Claude Code

Two related reliability fixes for VoiceServer on macOS:

1. Audio device probe at startup: Plays a near-silent system sound
   with a 3s timeout. If afplay hangs (no output device, virtual
   audio, running under launchd without audio session), all voice
   playback is disabled for the session rather than hanging.

2. afplay timeout per-clip: 10s timeout on each playback call with
   a settled-flag pattern to prevent resolve/reject races. Most TTS
   clips are 1-3s, so 10s catches hung audio devices without
   cutting off legitimate long utterances.

Without these fixes, afplay hangs indefinitely when no audio output
device is available, blocking the notification server.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant