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

Commit e2637fe3 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "hal: Enhance voice concurrency support for 8916"

parents c6b2c751 5f64eea4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ int stop_call(struct audio_device *adev, audio_usecase_t usecase_id)

    session = (struct voice_session *)voice_get_session_from_use_case(adev, usecase_id);
    session->state.current = CALL_INACTIVE;
    if (adev->mode == AUDIO_MODE_NORMAL)
        adev->voice.is_in_call = false;

    ret = platform_stop_voice_call(adev->platform, session->vsid);

+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ struct voice {
    bool mic_mute;
    float volume;
    bool voice_device_set;
    bool is_in_call;
};

enum {
+19 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#define AUDIO_PARAMETER_KEY_ALL_CALL_STATES     "all_call_states"
#define AUDIO_PARAMETER_KEY_DEVICE_MUTE         "device_mute"
#define AUDIO_PARAMETER_KEY_DIRECTION           "direction"
#define AUDIO_PARAMETER_KEY_IN_CALL             "in_call"

#define VOICE_EXTN_PARAMETER_VALUE_MAX_LEN 256

@@ -505,6 +506,15 @@ int voice_extn_set_parameters(struct audio_device *adev,
        }
    }

    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_IN_CALL, str_value,
                            sizeof(str_value));
    if (err >= 0) {
          str_parms_del(parms, AUDIO_PARAMETER_KEY_IN_CALL);
           if (!strncmp("true", str_value, sizeof("true"))) {
           adev->voice.is_in_call = true;
        }
    }

done:
    ALOGV("%s: exit with code(%d)", __func__, ret);
    free(kv_pairs);
@@ -536,10 +546,19 @@ void voice_extn_get_parameters(const struct audio_device *adev,
    int ret;
    char value[VOICE_EXTN_PARAMETER_VALUE_MAX_LEN] = {0};
    char *str = str_parms_to_str(query);
    int val = 0;

    ALOGV_IF(str != NULL, "%s: enter %s", __func__, str);
    free(str);

    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_IN_CALL, value,
                            sizeof(value));
    if (ret >=0) {
        if (adev->voice.is_in_call)
            val = 1;
        str_parms_add_int(reply, AUDIO_PARAMETER_KEY_IN_CALL, val);
    }

    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_AUDIO_MODE, value,
                            sizeof(value));
    if (ret >= 0) {
+33 −22
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ namespace android_audio_legacy {
// AudioPolicyInterface implementation
// ----------------------------------------------------------------------------
const char* AudioPolicyManager::HDMI_SPKR_STR = "hdmi_spkr";
int AudioPolicyManager::mvoice_call_state = 0;

status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
                                                      AudioSystem::device_connection_state state,
@@ -429,7 +430,7 @@ audio_io_handle_t AudioPolicyManager::getInput(int inputSource,
        prop_voip_enabled = atoi(propValue) || !strncmp("true", propValue, 4);
    }

    if (prop_rec_enabled) {
    if (prop_rec_enabled && mvoice_call_state) {
         //check if voice call is active  / running in background
         //some of VoIP apps(like SIP2SIP call) supports resume of VoIP call when call in progress
         //Need to block input request
@@ -450,14 +451,13 @@ audio_io_handle_t AudioPolicyManager::getInput(int inputSource,
                       return 0;
                    }
                break;

                default:
                    ALOGD("BLOCKING input during incall mode for inputSource: %d ",inputSource);
                return 0;
            }
        }
    }//check for VoIP flag
    else if(prop_voip_enabled) {
    else if(prop_voip_enabled && mvoice_call_state) {
         //check if voice call is active  / running in background
         //some of VoIP apps(like SIP2SIP call) supports resume of VoIP call when call in progress
         //Need to block input request
@@ -1030,7 +1030,7 @@ audio_io_handle_t AudioPolicyManager::getOutput(AudioSystem::stream_type stream,
       prop_voip_enabled = atoi(propValue) || !strncmp("true", propValue, 4);
    }

    if (prop_play_enabled) {
    if (prop_play_enabled && mvoice_call_state) {
        //check if voice call is active  / running in background
        if((AudioSystem::MODE_IN_CALL == mPhoneState) ||
             ((AudioSystem::MODE_IN_CALL == mPrevPhoneState)
@@ -1048,7 +1048,7 @@ audio_io_handle_t AudioPolicyManager::getOutput(AudioSystem::stream_type stream,
                flags = (AudioSystem::output_flags)AUDIO_OUTPUT_FLAG_FAST;
            }
        }
    } else if (prop_voip_enabled) {
    } else if (prop_voip_enabled && mvoice_call_state) {
        //check if voice call is active  / running in background
        //some of VoIP apps(like SIP2SIP call) supports resume of VoIP call when call in progress
        //return only ULL ouput
@@ -1401,6 +1401,7 @@ void AudioPolicyManager::setPhoneState(int state)
    int oldState = mPhoneState;
    mPhoneState = state;
    bool force = false;
    int voice_call_state = 0;

    // are we entering or starting a call
    if (!isStateInCall(oldState) && isStateInCall(state)) {
@@ -1457,9 +1458,18 @@ void AudioPolicyManager::setPhoneState(int state)
        prop_voip_enabled = atoi(propValue) || !strncmp("true", propValue, 4);
    }

    if((AudioSystem::MODE_IN_CALL != oldState) && (AudioSystem::MODE_IN_CALL == state)) {
        ALOGD("Entering to call mode oldState :: %d state::%d ",oldState, state);
    bool mode_in_call = (AudioSystem::MODE_IN_CALL != oldState) && (AudioSystem::MODE_IN_CALL == state);
    //query if it is a actual voice call initiated by telephony
    if (mode_in_call) {
        String8 valueStr = mpClientInterface->getParameters((audio_io_handle_t)0, String8("in_call"));
        AudioParameter result = AudioParameter(valueStr);
        if (result.getInt(String8("in_call"), voice_call_state) == NO_ERROR)
            ALOGD("SetPhoneState: Voice call state = %d", voice_call_state);
    }

    if (mode_in_call && voice_call_state) {
        ALOGD("Entering to call mode oldState :: %d state::%d ",oldState, state);
        mvoice_call_state = voice_call_state;
        if (prop_playback_enabled) {
            //Call invalidate to reset all opened non ULL audio tracks
            // Move tracks associated to this strategy from previous output to new output
@@ -1519,25 +1529,26 @@ void AudioPolicyManager::setPhoneState(int state)
            }
            if (((!outputDesc->isDuplicated() &&outputDesc->mProfile->mFlags & AUDIO_OUTPUT_FLAG_PRIMARY))
                        && prop_playback_enabled) {
                ALOGD(" calling suspendOutput on call mdoe for primary output");
                ALOGD(" calling suspendOutput on call mode for primary output");
                mpClientInterface->suspendOutput(mOutputs.keyAt(i));
            } //Close compress all sessions
            else if ((outputDesc->mProfile->mFlags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)
                            &&  prop_playback_enabled) {
                ALOGD(" calling closeOutput on call mdoe for COMPRESS output");
                ALOGD(" calling closeOutput on call mode for COMPRESS output");
                closeOutput(mOutputs.keyAt(i));
            }
            else if ((outputDesc->mProfile->mFlags & AUDIO_OUTPUT_FLAG_VOIP_RX)
                            && prop_voip_enabled) {
                ALOGD(" calling closeOutput on call mdoe for DIRECT  output");
                ALOGD(" calling closeOutput on call mode for DIRECT  output");
                closeOutput(mOutputs.keyAt(i));
            }
        }
   }

   if ((AudioSystem::MODE_IN_CALL == oldState) && (AudioSystem::MODE_IN_CALL != state)
             && prop_playback_enabled) {
        && prop_playback_enabled && mvoice_call_state) {
        ALOGD("EXITING from call mode oldState :: %d state::%d \n",oldState, state);
        mvoice_call_state = 0;
        //restore PCM (deep-buffer) output after call termination
        for (size_t i = 0; i < mOutputs.size(); i++) {
            AudioOutputDescriptor *outputDesc = mOutputs.valueAt(i);
+1 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ protected:
private:
        // Used for voip + voice concurrency usecase
        int mPrevPhoneState;
        static int mvoice_call_state;

};
};