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

Commit e93ae281 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

Fix mic address augmenting in APM

Apply the microphone addresses augmenting to all input devices.
This ensures that correct microphone device address is passed
to the HAL during input availability check.

Bug: 205884982
Test: adb shell dumpsys media.audio_policy (for AIDL HAL)
Change-Id: I2159d09e2adf8137107947b80f9b040eba0a3a3a
parent 6fa1c89b
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -5614,6 +5614,17 @@ status_t AudioPolicyManager::initialize() {
        return status;
    }

    // If microphones address is empty, set it according to device type
    for (size_t i = 0; i < mInputDevicesAll.size(); i++) {
        if (mInputDevicesAll[i]->address().empty()) {
            if (mInputDevicesAll[i]->type() == AUDIO_DEVICE_IN_BUILTIN_MIC) {
                mInputDevicesAll[i]->setAddress(AUDIO_BOTTOM_MICROPHONE_ADDRESS);
            } else if (mInputDevicesAll[i]->type() == AUDIO_DEVICE_IN_BACK_MIC) {
                mInputDevicesAll[i]->setAddress(AUDIO_BACK_MICROPHONE_ADDRESS);
            }
        }
    }

    mEngine->updateDeviceSelectionCache();
    mCommunnicationStrategy = mEngine->getProductStrategyForAttributes(
        mEngine->getAttributesForStreamType(AUDIO_STREAM_VOICE_CALL));
@@ -5628,17 +5639,6 @@ status_t AudioPolicyManager::initialize() {
                 mDefaultOutputDevice->toString().c_str());
        status = NO_INIT;
    }
    // If microphones address is empty, set it according to device type
    for (size_t i = 0; i < mAvailableInputDevices.size(); i++) {
        if (mAvailableInputDevices[i]->address().empty()) {
            if (mAvailableInputDevices[i]->type() == AUDIO_DEVICE_IN_BUILTIN_MIC) {
                mAvailableInputDevices[i]->setAddress(AUDIO_BOTTOM_MICROPHONE_ADDRESS);
            } else if (mAvailableInputDevices[i]->type() == AUDIO_DEVICE_IN_BACK_MIC) {
                mAvailableInputDevices[i]->setAddress(AUDIO_BACK_MICROPHONE_ADDRESS);
            }
        }
    }

    ALOGW_IF(mPrimaryOutput == nullptr, "The policy configuration does not declare a primary output");

    // Silence ALOGV statements