post_proc: fix post and pre process KW issues
KW issue fix includes: - handle memory allocation failure - array index boundary check Change-Id: I083952ba58d348a5b650601a83e6f492b0d686bb
This commit is contained in:
parent
d72dde4c99
commit
ebb69fae68
|
@ -201,6 +201,11 @@ int offload_effects_bundle_hal_start_output(audio_io_handle_t output, int pcm_id
|
||||||
|
|
||||||
output_context_t *out_ctxt = (output_context_t *)
|
output_context_t *out_ctxt = (output_context_t *)
|
||||||
malloc(sizeof(output_context_t));
|
malloc(sizeof(output_context_t));
|
||||||
|
if (!out_ctxt) {
|
||||||
|
ALOGE("%s fail to allocate for output context", __func__);
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
out_ctxt->handle = output;
|
out_ctxt->handle = output;
|
||||||
out_ctxt->pcm_device_id = pcm_id;
|
out_ctxt->pcm_device_id = pcm_id;
|
||||||
|
|
||||||
|
@ -334,6 +339,9 @@ int effect_lib_create(const effect_uuid_t *uuid,
|
||||||
sizeof(effect_uuid_t)) == 0) {
|
sizeof(effect_uuid_t)) == 0) {
|
||||||
equalizer_context_t *eq_ctxt = (equalizer_context_t *)
|
equalizer_context_t *eq_ctxt = (equalizer_context_t *)
|
||||||
calloc(1, sizeof(equalizer_context_t));
|
calloc(1, sizeof(equalizer_context_t));
|
||||||
|
if (eq_ctxt == NULL) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
context = (effect_context_t *)eq_ctxt;
|
context = (effect_context_t *)eq_ctxt;
|
||||||
context->ops.init = equalizer_init;
|
context->ops.init = equalizer_init;
|
||||||
context->ops.reset = equalizer_reset;
|
context->ops.reset = equalizer_reset;
|
||||||
|
@ -351,6 +359,9 @@ int effect_lib_create(const effect_uuid_t *uuid,
|
||||||
sizeof(effect_uuid_t)) == 0) {
|
sizeof(effect_uuid_t)) == 0) {
|
||||||
bassboost_context_t *bass_ctxt = (bassboost_context_t *)
|
bassboost_context_t *bass_ctxt = (bassboost_context_t *)
|
||||||
calloc(1, sizeof(bassboost_context_t));
|
calloc(1, sizeof(bassboost_context_t));
|
||||||
|
if (bass_ctxt == NULL) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
context = (effect_context_t *)bass_ctxt;
|
context = (effect_context_t *)bass_ctxt;
|
||||||
context->ops.init = bassboost_init;
|
context->ops.init = bassboost_init;
|
||||||
context->ops.reset = bassboost_reset;
|
context->ops.reset = bassboost_reset;
|
||||||
|
@ -368,6 +379,9 @@ int effect_lib_create(const effect_uuid_t *uuid,
|
||||||
sizeof(effect_uuid_t)) == 0) {
|
sizeof(effect_uuid_t)) == 0) {
|
||||||
virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)
|
virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)
|
||||||
calloc(1, sizeof(virtualizer_context_t));
|
calloc(1, sizeof(virtualizer_context_t));
|
||||||
|
if (virt_ctxt == NULL) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
context = (effect_context_t *)virt_ctxt;
|
context = (effect_context_t *)virt_ctxt;
|
||||||
context->ops.init = virtualizer_init;
|
context->ops.init = virtualizer_init;
|
||||||
context->ops.reset = virtualizer_reset;
|
context->ops.reset = virtualizer_reset;
|
||||||
|
@ -391,6 +405,9 @@ int effect_lib_create(const effect_uuid_t *uuid,
|
||||||
sizeof(effect_uuid_t)) == 0)) {
|
sizeof(effect_uuid_t)) == 0)) {
|
||||||
reverb_context_t *reverb_ctxt = (reverb_context_t *)
|
reverb_context_t *reverb_ctxt = (reverb_context_t *)
|
||||||
calloc(1, sizeof(reverb_context_t));
|
calloc(1, sizeof(reverb_context_t));
|
||||||
|
if (reverb_ctxt == NULL) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
context = (effect_context_t *)reverb_ctxt;
|
context = (effect_context_t *)reverb_ctxt;
|
||||||
context->ops.init = reverb_init;
|
context->ops.init = reverb_init;
|
||||||
context->ops.reset = reverb_reset;
|
context->ops.reset = reverb_reset;
|
||||||
|
|
|
@ -318,7 +318,8 @@ int offload_eq_send_params(struct mixer_ctl *ctl, struct eq_params eq,
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
ALOGV("%s: flags 0x%x", __func__, param_send_flags);
|
ALOGV("%s: flags 0x%x", __func__, param_send_flags);
|
||||||
if (eq.config.preset_id < -1 ) {
|
if ((eq.config.preset_id < -1) ||
|
||||||
|
((param_send_flags & OFFLOAD_SEND_EQ_PRESET) && (eq.config.preset_id == -1))) {
|
||||||
ALOGV("No Valid preset to set");
|
ALOGV("No Valid preset to set");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,6 +431,11 @@ int visualizer_hal_start_output(audio_io_handle_t output, int pcm_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
output_context_t *out_ctxt = (output_context_t *)malloc(sizeof(output_context_t));
|
output_context_t *out_ctxt = (output_context_t *)malloc(sizeof(output_context_t));
|
||||||
|
if (out_ctxt == NULL) {
|
||||||
|
ALOGE("%s fail to allocate memory", __func__);
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
out_ctxt->handle = output;
|
out_ctxt->handle = output;
|
||||||
list_init(&out_ctxt->effects_list);
|
list_init(&out_ctxt->effects_list);
|
||||||
|
|
||||||
|
@ -927,6 +932,10 @@ int effect_lib_create(const effect_uuid_t *uuid,
|
||||||
if (memcmp(uuid, &visualizer_descriptor.uuid, sizeof(effect_uuid_t)) == 0) {
|
if (memcmp(uuid, &visualizer_descriptor.uuid, sizeof(effect_uuid_t)) == 0) {
|
||||||
visualizer_context_t *visu_ctxt = (visualizer_context_t *)calloc(1,
|
visualizer_context_t *visu_ctxt = (visualizer_context_t *)calloc(1,
|
||||||
sizeof(visualizer_context_t));
|
sizeof(visualizer_context_t));
|
||||||
|
if (visu_ctxt == NULL) {
|
||||||
|
ALOGE("%s fail to allocate memory", __func__);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
context = (effect_context_t *)visu_ctxt;
|
context = (effect_context_t *)visu_ctxt;
|
||||||
context->ops.init = visualizer_init;
|
context->ops.init = visualizer_init;
|
||||||
context->ops.reset = visualizer_reset;
|
context->ops.reset = visualizer_reset;
|
||||||
|
|
|
@ -408,6 +408,10 @@ static struct session_s *get_session(int32_t id, int32_t sessionId, int32_t io
|
||||||
}
|
}
|
||||||
|
|
||||||
session = (struct session_s *)calloc(1, sizeof(struct session_s));
|
session = (struct session_s *)calloc(1, sizeof(struct session_s));
|
||||||
|
if (session == NULL) {
|
||||||
|
ALOGE("get_session() fail to allocate memory");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
session_init(session);
|
session_init(session);
|
||||||
session->id = sessionId;
|
session->id = sessionId;
|
||||||
session->io = ioId;
|
session->io = ioId;
|
||||||
|
@ -682,6 +686,10 @@ static int lib_create(const effect_uuid_t *uuid,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
id = uuid_to_id(&desc->type);
|
id = uuid_to_id(&desc->type);
|
||||||
|
if (id >= NUM_ID) {
|
||||||
|
ALOGW("lib_create: fx not found type: %08x", desc->type.timeLow);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
session = get_session(id, sessionId, ioId);
|
session = get_session(id, sessionId, ioId);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue