feat(helper): replace AudioObject IPC with XPC helper service#4
Merged
feat(helper): replace AudioObject IPC with XPC helper service#4
Conversation
Also adds VS Code launch configurations for AppFadersHelper debug/release.
Add four new error cases for XPC communication failures: - helperNotRunning: helper service not available - connectionFailed: XPC connection establishment failed - connectionInterrupted: XPC connection was interrupted - remoteError: helper returned an error
Duplicate AppFadersHostProtocol in host target for NSXPCInterface. Must match helper's definition exactly for XPC to work.
Replace AudioObject property IPC with XPC communication to helper service. - connect() now async, connects to mach service (no deviceID param) - setAppVolume/getAppVolume now async throws - Uses withCheckedThrowingContinuation for XPC reply handling - Handles connection invalidation and interruption - Removes all CoreAudio/AudioObject code
Adapt orchestrator to async XPC-based DriverBridge: - getVolume now async throws - setVolume now async with internal error handling - restoreVolumes and handleAppEvent now async - connect() no longer takes deviceID parameter
Add helper installation before driver: - Build helper with swift build - Create /Library/Application Support/AppFaders/ - Copy helper binary with proper permissions - Install LaunchAgent plist to /Library/LaunchAgents/ - Load LaunchAgent with launchctl
Add helper cleanup after driver removal: - Unload LaunchAgent with launchctl - Remove LaunchAgent plist from /Library/LaunchAgents/ - Remove helper binary from support directory - Remove support directory if empty - Handle missing files gracefully
- Convert all tests to async - Remove CoreAudio import and connect(deviceID:) calls - Update #expect blocks to use await - Rename deviceNotFound test to helperNotRunning - Delete orphaned VolumeStoreTests (VolumeStore moved to helper)
Manual test procedure for verifying XPC communication: - Install/uninstall steps - Log stream commands for driver and helper - Volume set/get verification - Driver cache verification - Troubleshooting section - Success criteria checklist
Driver was failing to load because: 1. Helper was a LaunchAgent (user session) but driver runs in system context (Core-Audio-Driver-Service.helper) 2. XPC calls during driver init blocked for 30s causing timeout Changes: - Switch helper from LaunchAgent to LaunchDaemon - Use launchctl bootstrap/bootout for system domain - Defer initial cache refresh to background queue
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.
Context
The original IPC approach using custom AudioObject properties failed because coreaudiod blocks custom property writes before they reach the driver. Solution follows the BackgroundMusic pattern (BGMXPCHelper) and Apple QA1811: a separate helper process that both host app and driver connect to via XPC.
Key discoveries during implementation:
Core-Audio-Driver-Service.helper)Changes Made
New Target: AppFadersHelper
Host App
Driver
AudioServerPlugIn_MachServicesto Info.plistScripts
Testing Notes
Integration test verified (
Docs/xpc-integration-test.md):All 30 unit tests pass.