diff options
author | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-05 00:45:26 +0000 |
---|---|---|
committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-05 00:45:26 +0000 |
commit | fbbf508bd695b8c27cbc524fb51573354091b5e0 (patch) | |
tree | d779d8df3ab89b12b1810a2ebf0bd2edf772fa8d /post_proc | |
parent | c49734d5552746ee9ced46e36bc1b1a4a5118086 (diff) | |
parent | 819130e136f54a3e7fa37ba830d87fedcf28a8ae (diff) | |
download | hardware_qcom_audio-fbbf508bd695b8c27cbc524fb51573354091b5e0.tar.gz hardware_qcom_audio-fbbf508bd695b8c27cbc524fb51573354091b5e0.tar.bz2 hardware_qcom_audio-fbbf508bd695b8c27cbc524fb51573354091b5e0.zip |
Merge tag 'android-6.0.0_r26' into cm-13.0
Android 6.0.0 release 26
Diffstat (limited to 'post_proc')
-rw-r--r-- | post_proc/volume_listener.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/post_proc/volume_listener.c b/post_proc/volume_listener.c index cf15f1ca..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: @@ -420,7 +441,7 @@ static int vol_effect_command(effect_handle_t self, // After changing the state and if device is speaker // recalculate gain dep cal level - if (context->dev_id & AUDIO_DEVICE_OUT_SPEAKER) { + if (context->dev_id == AUDIO_DEVICE_OUT_SPEAKER) { check_and_set_gain_dep_cal(); } @@ -447,7 +468,7 @@ static int vol_effect_command(effect_handle_t self, // After changing the state and if device is speaker // recalculate gain dep cal level - if (context->dev_id & AUDIO_DEVICE_OUT_SPEAKER) { + if (context->dev_id == AUDIO_DEVICE_OUT_SPEAKER) { check_and_set_gain_dep_cal(); } @@ -478,8 +499,8 @@ static int vol_effect_command(effect_handle_t self, __func__, context->dev_id, new_device); // check if old or new device is speaker - if ((context->dev_id & AUDIO_DEVICE_OUT_SPEAKER) || - (new_device & AUDIO_DEVICE_OUT_SPEAKER)) { + if ((context->dev_id == AUDIO_DEVICE_OUT_SPEAKER) || + (new_device == AUDIO_DEVICE_OUT_SPEAKER)) { recompute_gain_dep_cal_Level = true; } @@ -504,7 +525,7 @@ static int vol_effect_command(effect_handle_t self, goto exit; } - if (context->dev_id & AUDIO_DEVICE_OUT_SPEAKER) { + if (context->dev_id == AUDIO_DEVICE_OUT_SPEAKER) { recompute_gain_dep_cal_Level = true; } @@ -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; @@ -682,7 +703,7 @@ static int vol_prc_lib_release(effect_handle_t handle) ALOGV("--- Found something to remove ---"); list_remove(&context->effect_list_node); PRINT_STREAM_TYPE(context->stream_type); - if (context->dev_id && AUDIO_DEVICE_OUT_SPEAKER) { + if (context->dev_id == AUDIO_DEVICE_OUT_SPEAKER) { recompute_flag = true; } free(context); |