接HDMI同时输出喇叭spker声音
OS:Android13
背景:设备接HDMI,声音通道会优先从HDMI输出,喇叭是是没有声音的
修改如下:
1.
frameworks/base diff --git a/services/core/java/com/android/server/WiredAccessoryManager.java b/services/core/java/com/android/server/WiredAccessoryManager.java index 6162ad36009c..c71254e755b2 100644 --- a/services/core/java/com/android/server/WiredAccessoryManager.java +++ b/services/core/java/com/android/server/WiredAccessoryManager.java @@ -565,8 +565,8 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { updateBit(maskAndState, BIT_LINEOUT, status, ExtconInfo.EXTCON_LINE_OUT); } - updateBit(maskAndState, BIT_HDMI_AUDIO, status, "hdmi0"); - updateBit(maskAndState, BIT_HDMI_AUDIO_1, status, "hdmi1"); + // updateBit(maskAndState, BIT_HDMI_AUDIO, status, "hdmi0"); + // updateBit(maskAndState, BIT_HDMI_AUDIO_1, status, "hdmi1"); updateBit(maskAndState, BIT_DP_AUDIO, status, "dp0"); updateBit(maskAndState, BIT_DP_AUDIO_1, status, "dp1"); updateBit(maskAndState, BIT_HDMIIN_AUDIO, status, "hdmirx0");
2.
frameworks/av diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp index 9626483fd4..f28ca9a1ac 100644 --- a/services/audiopolicy/enginedefault/src/Engine.cpp +++ b/services/audiopolicy/enginedefault/src/Engine.cpp @@ -393,20 +393,20 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy, getLastRemovableMediaDevices(GROUP_WIRED)); } } - if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { - // no sonification on aux digital (e.g. HDMI) - devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_AUX_DIGITAL); - } - //priority Wired > a2dp > hdmi > hdmi 1 > spdif > spdif 1 - if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { - devices2 = availableOutputDevices.getDevicesFromType(VX_ROCKCHIP_OUT_HDMI0); - } - if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { - devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_SPDIF); - } - if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { - devices2 = availableOutputDevices.getDevicesFromType(VX_ROCKCHIP_OUT_SPDIF0); - } + // if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { + // // no sonification on aux digital (e.g. HDMI) + // devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_AUX_DIGITAL); + // } + // // priority Wired > a2dp > hdmi > hdmi 1 > spdif > spdif 1 + // if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { + // devices2 = availableOutputDevices.getDevicesFromType(VX_ROCKCHIP_OUT_HDMI0); + // } + // if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { + // devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_SPDIF); + // } + // if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { + // devices2 = availableOutputDevices.getDevicesFromType(VX_ROCKCHIP_OUT_SPDIF0); + // } if ((devices2.isEmpty()) && (getForceUse(AUDIO_POLICY_FORCE_FOR_DOCK) == AUDIO_POLICY_FORCE_ANALOG_DOCK)) { devices2 = availableOutputDevices.getDevicesFromType( @@ -419,9 +419,10 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy, DeviceVector devices3; if (strategy == STRATEGY_MEDIA) { // ARC and AUX_LINE can co-exist with others. - devices3 = availableOutputDevices.getDevicesFromTypes({ - AUDIO_DEVICE_OUT_HDMI_ARC, AUDIO_DEVICE_OUT_HDMI_EARC, - AUDIO_DEVICE_OUT_AUX_LINE, }); + // devices3 = availableOutputDevices.getDevicesFromTypes({ + // AUDIO_DEVICE_OUT_HDMI_ARC, AUDIO_DEVICE_OUT_HDMI_EARC, + // AUDIO_DEVICE_OUT_AUX_LINE, }); + devices3 = availableOutputDevices.getDevicesFromTypes({ AUDIO_DEVICE_OUT_AUX_DIGITAL}); } devices2.add(devices3); @@ -430,11 +431,11 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy, devices.add(devices2); // If hdmi system audio mode is on, remove speaker out of output list. - if ((strategy == STRATEGY_MEDIA) && - (getForceUse(AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO) == - AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED)) { - devices.remove(devices.getDevicesFromType(AUDIO_DEVICE_OUT_SPEAKER)); - } + // if ((strategy == STRATEGY_MEDIA) && + // (getForceUse(AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO) == + // AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED)) { + // devices.remove(devices.getDevicesFromType(AUDIO_DEVICE_OUT_SPEAKER)); + // } bool mediaActiveLocally = outputs.isActiveLocally(toVolumeSource(AUDIO_STREAM_MUSIC),