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

Commit 1bbbf54a authored by Venkata Narendra Kumar Gutta's avatar Venkata Narendra Kumar Gutta
Browse files

hal: reset echo reference at the end of recording/VoIP sessions

Echo reference is not being reset currently at the end of
recording/VoIP session causing the echo reference not to
work in the further instances of recording/VoIP sessions.
Fix this by resetting echo reference while closing the input
stream used for recording/VoIP usecases.

CRs-Fixed: 717973
Change-Id: I761ba112952951777525b1bf102c9d6ccaad3269
parent b5b2cb43
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -270,10 +270,13 @@ static int32_t stop_hfp(struct audio_device *adev)
        return -EINVAL;
    }

    /* 2. Get and set stream specific mixer controls */
    /* 2. Disable echo reference while stopping hfp */
    platform_set_echo_reference(adev->platform, false);

    /* 3. Get and set stream specific mixer controls */
    disable_audio_route(adev, uc_info);

    /* 3. Disable the rx and tx devices */
    /* 4. Disable the rx and tx devices */
    disable_snd_device(adev, uc_info->out_snd_device);
    disable_snd_device(adev, uc_info->in_snd_device);

+3 −0
Original line number Diff line number Diff line
@@ -3016,6 +3016,9 @@ static void adev_close_input_stream(struct audio_hw_device *dev,

    ALOGD("%s: enter:stream_handle(%p)",__func__, in);

    /* Disable echo reference while closing input stream */
    platform_set_echo_reference(adev->platform, false);

    if (in->usecase == USECASE_COMPRESS_VOIP_CALL) {
        pthread_mutex_lock(&adev->lock);
        ret = voice_extn_compress_voip_close_input_stream(&stream->common);
+26 −14
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ struct platform_data {
    int  fluence_mode;
    bool slowtalk;
    bool hd_voice;
    bool ec_ref_enabled;
    /* Audio calibration related functions */
    void                       *acdb_handle;
    int                        voice_feature_set;
@@ -472,16 +473,24 @@ static void query_platform(const char *snd_card_name,
    }
}

static void set_echo_reference(struct audio_device *adev, bool enable)
void platform_set_echo_reference(void *platform, bool enable)
{
    int ret = 0;
    struct platform_data *my_data = (struct platform_data *)platform;
    struct audio_device *adev = my_data->adev;

    if (enable)
        ret = audio_route_apply_and_update_path(adev->audio_route, "echo-reference");
    else
        ret = audio_route_reset_and_update_path(adev->audio_route, "echo-reference");
    if (enable) {
        my_data->ec_ref_enabled = enable;
        audio_route_apply_and_update_path(adev->audio_route, "echo-reference");
    } else {
        if (my_data->ec_ref_enabled) {
            audio_route_reset_and_update_path(adev->audio_route, "echo-reference");
            my_data->ec_ref_enabled = enable;
        } else {
            ALOGV("EC reference is already disabled : %d", my_data->ec_ref_enabled);
        }
    }

    ALOGV("Setting EC Reference: %d ret: %d", enable, ret);
    ALOGV("Setting EC Reference: %d", enable);
}

static struct csd_data *open_csd_client()
@@ -1474,14 +1483,16 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
            } else if (my_data->fluence_type == FLUENCE_NONE ||
                my_data->fluence_in_voice_call == false) {
                snd_device = SND_DEVICE_IN_HANDSET_MIC;
                set_echo_reference(adev, true);
                if (audio_extn_hfp_is_active(adev))
                    platform_set_echo_reference(adev->platform, true);
            } else {
                snd_device = SND_DEVICE_IN_VOICE_DMIC;
                adev->acdb_settings |= DMIC_FLAG;
            }
        } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
            snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC;
            set_echo_reference(adev, true);
               if (audio_extn_hfp_is_active(adev))
                   platform_set_echo_reference(adev->platform, true);
        } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) {
            if (adev->bt_wb_speech_enabled) {
                if (adev->bluetooth_nrec)
@@ -1510,7 +1521,8 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                }
            } else {
                snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC;
                set_echo_reference(adev, true);
                if (audio_extn_hfp_is_active(adev))
                    platform_set_echo_reference(adev->platform, true);
            }
        }
    } else if (source == AUDIO_SOURCE_CAMCORDER) {
@@ -1562,7 +1574,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
                }
                set_echo_reference(adev, true);
                platform_set_echo_reference(adev->platform, true);
            } else if (adev->active_input->enable_aec) {
                if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
                    if (my_data->fluence_type & FLUENCE_DUAL_MIC &&
@@ -1583,7 +1595,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
                }
                set_echo_reference(adev, true);
                platform_set_echo_reference(adev->platform, true);
            } else if (adev->active_input->enable_ns) {
                if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
                    if (my_data->fluence_type & FLUENCE_DUAL_MIC &&
@@ -1604,9 +1616,9 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
                }
                set_echo_reference(adev, false);
                platform_set_echo_reference(adev->platform,false);
            } else
                set_echo_reference(adev, false);
                platform_set_echo_reference(adev->platform, false);
        }
    } else if (source == AUDIO_SOURCE_MIC) {
        if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC &&
+17 −6
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ struct platform_data {
    bool fluence_in_voice_rec;
    int  fluence_type;
    int  dualmic_config;
    bool ec_ref_enabled;

    /* Audio calibration related functions */
    void *acdb_handle;
@@ -201,12 +202,22 @@ static const int acdb_device_table[SND_DEVICE_MAX] = {
#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)

static void set_echo_reference(struct audio_device *adev, bool enable)
void platform_set_echo_reference(void *platform, bool enable)
{
    if (enable)
    struct platform_data *my_data = (struct platform_data *)platform;
    struct audio_device *adev = my_data->adev;

    if (enable) {
        my_data->ec_ref_enabled = enable;
        audio_route_apply_and_update_path(adev->audio_route, "echo-reference");
    else
    } else {
        if (my_data->ec_ref_enabled) {
            audio_route_reset_and_update_path(adev->audio_route, "echo-reference");
            my_data->ec_ref_enabled = enable;
        } else {
            ALOGV("EC Reference is already disabled: %d", my_data->ec_ref_enabled);
        }
    }

    ALOGV("Setting EC Reference: %d", enable);
}
@@ -809,9 +820,9 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC;
                }
                set_echo_reference(adev, true);
                platform_set_echo_reference(adev->platform, true);
            } else
                set_echo_reference(adev, false);
                platform_set_echo_reference(adev->platform, false);
        }
    } else if (source == AUDIO_SOURCE_DEFAULT) {
        goto exit;
+27 −13
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ struct platform_data {
    char fluence_cap[PROPERTY_VALUE_MAX];
    bool slowtalk;
    bool hd_voice;
    bool ec_ref_enabled;
    bool is_i2s_ext_modem;
    /* Audio calibration related functions */
    void                       *acdb_handle;
@@ -494,12 +495,22 @@ static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = {
#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)

static void set_echo_reference(struct audio_device *adev, bool enable)
void platform_set_echo_reference(void *platform, bool enable)
{
    if (enable)
    struct platform_data *my_data = (struct platform_data *)platform;
    struct audio_device *adev = my_data->adev;

    if (enable) {
         my_data->ec_ref_enabled = enable;
         audio_route_apply_and_update_path(adev->audio_route, "echo-reference");
    else
    } else {
         if (my_data->ec_ref_enabled) {
             audio_route_reset_and_update_path(adev->audio_route, "echo-reference");
             my_data->ec_ref_enabled = enable;
         } else {
             ALOGV("EC Reference is already disabled: %d", my_data->ec_ref_enabled);
         }
    }

    ALOGV("Setting EC Reference: %d", enable);
}
@@ -1649,13 +1660,15 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
            } else if (my_data->fluence_type == FLUENCE_NONE ||
                my_data->fluence_in_voice_call == false) {
                snd_device = SND_DEVICE_IN_HANDSET_MIC;
                set_echo_reference(adev, true);
                if (audio_extn_hfp_is_active(adev))
                    platform_set_echo_reference(adev->platform, true);
            } else {
                snd_device = SND_DEVICE_IN_VOICE_DMIC;
            }
        } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
            snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC;
            set_echo_reference(adev, true);
            if (audio_extn_hfp_is_active(adev))
                platform_set_echo_reference(adev->platform, true);
        } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) {
            if (adev->bt_wb_speech_enabled) {
                if (adev->bluetooth_nrec)
@@ -1683,7 +1696,8 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                }
            } else {
                snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC;
                set_echo_reference(adev, true);
                if (audio_extn_hfp_is_active(adev))
                    platform_set_echo_reference(adev->platform, true);
            }
        }
    } else if (source == AUDIO_SOURCE_CAMCORDER) {
@@ -1727,7 +1741,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
                }
                set_echo_reference(adev, true);
                platform_set_echo_reference(adev->platform, true);
            } else if (adev->active_input->enable_aec) {
                if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
                    if (my_data->fluence_type & FLUENCE_DUAL_MIC &&
@@ -1746,7 +1760,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
                }
                set_echo_reference(adev, true);
                platform_set_echo_reference(adev->platform, true);
            } else if (adev->active_input->enable_ns) {
                if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
                    if (my_data->fluence_type & FLUENCE_DUAL_MIC &&
@@ -1765,9 +1779,9 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
                }
                set_echo_reference(adev, false);
                platform_set_echo_reference(adev->platform, false);
            } else
                set_echo_reference(adev, false);
                platform_set_echo_reference(adev->platform, false);
        }
    } else if (source == AUDIO_SOURCE_MIC) {
        if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC &&
@@ -1775,7 +1789,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
            if(my_data->fluence_type & FLUENCE_DUAL_MIC &&
                    my_data->fluence_in_audio_rec) {
                snd_device = SND_DEVICE_IN_HANDSET_DMIC;
                set_echo_reference(adev, true);
                platform_set_echo_reference(adev->platform, true);
            }
        }
    } else if (source == AUDIO_SOURCE_FM_RX ||
Loading