screenpipe icon indicating copy to clipboard operation
screenpipe copied to clipboard

fix audio device randomly stopping sometimes

Open Anmol202005 opened this issue 7 months ago • 5 comments


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

Anmol202005 avatar May 21 '25 20:05 Anmol202005

🧪 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.

github-actions[bot] avatar May 21 '25 20:05 github-actions[bot]

how did you reproduce it? @Anmol202005

tribhuwan-kumar avatar May 22 '25 14:05 tribhuwan-kumar

i had high hope for this PR :D but ...

Screenshot 2025-05-22 at 7 36 06 PM Screenshot 2025-05-22 at 7 37 03 PM Screenshot 2025-05-22 at 7 35 13 PM

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 avatar May 23 '25 02:05 louis030195

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.

Anmol202005 avatar May 29 '25 10:05 Anmol202005

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?

louis030195 avatar May 29 '25 17:05 louis030195

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. 😳

melmathari avatar Sep 25 '25 13:09 melmathari