fix audio device randomly stopping sometimes
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
🧪 testing bounty created!
a testing bounty has been created for this PR: view testing issue
testers will be awarded $20 each for providing quality test reports. please check the issue for testing requirements.
how did you reproduce it? @Anmol202005
i had high hope for this PR :D but ...
interesting here ... i was in a store and walking around with mac open then went to toilet closed the lid then it crashed (display audio seems)
but mic stopped working also then without error i think
interesting here ... i was in a store and walking around with mac open then went to toilet closed the lid then it crashed (display audio seems)
but mic stopped working also then without error i think
@louis030195 macOS can suspend audio when the system sleeps.
interesting here ... i was in a store and walking around with mac open then went to toilet closed the lid then it crashed (display audio seems) but mic stopped working also then without error i think
@louis030195 macOS can suspend audio when the system sleeps.
so what's your solution?
interesting here ... i was in a store and walking around with mac open then went to toilet closed the lid then it crashed (display audio seems) but mic stopped working also then without error i think
@louis030195 macOS can suspend audio when the system sleeps.
so what's your solution?
You closed the wrong lid. 😳