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

Commit 07a9ea23 authored by Shiv Maliyappanahalli's avatar Shiv Maliyappanahalli Committed by Gerrit - the friendly Code Review server
Browse files

hal: fix no audio in qchat call with speaker as default device

HAL doesnt let voice calls start if the device is set to speaker
as voice calls generally start on devices other than speaker.
However QCHAT calls start by calling setForceUse and setting the
device to speaker.

Fix by updating a flag whenever device routing happens when
AUDIO_MODE_IN_CALL. Reset the flag when mode is AUDIO_MODE_NORMAL.

CRs-fixed: 596074
Change-Id: I546959d2b0123828562dba1f6439aa494a365c3f
parent 7cb06b30
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -424,6 +424,7 @@ void voice_init(struct audio_device *adev)
    adev->voice.tty_mode = TTY_MODE_OFF;
    adev->voice.volume = 1.0f;
    adev->voice.mic_mute = false;
    adev->voice.voice_device_set = false;
    for (i = 0; i < MAX_VOICE_SESSIONS; i++) {
        adev->voice.session[i].pcm_rx = NULL;
        adev->voice.session[i].pcm_tx = NULL;
+2 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
 * Not a contribution.
 *
 * Copyright (C) 2013 The Android Open Source Project
@@ -60,6 +60,7 @@ struct voice {
    int tty_mode;
    bool mic_mute;
    float volume;
    bool voice_device_set;
};

enum {
+21 −4
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ static int update_calls(struct audio_device *adev)
    struct voice_session *session = NULL;
    int fd = 0;
    int ret = 0;
    bool is_in_call = false;

    ALOGD("%s: enter:", __func__);

@@ -202,6 +203,10 @@ static int update_calls(struct audio_device *adev)
                    ALOGE("%s: voice_end_call() failed for usecase: %d\n",
                          __func__, usecase_id);
                } else {
                    voice_extn_is_in_call(adev, &is_in_call);
                    if (!is_in_call) {
                        adev->voice.voice_device_set = false;
                    }
                    session->state.current = session->state.new;
                }
                break;
@@ -274,6 +279,7 @@ static int update_call_states(struct audio_device *adev,
    struct voice_session *session = NULL;
    int i = 0;
    bool is_in_call;
    int no_of_calls_active = 0;

    for (i = 0; i < MAX_VOICE_SESSIONS; i++) {
        if (vsid == adev->voice.session[i].vsid) {
@@ -282,17 +288,27 @@ static int update_call_states(struct audio_device *adev,
        }
    }

    for (i = 0; i < MAX_VOICE_SESSIONS; i++) {
        if (CALL_INACTIVE != adev->voice.session[i].state.current)
            no_of_calls_active++;
    }

    /* When there is only one call active, wait for audio policy manager to set
     * the mode to AUDIO_MODE_NORMAL and trigger routing to end the last call.
     */
    if (no_of_calls_active == 1 && call_state == CALL_INACTIVE)
        return 0;

    if (session) {
        session->state.new = call_state;
        voice_extn_is_in_call(adev, &is_in_call);
        ALOGD("%s is_in_call:%d mode:%d\n", __func__, is_in_call, adev->mode);
        ALOGD("%s is_in_call:%d voice_device_set:%d, mode:%d\n",
              __func__, is_in_call, adev->voice.voice_device_set, adev->mode);
        /* Dont start voice call before device routing for voice usescases has
         * occured, otherwise voice calls will be started unintendedly on
         * speaker.
         */
        if (is_in_call ||
            (adev->mode == AUDIO_MODE_IN_CALL &&
             adev->primary_output->devices != AUDIO_DEVICE_OUT_SPEAKER)) {
        if (is_in_call || adev->voice.voice_device_set) {
            /* Device routing is not triggered for voice calls on the subsequent
             * subs, Hence update the call states if voice call is already
             * active on other sub.
@@ -377,6 +393,7 @@ int voice_extn_start_call(struct audio_device *adev)
     * udpated.
     */
    ALOGV("%s: enter:", __func__);
    adev->voice.voice_device_set = true;
    return update_calls(adev);
}