Skip to content

Reconnect stalled proxy audio output after device engine restarts - #79

Open
sergiou87 wants to merge 1 commit into
briankendall:masterfrom
sergiou87:fix-proxy-audio-wake-recovery
Open

sergiou87 wants to merge 1 commit into
briankendall:masterfrom
sergiou87:fix-proxy-audio-wake-recovery

Conversation

@sergiou87

@sergiou87 sergiou87 commented Oct 26, 2026 •

Copy link
Copy Markdown

Problem

After waking the display, proxy audio can remain silent until macOS output is switched to another device and back. In one captured failure, Core Audio stopped and restarted the my BenQ's DisplayPort audio engine at display wake, while the proxy remained selected, unmuted, and at the same 48 kHz sample rate. A direct test tone through the BenQ monitor worked, but proxy playback stayed silent.

The exact internal cause was not proven in that running Release build. One recovery gap is that the target's cached started state can remain true across engine restarts, and unchanged device ID/buffer size causes setup to skip rebuilding the connection. Existing timeline recovery cannot help when output callbacks stop arriving.

Changes

  • Track input and output callback progress with atomic counters.
  • Rebuild the target output connection on the control queue when input remains active but output callbacks have stalled for at least two seconds.
  • Reset buffered timing during reconnect and log each recovery attempt.
  • Rate-limit reconnect attempts to once every ten seconds; avoid reconnecting idle, unavailable, or unready devices, and leave functioning output callbacks alone.
  • Remove target property listeners during teardown so repeated reconnects do not accumulate registrations.
  • Add standalone watchdog/heartbeat regression tests and document recovery behavior.

Validation

  • bash tests/run-audio-wake-tests.sh
  • Universal arm64/x86_64 Release driver and settings app build with Xcode 27, using a command-line MACOSX_DEPLOYMENT_TARGET=12.0 override because this Xcode no longer supports the project's 10.11 target. Repository deployment settings are unchanged.
  • I have been running a local build containing this fix and the separate sustained-delay fix for approximately one week. Neither wake-related silence nor excessive delay has recurred during that time. This is combined-build field testing, not an isolated comparison of the two fixes.

Independent of #78: this branch targets master and contains only wake recovery. The driver patch is unchanged from the tested combined build; tests and documentation were separated to remove the dependency on the delay fix.

Track input and output callback progress with atomic counters. When input remains active but output callbacks stop for two seconds, rebuild the target IO connection on the control queue and reset buffered timing. Limit reconnect attempts to once every ten seconds and log each attempt.

Remove target property listeners during teardown to avoid accumulating registrations across reconnects. Add standalone wake-recovery regression tests so this fix can be reviewed and merged independently of sustained-delay recovery.

Copilot-Session: b78a5bb5-6ba7-4a0a-86ac-d87fb6433026
@sergiou87
sergiou87 marked this pull request as ready for review October 26, 2026 13:27
@briankendall

Copy link
Copy Markdown
Owner

This seems like a decent approach for restarting the driver when it stalls. There's a few changes I think this needs before I can accept it.

  1. The timer that calls monitorUserActivity is a good place to perform this check, but that function is misnamed after this change, so please rename it to monitorDeviceStatus (or something else if you can think of a better name!)
  2. Granted proxy-audio-device doesn't currently have any tests so there's no established method for performing them, but since it's intended to be a single Xcode project that can be compiled normally using Xcode, the tests should be integrated into that project rather than compiled individually using a shell script

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