Fix HP_OUT in standalone association selected as default output when disconnected#16
Merged
SergeySlice merged 1 commit intoCloverHackyColor:mainfrom Mar 19, 2026
Merged
Conversation
On codecs where the headphone pin lives in its own association (hpredir=-1, e.g. ALC897 on Gigabyte Z390 AORUS MASTER), switchHandler previously skipped it entirely, leaving HPHN_ENABLE set in the pin control register regardless of whether headphones are physically present. macOS interprets HPHN_ENABLE as "headphones connected" and selects that PCM device as the default output on every reboot. Add a second loop in switchHandler that processes HP_OUT pins in standalone associations: reads presence detection, clears HPHN_ENABLE when no headphones are inserted, and calls hpSwitchHandler to mute/unmute other output associations (e.g. external speakers) accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
On codecs where the headphone pin is in its own association (
hpredir=-1, e.g. ALC897 on Gigabyte Z390 AORUS MASTER),switchHandlerpreviously skipped it entirely. This leftHPHN_ENABLEset in the pin control register regardless of whether headphones are physically present. macOS interpretsHPHN_ENABLEas "headphones connected" and selects that PCM device as the default output on every reboot — even when no headphones are plugged in.Root cause (from user dump analysis)
0x10ec0897)as=7,hpredir=-1— standalone association, skipped by existingswitchHandlerloopas=1, separate associationpin ctrl = 0xC0(HPHN_ENABLE | OUT_ENABLE) unconditionally → macOS selects Headphones as default outputFix
Add a second loop in
switchHandlerthat processesHP_OUTpins in standalone associations (hpredir < 0):HPHN_ENABLEwhen no headphones are inserted → macOS does not see headphones and keeps External Speaker as defaultHPHN_ENABLEwhen headphones are present, and callshpSwitchHandlerto mute/unmute other output associations (e.g. external speakers)trancandbranches/zdevTest plan
🤖 Generated with Claude Code