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

Commit 5560a6a5 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "Audio Policy Engine: remove fatal logs" into main

parents 46a93fa3 5569bf4c
Loading
Loading
Loading
Loading
+39 −30
Original line number Diff line number Diff line
@@ -175,16 +175,17 @@ void Engine::filterOutputDevicesForStrategy(legacy_strategy strategy,
        //   - cannot route from voice call RX OR
        //   - audio HAL version is < 3.0 and TX device is on the primary HW module
        if (getPhoneState() == AUDIO_MODE_IN_CALL) {
            sp<AudioOutputDescriptor> primaryOutput = outputs.getPrimaryOutput();
            if (primaryOutput != nullptr) {
                audio_devices_t txDevice = AUDIO_DEVICE_NONE;
                sp<DeviceDescriptor> txDeviceDesc =
                        getDeviceForInputSource(AUDIO_SOURCE_VOICE_COMMUNICATION);
                if (txDeviceDesc != nullptr) {
                    txDevice = txDeviceDesc->type();
                }
            sp<AudioOutputDescriptor> primaryOutput = outputs.getPrimaryOutput();
            LOG_ALWAYS_FATAL_IF(primaryOutput == nullptr, "Primary output not found");
                DeviceVector availPrimaryInputDevices =
                    availableInputDevices.getDevicesFromHwModule(primaryOutput->getModuleHandle());
                        availableInputDevices.getDevicesFromHwModule(
                            primaryOutput->getModuleHandle());

                // TODO: getPrimaryOutput return only devices from first module in
                // audio_policy_configuration.xml, hearing aid is not there, but it's
@@ -196,13 +197,15 @@ void Engine::filterOutputDevicesForStrategy(legacy_strategy strategy,
                        availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_HEARING_AID));

                if ((availableInputDevices.getDevice(AUDIO_DEVICE_IN_TELEPHONY_RX,
                                                 String8(""), AUDIO_FORMAT_DEFAULT) == nullptr) ||
                ((availPrimaryInputDevices.getDevice(
                                                     String8(""), AUDIO_FORMAT_DEFAULT) == nullptr)
                    || ((availPrimaryInputDevices.getDevice(
                            txDevice, String8(""), AUDIO_FORMAT_DEFAULT) != nullptr) &&
                     (primaryOutput->getPolicyAudioPort()->getModuleVersionMajor() < 3))) {
                    availableOutputDevices = availPrimaryOutputDevices;
                }

            } else {
                ALOGE("%s, STRATEGY_PHONE: Primary output not found", __func__);
            }
        }
        // Do not use A2DP devices when in call but use them when not in call
        // (e.g for voice mail playback)
@@ -595,8 +598,11 @@ sp<DeviceDescriptor> Engine::getDeviceForInputSource(audio_source_t inputSource)
        if ((getPhoneState() == AUDIO_MODE_IN_CALL) &&
                (availableOutputDevices.getDevice(AUDIO_DEVICE_OUT_TELEPHONY_TX,
                        String8(""), AUDIO_FORMAT_DEFAULT)) == nullptr) {
            LOG_ALWAYS_FATAL_IF(availablePrimaryDevices.isEmpty(), "Primary devices not found");
            if (!availablePrimaryDevices.isEmpty()) {
                availableDevices = availablePrimaryDevices;
            } else {
                ALOGE("%s, AUDIO_SOURCE_VOICE_COMMUNICATION: Primary devices not found", __func__);
            }
        }

        if (audio_is_bluetooth_out_sco_device(commDeviceType)) {
@@ -650,8 +656,11 @@ sp<DeviceDescriptor> Engine::getDeviceForInputSource(audio_source_t inputSource)
    case AUDIO_SOURCE_HOTWORD:
        // We should not use primary output criteria for Hotword but rather limit
        // to devices attached to the same HW module as the build in mic
        LOG_ALWAYS_FATAL_IF(availablePrimaryDevices.isEmpty(), "Primary devices not found");
        if (!availablePrimaryDevices.isEmpty()) {
            availableDevices = availablePrimaryDevices;
        } else {
            ALOGE("%s, AUDIO_SOURCE_HOTWORD: Primary devices not found", __func__);
        }
        if (audio_is_bluetooth_out_sco_device(commDeviceType)) {
            device = availableDevices.getDevice(
                    AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, String8(""), AUDIO_FORMAT_DEFAULT);