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

Commit 0d001b78 authored by Samyak Jain's avatar Samyak Jain
Browse files

hal: check if separate backend is used for voice headset

If concurrent capture is disabled, we select voice headphones irrespective
of whether separate backend is used for voice headset or not

Add check all backends match API to support both capture and playback
devices, and use it to check if separate backend is added for
headset-mic and select the device accordingly.

Change-Id: I405b52fbf14ca800bd188a62ba83bf82aa61ea1f
parent 20c978ad
Loading
Loading
Loading
Loading
+37 −2
Original line number Diff line number Diff line
@@ -4303,6 +4303,40 @@ bool platform_check_backends_match(snd_device_t snd_device1, snd_device_t snd_de
    return result;
}

bool platform_check_all_backends_match(snd_device_t snd_device1, snd_device_t snd_device2)
{
    bool result = true;

    if ((snd_device1 < SND_DEVICE_MIN) || (snd_device1 >= SND_DEVICE_MAX)) {
        ALOGE("%s: Invalid snd_device = %s", __func__,
                platform_get_snd_device_name(snd_device1));
        return false;
    }

    if ((snd_device2 < SND_DEVICE_MIN) || (snd_device2 >= SND_DEVICE_MAX)) {
        ALOGE("%s: Invalid snd_device = %s", __func__,
                platform_get_snd_device_name(snd_device2));
        return false;
    }

    const char * be_itf1 = hw_interface_table[snd_device1];
    const char * be_itf2 = hw_interface_table[snd_device2];

    if (snd_device1 < SND_DEVICE_OUT_END && snd_device2 < SND_DEVICE_OUT_END) {
        return platform_check_backends_match(snd_device1, snd_device2);
    } else if (snd_device1 >= SND_DEVICE_IN_BEGIN && snd_device2 >= SND_DEVICE_IN_BEGIN) {
        if (NULL != be_itf1 && NULL != be_itf2) {
            if (strcmp(be_itf2, be_itf1))
                result = false;
        }
    } else {
        result = false;
    }

    ALOGV("%s: be_itf1 = %s, be_itf2 = %s, match %d", __func__, be_itf1, be_itf2, result);
    return result;
}

int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
{
    int device_id = -1;
@@ -6213,8 +6247,9 @@ snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *o
                    snd_device = SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET;
                else
                    snd_device = SND_DEVICE_OUT_VOICE_ANC_HEADSET;
            } else if (audio_extn_is_concurrent_capture_enabled() &&
                        compare_device_type(&devices, AUDIO_DEVICE_OUT_WIRED_HEADSET)) {
            } else if (!platform_check_all_backends_match(SND_DEVICE_IN_VOICE_HEADSET_MIC,
                       SND_DEVICE_IN_SPEAKER_MIC) && compare_device_type(&devices,
                       AUDIO_DEVICE_OUT_WIRED_HEADSET)) {
                //Separate backend is added for headset-mic as part of concurrent capture
                snd_device = SND_DEVICE_OUT_VOICE_HEADSET;
            } else {