Revisit HDMI-CEC system audio mode in AudioService.
From recent feedback on HDMI-CEC system audio mode,
it would be unnecessary to enforce output from AudioService.
Instead, it would follow audio policy according to status
of HDMI-CEC system audio mode.
For that removed two params of setHdmiSystemAudioModeSupported
api of AudioManager.
In terms of speaker mute, it will be handled by removing speaker
from audio ouput instead of changing gain control. For that
added new force usage type, FOR_HDMI_SYSTEM_AUDIO_MODE and
new force config type, FORCE_HDMI_SYSTEM_AUDIO_ENFORCED.
This is used to notify change of system audio mode to
audio policy manager.
Bug: 16305986
Bug: 16002150
Change-Id: I702e0f9ce7c7887d5f5dd02b06a40d20e4c950df
diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp
index 1b4796b..f2320de 100644
--- a/services/audiopolicy/AudioPolicyManager.cpp
+++ b/services/audiopolicy/AudioPolicyManager.cpp
@@ -560,6 +560,13 @@
forceVolumeReeval = true;
mForceUse[usage] = config;
break;
+ case AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO:
+ if (config != AUDIO_POLICY_FORCE_NONE &&
+ config != AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED) {
+ ALOGW("setForceUse() invalid config %d forHDMI_SYSTEM_AUDIO", config);
+ }
+ mForceUse[usage] = config;
+ break;
default:
ALOGW("setForceUse() invalid usage %d", usage);
break;
@@ -1529,6 +1536,9 @@
result.append(buffer);
snprintf(buffer, SIZE, " Force use for system %d\n", mForceUse[AUDIO_POLICY_FORCE_FOR_SYSTEM]);
result.append(buffer);
+ snprintf(buffer, SIZE, " Force use for hdmi system audio %d\n",
+ mForceUse[AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO]);
+ result.append(buffer);
snprintf(buffer, SIZE, " Available output devices:\n");
result.append(buffer);
@@ -3554,10 +3564,10 @@
}
int device3 = AUDIO_DEVICE_NONE;
if (strategy == STRATEGY_MEDIA) {
- // ARC, SPDIF and LINE can co-exist with others.
+ // ARC, SPDIF and AUX_LINE can co-exist with others.
device3 = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_HDMI_ARC;
device3 |= (availableOutputDeviceTypes & AUDIO_DEVICE_OUT_SPDIF);
- device3 |= (availableOutputDeviceTypes & AUDIO_DEVICE_OUT_LINE);
+ device3 |= (availableOutputDeviceTypes & AUDIO_DEVICE_OUT_AUX_LINE);
}
device2 |= device3;
@@ -3565,6 +3575,13 @@
// STRATEGY_ENFORCED_AUDIBLE, AUDIO_DEVICE_NONE otherwise
device |= device2;
+ // If hdmi system audio mode is on, remove speaker out of output list.
+ if ((strategy == STRATEGY_MEDIA) &&
+ (mForceUse[AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO] ==
+ AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED)) {
+ device &= ~AUDIO_DEVICE_OUT_SPEAKER;
+ }
+
if (device) break;
device = mDefaultOutputDevice->mDeviceType;
if (device == AUDIO_DEVICE_NONE) {