Skip to content

Audio: don't hold the followers' lock while reopening a device (UI freezes, #94) - #95

Open
marcin-koziol wants to merge 1 commit into
BurningTreeC:mainfrom
marcin-koziol:follower-retry-unlocked
Open

marcin-koziol wants to merge 1 commit into
BurningTreeC:mainfrom
marcin-koziol:follower-retry-unlocked

Conversation

@marcin-koziol

Copy link
Copy Markdown

Problem

When a device that follows the master (a second audio device, e.g. an interface's input next to the built-in output) fails to open, the follower watcher tries again every second. It held the followers' lock for the whole try: looking for the device, opening it and starting the stream. On Windows a refused input ("access denied", e.g. after Windows 11 26H2 turned off microphone access for desktop apps) takes seconds per try.

The session takes the same lock every second (watch_followers → stream_devices) to show the devices, so the UI thread kept waiting on it. The interface stuttered and froze from launch, even when moving the window, at 2–3 % CPU, while the audio played on. No renderer setting helped (#94).

Fix

Watcher::tick takes the lock only to collect retired links and to attach a new link. Looking for the device, opening it and starting the stream happen without it.

Testing

🤖 Generated with Claude Code

…s' lock

The watcher held the followers' lock while it looked for a device that
went away and tried to open it again, every second. When Windows refuses
an input ("access denied": its microphone privacy setting, or another
program holding it), each try takes seconds, and the session, which takes
the same lock every second to show the devices, waited with it: the whole
interface stuttered and froze while the audio played on (BurningTreeC#94). The lock
is now taken only to collect retired links and to attach a new one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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