[LG Optimus 3D] defcomg:
My bad i ment i don't have a hdmi cable anyway this is what i see

Headset Connection

07-27 06:53:21.945 V/HeadsetObserver(1813): Headset UEVENT: {SUBSYSTEM=switch, SWITCH_STATE=1, DEVPATH=/devices/virtual/switch/h2w, SEQNUM=2494, ACTION=change, SWITCH_NAME=h2w}
07-27 06:53:21.945 V/HeadsetObserver(1813): Intent.ACTION_HEADSET_PLUG: state: 1 name: h2w mic: 1
07-27 06:53:21.953 D/AudioPolicyService(15664): frameworks/base/services/audioflinger/AudioPolicyService.cpp:setDeviceConnectionState : device 00000004, state 1, dev addr
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): setDeviceConnectionState() device: 4, state 1, address
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): setDeviceConnectionState() connecting device 4
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getNewDevice() selected device 0
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() from cache strategy 1, device 1
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() strategy 1, device 4
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() from cache strategy 2, device 2
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() strategy 2, device 6
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() from cache strategy 0, device 2
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() strategy 0, device 4
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() from cache strategy 3, device 2
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() strategy 0, device 4
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() strategy 3, device 4
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() strategy 0, device 4
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() strategy 1, device 4
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() strategy 2, device 6
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() strategy 0, device 4
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): getDeviceForStrategy() strategy 3, device 4
07-27 06:53:21.953 V/AudioPolicyManagerBase(15664): setOutputDevice() output 1 device 0 delayMs 0

HDMI Connection

7-27 00:51:11.171 V/HDMIObserver(28860): HDMI UEVENT: {SUBSYSTEM=omapdss, DEVPATH=/devices/omapdss/display1, SEQNUM=10459, ACTION=add, DRIVER=hdmi_panel}
07-27 00:51:11.179 D/AudioPolicyService(28853): frameworks/base/services/audioflinger/AudioPolicyService.cpp:setDeviceConnectionState : device 00000400, state 1, dev addr
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): setDeviceConnectionState() device: 400, state 1, address
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): setDeviceConnectionState() connecting device 400
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getNewDevice() selected device 0
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() from cache strategy 1, device 8
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 1, device 8
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() from cache strategy 2, device a
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 2, device 402
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() from cache strategy 0, device 8
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 0, device 400
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() from cache strategy 3, device 8
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 0, device 400
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 3, device 400
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 0, device 400
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 1, device 8
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 2, device 402
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 0, device 400
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 3, device 400
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): setOutputDevice() output 1 device 0 delayMs 0
07-27 00:51:11.179 V/AudioPolicyManagerBase(28853): setOutputDevice() setting same device 0 or null device for output 1
07-27 00:51:11.179 I/LGHDMILib(28860): Enter start out

HDMI Disconnect

07-27 00:53:37.343 V/HDMIObserver(28860): HDMI UEVENT: {SUBSYSTEM=omapdss, DEVPATH=/devices/omapdss/display1, SEQNUM=10462, ACTION=remove, DRIVER=hdmi_panel}
07-27 00:53:37.343 D/AudioPolicyService(28853): frameworks/base/services/audioflinger/AudioPolicyService.cpp:setDeviceConnectionState : device 00000400, state 0, dev addr
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): setDeviceConnectionState() device: 400, state 0, address
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): setDeviceConnectionState() disconnecting device 400
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getNewDevice() selected device 0
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() from cache strategy 1, device 8
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 1, device 8
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() from cache strategy 2, device 402
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 2, device a
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() from cache strategy 0, device 400
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 0, device 8
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() from cache strategy 3, device 400
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 0, device 8
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 3, device 8
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 0, device 8
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 1, device 8
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 2, device a
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 0, device 8
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): getDeviceForStrategy() strategy 3, device 8
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): setOutputDevice() output 1 device 0 delayMs 0
07-27 00:53:37.343 V/AudioPolicyManagerBase(28853): setOutputDevice() setting same device 0 or null device for output 1
07-27 00:53:37.343 I/LGHDMILib(28860): Stop GFX Cloning

Headset = Device 4

HDMI = Device 400

What need does the audio routing

AudioPolicyManagerBase

AudioPolicyService

Found Some Moto LIB Source

AudioPolicyService.cpp

AudioPolicyManager.cpp

I think changing this line to 2 may allow HDMI Audio + Headset at the same time

// connect/disconnect only 1 device at a time

100

if (AudioSystem::popCount(device) != 1) return BAD_VALUE;

101

102

if (strlen(device_address) >= MAX_DEVICE_ADDRESS_LEN) {

103

LOGV("setDeviceConnectionState() invalid address: %s", device_address);

104

return BAD_VALUE;

105

}

.

In The Framework

AudioSystem.smali

[COLOR="Red"].field public static final DEVICE_OUT_AUX_DIGITAL:I = 0x400[/COLOR]

.field public static final DEVICE_OUT_BLUETOOTH_A2DP:I = 0x80

.field public static final DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES:I = 0x100

.field public static final DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER:I = 0x200

.field public static final DEVICE_OUT_BLUETOOTH_SCO:I = 0x10

.field public static final DEVICE_OUT_BLUETOOTH_SCO_CARKIT:I = 0x40

.field public static final DEVICE_OUT_BLUETOOTH_SCO_HEADSET:I = 0x20

.field public static final DEVICE_OUT_DEFAULT:I = 0x8000

.field public static final DEVICE_OUT_EARPIECE:I = 0x1

.field public static final DEVICE_OUT_FM_TRANSMIT:I = 0x800

.field public static final DEVICE_OUT_LOW_POWER:I = 0x1000

.field public static final DEVICE_OUT_SPEAKER:I = 0x2

.field public static final DEVICE_OUT_WIRED_HEADPHONE:I = 0x8

[COLOR="Red"].field public static final DEVICE_OUT_WIRED_HEADSET:I = 0x4[/COLOR]

.field public static final DEVICE_STATE_AVAILABLE:I = 0x1

.field public static final DEVICE_STATE_UNAVAILABLE:I = 0x0

AudioService.jar

} else if (SystemProperties.OMAP_ENHANCEMENT && action.equals(ACTION_HDMI_PLUG)) {

int state = intent.getIntExtra("state", 0);

boolean isConnected = mConnectedDevices.containsKey(AudioSystem.[COLOR="Red"]DEVICE_OUT_AUX_DIGITAL[/COLOR]);

if (state == 0 && isConnected) {

AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_AUX_DIGITAL,

AudioSystem.DEVICE_STATE_UNAVAILABLE,

"");

mConnectedDevices.remove(AudioSystem.DEVICE_OUT_AUX_DIGITAL);

} else if (state == 1 && !isConnected) {

AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_AUX_DIGITAL,

AudioSystem.DEVICE_STATE_AVAILABLE,

"");

} else {

boolean isConnected = mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE);

if (state == 0 && isConnected) {

AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE,

AudioSystem.DEVICE_STATE_UNAVAILABLE,

"");

mConnectedDevices.remove(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE);

} else if (state == 1 && !isConnected) {

AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE,

AudioSystem.DEVICE_STATE_AVAILABLE,

"");

mConnectedDevices.put( new Integer(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE), "");

}

}

I Don't know what rom You are using so framework may differ a little anyway Decomplile framework.jar goto smali/android/media/AudioService$AudioServiceBroadcastReceiver.smali search for 0x400 you will get 5 matches replace them with 0x4 save complile Make flashable zip and flash backup your rom first give it a try i can't confirm it works but it should tho. Basically its this

else if (SystemProperties.OMAP_ENHANCEMENT && action.equals(ACTION_HDMI_PLUG)) {

int state = intent.getIntExtra("state", 0);

boolean isConnected = mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE);

if (state == 0 && isConnected) {

AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE,

AudioSystem.DEVICE_STATE_UNAVAILABLE,

"");

mConnectedDevices.remove(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE);

} else if (state == 1 && !isConnected) {

AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE,

AudioSystem.DEVICE_STATE_AVAILABLE,

"");

mConnectedDevices.put( new Integer(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE), "");

}