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

Commit 58a73fc8 authored by Eric Laurent's avatar Eric Laurent Committed by Jakub Pawlowski
Browse files

Add Bluetooth Hearing Aid routing and configuration

Bug: 69623109
Test: connect to Hearing Aid, make phone call, verify audio is heard
Change-Id: I92267fb48608fb721c5c4ef7ec9fceeafc8ea192
parent 966c1587
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -33,7 +33,8 @@ DevicesFactoryHalHybrid::~DevicesFactoryHalHybrid() {
}

status_t DevicesFactoryHalHybrid::openDevice(const char *name, sp<DeviceHalInterface> *device) {
    if (mHidlFactory != 0 && strcmp(AUDIO_HARDWARE_MODULE_ID_A2DP, name) != 0) {
    if (mHidlFactory != 0 && strcmp(AUDIO_HARDWARE_MODULE_ID_A2DP, name) != 0 &&
        strcmp(AUDIO_HARDWARE_MODULE_ID_HEARING_AID, name) != 0) {
        return mHidlFactory->openDevice(name, device);
    }
    return mLocalFactory->openDevice(name, device);
+1 −0
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ public:
        case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP:
        case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES:
        case AUDIO_DEVICE_OUT_USB_HEADSET:
        case AUDIO_DEVICE_OUT_HEARING_AID:
            return DEVICE_CATEGORY_HEADSET;
        case AUDIO_DEVICE_OUT_LINE:
        case AUDIO_DEVICE_OUT_AUX_DIGITAL:
+3 −0
Original line number Diff line number Diff line
@@ -182,6 +182,9 @@
        <!-- Remote Submix Audio HAL -->
        <xi:include href="r_submix_audio_policy_configuration.xml"/>

        <!-- Hearing aid Audio HAL -->
        <xi:include href="hearing_aid_audio_policy_configuration.xml"/>

    </modules>
    <!-- End of Modules section -->

+17 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!-- Hearing aid Audio HAL Audio Policy Configuration file -->
<module name="hearing_aid" halVersion="2.0">
    <mixPorts>
        <mixPort name="hearing aid output" role="source" flags="AUDIO_OUTPUT_FLAG_PRIMARY">
            <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                     samplingRates="24000,16000"
                     channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
        </mixPort>
    </mixPorts>
    <devicePorts>
        <devicePort tagName="BT Hearing Aid Out" type="AUDIO_DEVICE_OUT_HEARING_AID" role="sink"/>
    </devicePorts>
    <routes>
        <route type="mix" sink="BT Hearing Aid Out" sources="hearing aid output"/>
    </routes>
</module>
+12 −1
Original line number Diff line number Diff line
@@ -306,8 +306,14 @@ audio_devices_t Engine::getDeviceForStrategyInt(routing_strategy strategy,
            sp<AudioOutputDescriptor> primaryOutput = outputs.getPrimaryOutput();
            audio_devices_t availPrimaryInputDevices =
                 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
            // a primary device
            // FIXME: this is not the right way of solving this problem
            audio_devices_t availPrimaryOutputDevices =
                    primaryOutput->supportedDevices() & availableOutputDevices.types();
                (primaryOutput->supportedDevices() | AUDIO_DEVICE_OUT_HEARING_AID) &
                availableOutputDevices.types();

            if (((availableInputDevices.types() &
                    AUDIO_DEVICE_IN_TELEPHONY_RX & ~AUDIO_DEVICE_BIT_IN) == 0) ||
@@ -332,6 +338,8 @@ audio_devices_t Engine::getDeviceForStrategyInt(routing_strategy strategy,
            // FALL THROUGH

        default:    // FORCE_NONE
            device = availableOutputDevicesType & AUDIO_DEVICE_OUT_HEARING_AID;
            if (device) break;
            // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to A2DP
            if (!isInCall() &&
                    (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] != AUDIO_POLICY_FORCE_NO_BT_A2DP) &&
@@ -481,6 +489,9 @@ audio_devices_t Engine::getDeviceForStrategyInt(routing_strategy strategy,
                    outputDeviceTypesToIgnore);
            break;
        }
        if (device2 == AUDIO_DEVICE_NONE) {
            device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_HEARING_AID;
        }
        if ((device2 == AUDIO_DEVICE_NONE) &&
                (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] != AUDIO_POLICY_FORCE_NO_BT_A2DP) &&
                (outputs.getA2dpOutput() != 0)) {