Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 839e4f33 authored by Jungshik Jang's avatar Jungshik Jang
Browse files

Add force usage and category for System Audio Control.

System Audio Control in HDMI-CEC delegate audio control
to audio receiver. When system audio control is selected
in audio settings as audio output it should select one of ARC, SPDIF,
and LINE as audio output.
Whenever user select System Audio as audio output, audio
setting should call
setForceUse(AUDIO_POLICY_FORCE_FOR_SYSTEM_AUDIO, AUDIO_POLICY_FORCE_XXX);
and if other output is selected it should call
setForceUse(AUDIO_POLICY_FORCE_FOR_SYSTEM_AUDIO, AUDIO_POLICY_FORCE_NONE);

Change-Id: I1c237ee9291a4e0acf01a86aff3176edce5c14e0
parent 8d0bc4a8
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -516,7 +516,10 @@ void AudioPolicyManager::setForceUse(audio_policy_force_use_t usage,
            config != AUDIO_POLICY_FORCE_WIRED_ACCESSORY &&
            config != AUDIO_POLICY_FORCE_ANALOG_DOCK &&
            config != AUDIO_POLICY_FORCE_DIGITAL_DOCK && config != AUDIO_POLICY_FORCE_NONE &&
            config != AUDIO_POLICY_FORCE_NO_BT_A2DP) {
            config != AUDIO_POLICY_FORCE_NO_BT_A2DP &&
            config != AUDIO_POLICY_FORCE_SYSTEM_AUDIO_HDMI_ARC &&
            config != AUDIO_POLICY_FORCE_SYSTEM_AUDIO_SPDIF &&
            config != AUDIO_POLICY_FORCE_SYSTEM_AUDIO_LINE) {
            ALOGW("setForceUse() invalid config %d for FOR_MEDIA", config);
            return;
        }
@@ -3536,10 +3539,32 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
        if (device2 == AUDIO_DEVICE_NONE) {
            device2 = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_SPEAKER;
        }

        int device3 = AUDIO_DEVICE_NONE;
        if (strategy == STRATEGY_MEDIA) {
            // Hdmi system audio should use manually configured device type.
            if (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA]
                    == AUDIO_POLICY_FORCE_SYSTEM_AUDIO_HDMI_ARC) {
                device3 = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_HDMI_ARC;
            } else if (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA]
                    == AUDIO_POLICY_FORCE_SYSTEM_AUDIO_SPDIF) {
                device3 = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_SPDIF;
            } else if (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA]
                    == AUDIO_POLICY_FORCE_SYSTEM_AUDIO_LINE) {
                device3 = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_LINE;
            }
        }

        // Merge hdmi cec system audio and existing device for media. If system audio is on,
        // internal speaker will be muted but others are not.
        device2 |= device3;
        // device is DEVICE_OUT_SPEAKER if we come from case STRATEGY_SONIFICATION or
        // STRATEGY_ENFORCED_AUDIBLE, AUDIO_DEVICE_NONE otherwise
        device |= device2;

        // If system audio mode is on and proper audio out is set, remove speaker from device.
        if (device3 != AUDIO_DEVICE_NONE) {
             device &= ~AUDIO_DEVICE_OUT_SPEAKER;
        }
        if (device) break;
        device = mDefaultOutputDevice->mDeviceType;
        if (device == AUDIO_DEVICE_NONE) {