hal: fix set_parameter() returning -2 error
When setparameters() is called and if the known keys are not found, the implementation returns -2 error.Fix this by setting error only when keys are found and there is an error while executing corresponding implemention. CRs-fixed: 589280 Change-Id: If5544d6fdeac47ddfc1f7e8e18bfa81e2ef5cbc2
This commit is contained in:
parent
f93084982f
commit
3e064fdd0f
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* 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.
|
||||
|
@ -1341,14 +1341,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);
|
||||
|
@ -1392,18 +1392,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);
|
||||
|
@ -1821,16 +1821,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)) {
|
||||
|
@ -1838,8 +1838,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;
|
||||
|
@ -2236,18 +2236,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 = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_BT_NREC, value, sizeof(value));
|
||||
if (ret >= 0) {
|
||||
ret = platform_set_parameters(adev->platform, parms);
|
||||
if (ret != 0)
|
||||
goto done;
|
||||
|
||||
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.
|
||||
*/
|
||||
|
@ -2257,16 +2262,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
|
||||
|
@ -2298,8 +2303,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;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* 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.
|
||||
|
@ -1358,12 +1358,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) {
|
||||
|
@ -1373,8 +1373,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;
|
||||
|
@ -1386,9 +1386,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) {
|
||||
|
|
23
hal/voice.c
23
hal/voice.c
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* 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 = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_TTY_MODE, value, sizeof(value));
|
||||
if (ret >= 0) {
|
||||
ret = voice_extn_compress_voip_set_parameters(adev, parms);
|
||||
if (ret != 0)
|
||||
goto done;
|
||||
|
||||
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);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* 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,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* 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__);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* 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.
|
||||
|
@ -128,7 +128,7 @@ int voice_extn_compress_voip_set_volume(struct audio_device *adev, float volume)
|
|||
int voice_extn_compress_voip_select_devices(struct audio_device *adev,
|
||||
snd_device_t *out_snd_device,
|
||||
snd_device_t *in_snd_device);
|
||||
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);
|
||||
|
||||
void voice_extn_compress_voip_out_get_parameters(struct stream_out *out,
|
||||
|
@ -210,10 +210,11 @@ static int voice_extn_compress_voip_select_devices(struct audio_device *adev,
|
|||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static void voice_extn_compress_voip_set_parameters(struct audio_device *adev,
|
||||
static int voice_extn_compress_voip_set_parameters(struct audio_device *adev,
|
||||
struct str_parms *parms)
|
||||
{
|
||||
ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static void voice_extn_compress_voip_out_get_parameters(struct stream_out *out,
|
||||
|
|
Loading…
Reference in New Issue