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

Commit ee00824d authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "hal: check if separate backend is used for voice headset"

parents f612905f 0d001b78
Loading
Loading
Loading
Loading
+37 −2
Original line number Original line Diff line number Diff line
@@ -4298,6 +4298,40 @@ bool platform_check_backends_match(snd_device_t snd_device1, snd_device_t snd_de
    return result;
    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 platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
{
{
    int device_id = -1;
    int device_id = -1;
@@ -6208,8 +6242,9 @@ snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *o
                    snd_device = SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET;
                    snd_device = SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET;
                else
                else
                    snd_device = SND_DEVICE_OUT_VOICE_ANC_HEADSET;
                    snd_device = SND_DEVICE_OUT_VOICE_ANC_HEADSET;
            } else if (audio_extn_is_concurrent_capture_enabled() &&
            } else if (!platform_check_all_backends_match(SND_DEVICE_IN_VOICE_HEADSET_MIC,
                        compare_device_type(&devices, AUDIO_DEVICE_OUT_WIRED_HEADSET)) {
                       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
                //Separate backend is added for headset-mic as part of concurrent capture
                snd_device = SND_DEVICE_OUT_VOICE_HEADSET;
                snd_device = SND_DEVICE_OUT_VOICE_HEADSET;
            } else {
            } else {