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

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

Merge "hal: fix set_parameter() returning -2 error"

parents 79545405 3e064fdd
Loading
Loading
Loading
Loading
+30 −24
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
 * Copyright (C) 2013-2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -1355,14 +1355,14 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
    struct listnode *node;
    struct str_parms *parms;
    char value[32];
    int ret, val = 0;
    int ret = 0, val = 0, err;
    bool select_new_device = false;

    ALOGD("%s: enter: usecase(%d: %s) kvpairs: %s",
          __func__, out->usecase, use_case_table[out->usecase], kvpairs);
    parms = str_parms_create_str(kvpairs);
    ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value));
    if (ret >= 0) {
    err = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value));
    if (err >= 0) {
        val = atoi(value);
        pthread_mutex_lock(&out->lock);
        pthread_mutex_lock(&adev->lock);
@@ -1406,18 +1406,18 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
            if ((adev->mode == AUDIO_MODE_IN_CALL) &&
                    !voice_is_in_call(adev) &&
                    (out == adev->primary_output)) {
                voice_start_call(adev);
                ret = voice_start_call(adev);
            } else if ((adev->mode == AUDIO_MODE_IN_CALL) &&
                            voice_is_in_call(adev) &&
                            (out == adev->primary_output)) {
                select_devices(adev, get_voice_usecase_id_from_list(adev));
                ret = select_devices(adev, get_voice_usecase_id_from_list(adev));
            }
        }

        if ((adev->mode == AUDIO_MODE_NORMAL) &&
                voice_is_in_call(adev) &&
                (out == adev->primary_output)) {
            voice_stop_call(adev);
            ret = voice_stop_call(adev);
        }

        pthread_mutex_unlock(&adev->lock);
@@ -1837,16 +1837,16 @@ static int in_set_parameters(struct audio_stream *stream, const char *kvpairs)
    struct str_parms *parms;
    char *str;
    char value[32];
    int ret, val = 0;
    int ret = 0, val = 0, err;

    ALOGV("%s: enter: kvpairs=%s", __func__, kvpairs);
    parms = str_parms_create_str(kvpairs);

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_INPUT_SOURCE, value, sizeof(value));

    pthread_mutex_lock(&in->lock);
    pthread_mutex_lock(&adev->lock);
    if (ret >= 0) {

    err = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_INPUT_SOURCE, value, sizeof(value));
    if (err >= 0) {
        val = atoi(value);
        /* no audio source uses val == 0 */
        if ((in->source != val) && (val != 0)) {
@@ -1854,8 +1854,8 @@ static int in_set_parameters(struct audio_stream *stream, const char *kvpairs)
        }
    }

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value));
    if (ret >= 0) {
    err = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value));
    if (err >= 0) {
        val = atoi(value);
        if ((in->device != val) && (val != 0)) {
            in->device = val;
@@ -2252,18 +2252,23 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
    char *str;
    char value[32];
    int val;
    int ret;
    int ret = 0, err;

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

    pthread_mutex_lock(&adev->lock);
    parms = str_parms_create_str(kvpairs);

    voice_set_parameters(adev, parms);
    platform_set_parameters(adev->platform, parms);
    ret = voice_set_parameters(adev, parms);
    if (ret != 0)
        goto done;

    ret = platform_set_parameters(adev->platform, parms);
    if (ret != 0)
        goto done;

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_BT_NREC, value, sizeof(value));
    if (ret >= 0) {
    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_BT_NREC, value, sizeof(value));
    if (err >= 0) {
        /* When set to false, HAL should disable EC and NS
         * But it is currently not supported.
         */
@@ -2273,16 +2278,16 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
            adev->bluetooth_nrec = false;
    }

    ret = str_parms_get_str(parms, "screen_state", value, sizeof(value));
    if (ret >= 0) {
    err = str_parms_get_str(parms, "screen_state", value, sizeof(value));
    if (err >= 0) {
        if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0)
            adev->screen_off = false;
        else
            adev->screen_off = true;
    }

    ret = str_parms_get_int(parms, "rotation", &val);
    if (ret >= 0) {
    err = str_parms_get_int(parms, "rotation", &val);
    if (err >= 0) {
        bool reverse_speakers = false;
        switch(val) {
        // FIXME: note that the code below assumes that the speakers are in the correct placement
@@ -2314,8 +2319,9 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
    }

    audio_extn_set_parameters(adev, parms);
    str_parms_destroy(parms);

done:
    str_parms_destroy(parms);
    pthread_mutex_unlock(&adev->lock);
    ALOGV("%s: exit with code(%d)", __func__, ret);
    return ret;
+9 −9
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
 * Copyright (C) 2013-2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -1359,12 +1359,12 @@ int platform_set_parameters(void *platform, struct str_parms *parms)
    char *str;
    char value[256] = {0};
    int val;
    int ret = 0;
    int ret = 0, err;

    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));

    ret = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_BTSCO, &val);
    if (ret >= 0) {
    err = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_BTSCO, &val);
    if (err >= 0) {
        str_parms_del(parms, AUDIO_PARAMETER_KEY_BTSCO);
        my_data->btsco_sample_rate = val;
        if (val == SAMPLE_RATE_16KHZ) {
@@ -1374,8 +1374,8 @@ int platform_set_parameters(void *platform, struct str_parms *parms)
        }
    }

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SLOWTALK, value, sizeof(value));
    if (ret >= 0) {
    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SLOWTALK, value, sizeof(value));
    if (err >= 0) {
        bool state = false;
        if (!strncmp("true", value, sizeof("true"))) {
            state = true;
@@ -1387,9 +1387,9 @@ int platform_set_parameters(void *platform, struct str_parms *parms)
            ALOGE("%s: Failed to set slow talk err: %d", __func__, ret);
    }

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOLUME_BOOST,
    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOLUME_BOOST,
                            value, sizeof(value));
    if (ret >= 0) {
    if (err >= 0) {
        str_parms_del(parms, AUDIO_PARAMETER_KEY_VOLUME_BOOST);

        if (my_data->acdb_reload_vocvoltable == NULL) {
+14 −9
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
 * Copyright (C) 2013-2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -363,15 +363,20 @@ int voice_set_parameters(struct audio_device *adev, struct str_parms *parms)
    char *str;
    char value[32];
    int val;
    int ret = 0;
    int ret = 0, err;

    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));

    voice_extn_set_parameters(adev, parms);
    voice_extn_compress_voip_set_parameters(adev, parms);
    ret = voice_extn_set_parameters(adev, parms);
    if (ret != 0)
        goto done;

    ret = voice_extn_compress_voip_set_parameters(adev, parms);
    if (ret != 0)
        goto done;

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_TTY_MODE, value, sizeof(value));
    if (ret >= 0) {
    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_TTY_MODE, value, sizeof(value));
    if (err >= 0) {
        int tty_mode;
        str_parms_del(parms, AUDIO_PARAMETER_KEY_TTY_MODE);
        if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_OFF) == 0)
@@ -396,9 +401,9 @@ int voice_set_parameters(struct audio_device *adev, struct str_parms *parms)
        }
    }

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_INCALLMUSIC,
    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_INCALLMUSIC,
                            value, sizeof(value));
    if (ret >= 0) {
    if (err >= 0) {
        str_parms_del(parms, AUDIO_PARAMETER_KEY_INCALLMUSIC);
        if (strcmp(value, AUDIO_PARAMETER_VALUE_TRUE) == 0)
            platform_start_incall_music_usecase(adev->platform);
+18 −14
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
 * Copyright (C) 2013-2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -400,53 +400,57 @@ error_start_voip:
    return ret;
}

void voice_extn_compress_voip_set_parameters(struct audio_device *adev,
int voice_extn_compress_voip_set_parameters(struct audio_device *adev,
                                             struct str_parms *parms)
{
    char *str;
    char value[32]={0};
    int ret, rate;
    int ret = 0, err, rate;
    int min_rate, max_rate;
    bool flag;

    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_RATE,
    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_RATE,
                            value, sizeof(value));
    if (ret >= 0) {
    if (err >= 0) {
        rate = atoi(value);
        voip_set_rate(adev, rate);
        voip_set_evrc_min_max_rate(adev, rate, rate);
    }

    memset(value, 0, sizeof(value));
    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_EVRC_RATE_MIN,
    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_EVRC_RATE_MIN,
                            value, sizeof(value));
    if (ret >= 0) {
    if (err >= 0) {
        min_rate = atoi(value);
        str_parms_del(parms, AUDIO_PARAMETER_KEY_VOIP_EVRC_RATE_MIN);
        memset(value, 0, sizeof(value));
        ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_EVRC_RATE_MAX,
        err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_EVRC_RATE_MAX,
                                value, sizeof(value));
        if (ret >= 0) {
        if (err >= 0) {
            max_rate = atoi(value);
            voip_set_evrc_min_max_rate(adev, min_rate, max_rate);
        }
        else
        } else {
            ALOGE("%s: AUDIO_PARAMETER_KEY_VOIP_EVRC_RATE_MAX not found", __func__);
            ret = -EINVAL;
            goto done;
        }
    }

    memset(value, 0, sizeof(value));
    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_DTX_MODE,
    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_DTX_MODE,
                            value, sizeof(value));
    if (ret >= 0) {
    if (err >= 0) {
        flag = false;
        if (strcmp(value, AUDIO_PARAMETER_VALUE_VOIP_TRUE) == 0)
            flag = true;
        voip_set_dtx(adev, flag);
    }

done:
    ALOGV("%s: exit", __func__);
    return ret;
}

void voice_extn_compress_voip_out_get_parameters(struct stream_out *out,
+9 −9
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
 * Copyright (C) 2013-2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
 */

#define LOG_TAG "voice_extn"
#define LOG_NDEBUG 0
/*#define LOG_NDEBUG 0*/
#define LOG_NDDEBUG 0

#include <errno.h>
@@ -409,17 +409,17 @@ int voice_extn_set_parameters(struct audio_device *adev,
{
    char *str;
    int value;
    int ret = 0;
    int ret = 0, err;

    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));

    ret = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_VSID, &value);
    if (ret >= 0) {
    err = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_VSID, &value);
    if (err >= 0) {
        str_parms_del(parms, AUDIO_PARAMETER_KEY_VSID);
        int vsid = value;
        uint32_t vsid = value;
        int call_state = -1;
        ret = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_CALL_STATE, &value);
        if (ret >= 0) {
        err = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_CALL_STATE, &value);
        if (err >= 0) {
            call_state = value;
        } else {
            ALOGE("%s: call_state key not found", __func__);
Loading