Skip to content

fix(audio): prevent app hang when audio device doesn't respond to cleanup#56

Merged
moinulmoin merged 1 commit intomoinulmoin:mainfrom
tomchapin:bugfix/audio-stream-timeout
Jan 29, 2026
Merged

fix(audio): prevent app hang when audio device doesn't respond to cleanup#56
moinulmoin merged 1 commit intomoinulmoin:mainfrom
tomchapin:bugfix/audio-stream-timeout

Conversation

@tomchapin
Copy link
Copy Markdown
Contributor

Summary

  • Fixes app freeze when stopping recordings with USB/wireless audio devices (e.g., Astro A50)
  • Some audio devices can hang indefinitely during stream cleanup on Windows WASAPI
  • App now gracefully recovers instead of freezing

Changes

  • Wrap drop(stream) in a separate thread with 1-second timeout
  • If timeout fires, abandon the hung thread and continue gracefully
  • Enhanced error callback to trigger stop on device errors (e.g., disconnection)
  • Added detailed logging for debugging audio device issues

Test plan

  • Tested with Astro A50 headset in frozen state
  • Verified app recovers after 1-second timeout
  • Verified recording pill disappears properly
  • Verified "no audio recorded" feedback shows
  • Verified user can immediately start new recording
  • Verified normal operation works when device is healthy

Log output when timeout fires

[WARN] ═══════════════════════════════════════════════════════
[WARN] ⚠️ AUDIO STREAM DROP TIMEOUT
[WARN] ═══════════════════════════════════════════════════════
[WARN] Timeout: 1000ms
[WARN] Elapsed: 1004ms
[WARN] Cause: Audio device driver not responding to cleanup
[WARN] Impact: Recording will continue, orphaned thread abandoned
[WARN] Resolution: Device may need to be unplugged/replugged
[WARN] ═══════════════════════════════════════════════════════

🤖 Generated with Claude Code

…anup

Some audio devices (especially USB/wireless headsets like Astro A50) can
hang indefinitely during stream cleanup on Windows. This causes the app
to freeze when stopping a recording.

Changes:
- Wrap drop(stream) in a separate thread with 1-second timeout
- If timeout fires, abandon the hung thread and continue gracefully
- Enhanced error callback to trigger stop on device errors (e.g., disconnection)
- Added detailed logging for debugging audio device issues

When the timeout fires:
- App recovers instead of freezing
- User sees "no audio recorded" feedback
- Recording state properly resets to idle
- User can immediately start a new recording

Co-Authored-By: Claude Opus 4.5 <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.

2 participants