name: pull request about: Audio Device Reconnection Logic for Long-Running Sessions title: “[pr] fix audio device randomly stopping sometimes “


Fix: Audio Device Reconnection Logic for Long-Running Sessions

related issue: #1626

Problem

Audio recording was stopping after extended periods (48h+) on macOS due to device disconnections without proper reconnection handling. The system would fail permanently when a device disconnected instead of attempting to recover.

Solution

Implemented a robust device reconnection system with configurable retry logic:

Key Changes

  • Added device-specific reconnection tracking with reconnect_attempts
  • Implemented maximum reconnection attempts (10) with 5-second delay between attempts
  • Added proper device state management through is_disconnected flag
  • Improved logging for reconnection attempts and success/failure states

Technical Details

const MAX_RECONNECT_ATTEMPTS: u32 = 10;
const RECONNECT_DELAY: Duration = Duration::from_secs(5);
  • Tracks reconnection attempts per device
  • Resets attempt counter on successful reconnection
  • Maintains device state through atomic boolean flag
  • Provides detailed logging of reconnection progress

Testing

  • Verified long-running stability (>72h) on macOS
  • Tested recovery from device disconnections
  • Confirmed proper reset of reconnection attempts after successful recovery

Notes

  • No changes to core audio processing logic
  • Maintains existing whisper integration

/claim #1626

Claim

Total prize pool $400
Total paid $0
Status Pending
Submitted May 21, 2025
Last updated May 21, 2025

Contributors

AN

Anmol Sharma

@Anmol202005

100%

Sponsors

SC

screenpi.pe

@mediar-ai

$400