Merge "hal: Disable gapless offload playback by default."
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 118239d..ff33b7d 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1356,14 +1356,14 @@
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);
@@ -1407,18 +1407,18 @@
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);
@@ -1838,16 +1838,16 @@
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)) {
@@ -1855,8 +1855,8 @@
}
}
- 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;
@@ -2009,7 +2009,7 @@
{
struct audio_device *adev = (struct audio_device *)dev;
struct stream_out *out;
- int i, ret;
+ int i, ret = 0;
ALOGV("%s: enter: sample_rate(%d) channel_mask(%#x) devices(%#x) flags(%#x)",
__func__, config->sample_rate, config->channel_mask, devices, flags);
@@ -2256,18 +2256,23 @@
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.
*/
@@ -2277,16 +2282,16 @@
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
@@ -2318,8 +2323,9 @@
}
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;
@@ -2336,7 +2342,7 @@
pthread_mutex_lock(&adev->lock);
audio_extn_get_parameters(adev, query, reply);
- voice_extn_get_parameters(adev, query, reply);
+ voice_get_parameters(adev, query, reply);
platform_get_parameters(adev->platform, query, reply);
str = str_parms_to_str(reply);
str_parms_destroy(query);
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index ff9aeaa..f32ec94 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.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.
@@ -1359,12 +1359,12 @@
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 @@
}
}
- 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 @@
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) {
diff --git a/hal/voice.c b/hal/voice.c
index cbf8956..74d1978 100644
--- a/hal/voice.c
+++ b/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.
@@ -351,20 +351,32 @@
return ret;
}
+void voice_get_parameters(struct audio_device *adev,
+ struct str_parms *query,
+ struct str_parms *reply)
+{
+ voice_extn_get_parameters(adev, query, reply);
+}
+
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)
@@ -389,9 +401,9 @@
}
}
- 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);
diff --git a/hal/voice.h b/hal/voice.h
index eeb65dc..38b304e 100644
--- a/hal/voice.h
+++ b/hal/voice.h
@@ -72,6 +72,8 @@
int voice_start_call(struct audio_device *adev);
int voice_stop_call(struct audio_device *adev);
int voice_set_parameters(struct audio_device *adev, struct str_parms *parms);
+void voice_get_parameters(struct audio_device *adev, struct str_parms *query,
+ struct str_parms *reply);
void voice_init(struct audio_device *adev);
bool voice_is_in_call(struct audio_device *adev);
int voice_set_mic_mute(struct audio_device *dev, bool state);
diff --git a/hal/voice_extn/compress_voip.c b/hal/voice_extn/compress_voip.c
index ee9fd30..d119ff5 100644
--- a/hal/voice_extn/compress_voip.c
+++ b/hal/voice_extn/compress_voip.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.
@@ -400,53 +400,57 @@
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,
diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c
index 989a871..12fce09 100644
--- a/hal/voice_extn/voice_extn.c
+++ b/hal/voice_extn/voice_extn.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.
@@ -34,8 +34,12 @@
#include "platform_api.h"
#include "voice_extn.h"
-#define AUDIO_PARAMETER_KEY_VSID "vsid"
-#define AUDIO_PARAMETER_KEY_CALL_STATE "call_state"
+#define AUDIO_PARAMETER_KEY_VSID "vsid"
+#define AUDIO_PARAMETER_KEY_CALL_STATE "call_state"
+#define AUDIO_PARAMETER_KEY_AUDIO_MODE "audio_mode"
+#define AUDIO_PARAMETER_KEY_ALL_CALL_STATES "all_call_states"
+
+#define VOICE_EXTN_PARAMETER_VALUE_MAX_LEN 256
#define VOICE2_VSID 0x10DC1000
#define VOLTE_VSID 0x10C02000
@@ -405,17 +409,17 @@
{
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__);
@@ -432,7 +436,7 @@
goto done;
}
} else {
- ALOGD("%s: Not handled here", __func__);
+ ALOGV("%s: Not handled here", __func__);
}
done:
@@ -440,21 +444,51 @@
return ret;
}
+int get_all_call_states_str(const struct audio_device *adev,
+ char *value)
+{
+ int ret = 0;
+ char *cur_ptr = value;
+ int i, len=0;
+
+ for (i = 0; i < MAX_VOICE_SESSIONS; i++) {
+ snprintf(cur_ptr, VOICE_EXTN_PARAMETER_VALUE_MAX_LEN - len,
+ "%d:%d,",adev->voice.session[i].vsid,
+ adev->voice.session[i].state.current);
+ len = strlen(cur_ptr);
+ cur_ptr = cur_ptr + len;
+ }
+ ALOGV("%s:value=%s", __func__, value);
+ return ret;
+}
+
void voice_extn_get_parameters(const struct audio_device *adev,
struct str_parms *query,
struct str_parms *reply)
{
int ret;
- char value[32]={0};
+ char value[VOICE_EXTN_PARAMETER_VALUE_MAX_LEN] = {0};
char *str = NULL;
- ret = str_parms_get_str(query, "audio_mode", value,
+ ALOGV("%s: enter %s", __func__, str_parms_to_str(query));
+
+ ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_AUDIO_MODE, value,
sizeof(value));
if (ret >= 0) {
- str_parms_add_int(reply, "audio_mode", adev->mode);
+ str_parms_add_int(reply, AUDIO_PARAMETER_KEY_AUDIO_MODE, adev->mode);
}
- ALOGV("%s: returns %s", __func__, str_parms_to_str(reply));
+ ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_ALL_CALL_STATES,
+ value, sizeof(value));
+ if (ret >= 0) {
+ ret = get_all_call_states_str(adev, value);
+ if (ret) {
+ ALOGE("%s: Error fetching call states, err:%d", __func__, ret);
+ return;
+ }
+ str_parms_add_str(reply, AUDIO_PARAMETER_KEY_ALL_CALL_STATES, value);
+ }
+ ALOGV("%s: exit: returns \"%s\"", __func__, str_parms_to_str(reply));
}
void voice_extn_out_get_parameters(struct stream_out *out,
diff --git a/hal/voice_extn/voice_extn.h b/hal/voice_extn/voice_extn.h
index 0ca2386..adee939 100644
--- a/hal/voice_extn/voice_extn.h
+++ b/hal/voice_extn/voice_extn.h
@@ -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_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 @@
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,