summaryrefslogtreecommitdiffstats
path: root/hal
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-03-25 18:09:11 -0700
committerEric Laurent <elaurent@google.com>2014-03-25 18:09:11 -0700
commit03f09436bb527c26750659d702713ee16bbe75bf (patch)
tree63d02bdbcfeb9632685e05086314a238a42ccc20 /hal
parentfc3907054ff6dab21a07654e8bf0bd9a2b46fddc (diff)
downloadandroid_hardware_qcom_audio-03f09436bb527c26750659d702713ee16bbe75bf.tar.gz
android_hardware_qcom_audio-03f09436bb527c26750659d702713ee16bbe75bf.tar.bz2
android_hardware_qcom_audio-03f09436bb527c26750659d702713ee16bbe75bf.zip
audio: fix set_parameters return value.
xxx_set_parameters functions were returning the status returned by str_parms_create_str() which is incorrect. These functions should return 0 when no error occurs. Change-Id: Ib4a7ac427e49f5500c99902f86d2d69d5843eda0
Diffstat (limited to 'hal')
-rw-r--r--hal/audio_hw.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 972837bb..9481d4b6 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1256,6 +1256,7 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
char value[32];
int ret, val = 0;
bool select_new_device = false;
+ int status = 0;
ALOGD("%s: enter: usecase(%d: %s) kvpairs: %s",
__func__, out->usecase, use_case_table[out->usecase], kvpairs);
@@ -1325,8 +1326,8 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
}
str_parms_destroy(parms);
- ALOGV("%s: exit: code(%d)", __func__, ret);
- return ret;
+ ALOGV("%s: exit: code(%d)", __func__, status);
+ return status;
}
static char* out_get_parameters(const struct audio_stream *stream, const char *keys)
@@ -1700,6 +1701,7 @@ static int in_set_parameters(struct audio_stream *stream, const char *kvpairs)
char *str;
char value[32];
int ret, val = 0;
+ int status = 0;
ALOGV("%s: enter: kvpairs=%s", __func__, kvpairs);
parms = str_parms_create_str(kvpairs);
@@ -1717,13 +1719,14 @@ 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) {
val = atoi(value);
if ((in->device != val) && (val != 0)) {
in->device = val;
/* If recording is in progress, change the tx device to new device */
if (!in->standby)
- ret = select_devices(adev, in->usecase);
+ status = select_devices(adev, in->usecase);
}
}
@@ -1731,8 +1734,8 @@ static int in_set_parameters(struct audio_stream *stream, const char *kvpairs)
pthread_mutex_unlock(&in->lock);
str_parms_destroy(parms);
- ALOGV("%s: exit: status(%d)", __func__, ret);
- return ret;
+ ALOGV("%s: exit: status(%d)", __func__, status);
+ return status;
}
static char* in_get_parameters(const struct audio_stream *stream,
@@ -2032,6 +2035,7 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
char value[32];
int val;
int ret;
+ int status = 0;
ALOGV("%s: enter: %s", __func__, kvpairs);
@@ -2096,27 +2100,30 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
break;
default:
ALOGE("%s: unexpected rotation of %d", __func__, val);
+ status = -EINVAL;
}
- pthread_mutex_lock(&adev->lock);
- if (adev->speaker_lr_swap != reverse_speakers) {
- adev->speaker_lr_swap = reverse_speakers;
- // only update the selected device if there is active pcm playback
- struct audio_usecase *usecase;
- struct listnode *node;
- list_for_each(node, &adev->usecase_list) {
- usecase = node_to_item(node, struct audio_usecase, list);
- if (usecase->type == PCM_PLAYBACK) {
- select_devices(adev, usecase->id);
- break;
+ if (status == 0) {
+ pthread_mutex_lock(&adev->lock);
+ if (adev->speaker_lr_swap != reverse_speakers) {
+ adev->speaker_lr_swap = reverse_speakers;
+ // only update the selected device if there is active pcm playback
+ struct audio_usecase *usecase;
+ struct listnode *node;
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+ if (usecase->type == PCM_PLAYBACK) {
+ select_devices(adev, usecase->id);
+ break;
+ }
}
}
+ pthread_mutex_unlock(&adev->lock);
}
- pthread_mutex_unlock(&adev->lock);
}
str_parms_destroy(parms);
- ALOGV("%s: exit with code(%d)", __func__, ret);
- return ret;
+ ALOGV("%s: exit with code(%d)", __func__, status);
+ return status;
}
static char* adev_get_parameters(const struct audio_hw_device *dev,