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

Commit 4264d010 authored by vivek mehta's avatar vivek mehta Committed by android-build-merger
Browse files

msm8916: hal: optimize worst case soundcard detection time am: d135c317

am: a2abf112

Change-Id: I1981e5d26bdadf15d8ff68dff33047467ecb8ee8
parents c25092d4 a2abf112
Loading
Loading
Loading
Loading
+31 −16
Original line number Diff line number Diff line
@@ -842,24 +842,39 @@ void *platform_init(struct audio_device *adev)
    }

    list_init(&operator_info_list);
    bool card_verifed[MAX_SND_CARD] = {0};
    const int retry_limit = property_get_int32("audio.snd_card.open.retries", RETRY_NUMBER);

    while (snd_card_num < MAX_SND_CARD) {
        adev->mixer = mixer_open(snd_card_num);
    for (;;) {
        if (snd_card_num >= MAX_SND_CARD) {
            if (retry_num++ >= retry_limit) {
                ALOGE("%s: Unable to find correct sound card, aborting.", __func__);
                free(my_data);
                my_data = NULL;
                return NULL;
            }

        while (!adev->mixer && retry_num < RETRY_NUMBER) {
            snd_card_num = 0;
            usleep(RETRY_US);
            adev->mixer = mixer_open(snd_card_num);
            retry_num++;
            continue;
        }

        if (card_verifed[snd_card_num]) {
            ++snd_card_num;
            continue;
        }

        adev->mixer = mixer_open(snd_card_num);

        if (!adev->mixer) {
            ALOGE("%s: Unable to open the mixer card: %d", __func__,
               snd_card_num);
            retry_num = 0;
            snd_card_num++;
            ++snd_card_num;
            continue;
        }

        card_verifed[snd_card_num] = true;

        snd_card_name = mixer_get_name(adev->mixer);
        ALOGV("%s: snd_card_name: %s", __func__, snd_card_name);

@@ -875,21 +890,21 @@ void *platform_init(struct audio_device *adev)
            if (!adev->audio_route) {
                ALOGE("%s: Failed to init audio route controls, aborting.",
                       __func__);
                hw_info_deinit(my_data->hw_info);
                my_data->hw_info = NULL;
                free(my_data);
                my_data = NULL;
                mixer_close(adev->mixer);
                adev->mixer = NULL;
                return NULL;
            }
            adev->snd_card = snd_card_num;
            ALOGD("%s: Opened sound card:%d", __func__, snd_card_num);
            break;
        }
        retry_num = 0;
        snd_card_num++;
    }

    if (snd_card_num >= MAX_SND_CARD) {
        ALOGE("%s: Unable to find correct sound card, aborting.", __func__);
        free(my_data);
        return NULL;
        ++snd_card_num;
        mixer_close(adev->mixer);
        adev->mixer = NULL;
    }

    //set max volume step for voice call