Conversation
The driver remembered its target output device by UID. For USB audio devices without a serial number (common in Thunderbolt docks), macOS embeds the USB location ID into the synthesized UID, which means plugging into a different port produces a different UID. The driver would fail to find the device and stay silent until the user manually re-selected it. Two changes: * findTargetOutputAudioDevice now does a tolerant fallback pass. If no exact UID match is found, it looks for a UID that matches in every field except the USB location ID (the format is AppleUSBAudioEngine:<vendor>:<product>:<location>:<stream>). The stored UID is intentionally not overwritten, so returning to the original port still just works. * When setupTargetOutputDevice can't find the device at all, it now schedules a retry every 5 seconds. The device-list listener already covers most reconnections, but sleep/wake and transient Bluetooth dropouts don't always fire it. A generation counter ensures any in-flight retry from a previous failed setup is canceled when a new setup runs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
mcg1969
marked this pull request as ready for review
May 23, 2026 20:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
My audio device is the digital audio output from my CalDigit Thunderbolt dock. I was finding that sometimes, when I plug my dock back in, Proxy Audio Device wasn't finding the device anymore. I expected #61 / #70 to fix that, but it didn't... And I was finding the symptom was not consistent. Sometimes it found the device, sometimes it didn't.
It turns out that the randomness was generated by me. When I plug in the dock I'm doing it by feel, and I was alternating randomly between the two USB-C ports on the left/blind side of my MBP. If I plugged it into the other port compared to the one I used to set the ProxyAudioDevice settings, that's when it lost track of the device.
This PR makes the driver more robust about retaining its target output device when the device is briefly unavailable or its UID has changed because of a USB port swap.
The problem
The driver remembers its target output device by UID, but for USB audio devices that don't expose a serial number (common in Thunderbolt docks), macOS synthesizes the UID by embedding the USB location ID:
Plugging the same device into a different physical port on the Mac changes the location ID, which changes the UID. The driver would fail to find the device and stay silent until the user manually re-selected it from the Settings app.
This was also a contributing factor to the issue described in PR #61: when the dock came back on a different port, the proxy audio device remained "selected" but was effectively pointing at nothing. (With the new "hide when unavailable" preference from #70 turned on, the symptom shifted from "no audio" to "Proxy Audio is missing from the system audio list".)
The fix
Two complementary changes, both in the driver:
1. Tolerant USB UID matching in
findTargetOutputAudioDevice. When the exact UID match fails, a second pass looks for a device whose UID matches in every component except the location ID. OnlyAppleUSBAudioEngineUIDs of exactly the expected 5-component shape are eligible, so devices from the same vendor with different products won't be confused. The stored UID is intentionally not overwritten on a port-swap match — returning to the original port still just works.2. Periodic retry when the target device can't be found. When
setupTargetOutputDevicefinds no match, it now schedules a retry every 5 seconds via the existing audio-output dispatch queue. The device-list listener already covers most reconnections, but sleep/wake and transient Bluetooth dropouts don't always fire it. A generation counter ensures any in-flight retry from a previous failed setup is canceled when a new setup runs.Test plan
Tested locally on macOS 26.4 (Apple Silicon) with a CalDigit Thunderbolt 3 Dock with no USB serial number. Even though I only ever swapped between two physical USB-C ports, the dock's location ID came back as three distinct values across the testing session — further evidence that the UID can't be relied on as a stable handle for the same device:
xcodebuild -configuration Release.killall coreaudiod.Notes
🤖 Generated with Claude Code