summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2015-09-11 01:33:28 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-09-11 01:33:28 +0000
commit13355e906843e889df8ee88d39015f373666fb7f (patch)
tree09ad9acb48ac3e8e1bca2f9deea9bb31e0eefc28
parente63e61d40e171b60b8345f2a47022d066aa589f2 (diff)
parent7963d3828318a32c7a17a240006696e780fd0502 (diff)
downloadhardware_qcom_audio-13355e906843e889df8ee88d39015f373666fb7f.tar.gz
hardware_qcom_audio-13355e906843e889df8ee88d39015f373666fb7f.tar.bz2
hardware_qcom_audio-13355e906843e889df8ee88d39015f373666fb7f.zip
Merge "volume listener: fix process() function for accumulate mode." into mnc-dr-dev
-rw-r--r--post_proc/volume_listener.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/post_proc/volume_listener.c b/post_proc/volume_listener.c
index 62acd6f5..34954bbc 100644
--- a/post_proc/volume_listener.c
+++ b/post_proc/volume_listener.c
@@ -312,6 +312,13 @@ static void check_and_set_gain_dep_cal()
* Effect Control Interface Implementation
*/
+static inline int16_t clamp16(int32_t sample)
+{
+ if ((sample>>15) ^ (sample>>31))
+ sample = 0x7FFF ^ (sample>>31);
+ return sample;
+}
+
static int vol_effect_process(effect_handle_t self,
audio_buffer_t *in_buffer,
audio_buffer_t *out_buffer)
@@ -330,7 +337,15 @@ static int vol_effect_process(effect_handle_t self,
// calculation based on channel count 2
if (in_buffer->raw != out_buffer->raw) {
- memcpy(out_buffer->raw, in_buffer->raw, out_buffer->frameCount * 2 * sizeof(int16_t));
+ if (context->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE) {
+ size_t i;
+ for (i = 0; i < out_buffer->frameCount*2; i++) {
+ out_buffer->s16[i] = clamp16(out_buffer->s16[i] + in_buffer->s16[i]);
+ }
+ } else {
+ memcpy(out_buffer->raw, in_buffer->raw, out_buffer->frameCount * 2 * sizeof(int16_t));
+ }
+
} else {
ALOGW("%s: something wrong, didn't handle in_buffer and out_buffer same address case",
__func__);
@@ -374,6 +389,12 @@ static int vol_effect_command(effect_handle_t self,
case EFFECT_CMD_SET_CONFIG:
ALOGV("%s :: cmd called EFFECT_CMD_SET_CONFIG", __func__);
+ if (p_cmd_data == NULL || cmd_size != sizeof(effect_config_t)
+ || p_reply_data == NULL || reply_size == NULL || *reply_size != sizeof(int)) {
+ return -EINVAL;
+ }
+ context->config = *(effect_config_t *)p_cmd_data;
+ *(int *)p_reply_data = 0;
break;
case EFFECT_CMD_GET_CONFIG:
@@ -600,7 +621,7 @@ static int lib_init()
static int vol_prc_lib_create(const effect_uuid_t *uuid,
int32_t session_id,
- int32_t io_id,
+ int32_t io_id __unused,
effect_handle_t *p_handle)
{
int itt = 0;