post_proc: complete reverb environmental interfaces
offload reverb effect leaves reverb delay, reflections level/delay and
properties as stub. Complete the implementation of these stub reverb
environmental interfaces.
CRs-Fixed: 937407
Change-Id: Id0002ff6770b40b41bec18b70a63ef15c64fcee7
diff --git a/post_proc/reverb.c b/post_proc/reverb.c
index 450ce81..2e97f68 100644
--- a/post_proc/reverb.c
+++ b/post_proc/reverb.c
@@ -230,6 +230,72 @@
OFFLOAD_SEND_REVERB_LEVEL);
}
+uint32_t reverb_get_reverb_delay(reverb_context_t *context)
+{
+ ALOGV("%s: ctxt %p, reverb delay: %d", __func__, context,
+ context->reverb_settings.reverbDelay);
+ return context->reverb_settings.reverbDelay;
+}
+
+void reverb_set_reverb_delay(reverb_context_t *context, uint32_t delay)
+{
+ ALOGV("%s: ctxt %p, reverb delay: %d", __func__, context, delay);
+ context->reverb_settings.reverbDelay = delay;
+ offload_reverb_set_delay(&(context->offload_reverb), delay);
+ if (context->ctl)
+ offload_reverb_send_params(context->ctl, &context->offload_reverb,
+ OFFLOAD_SEND_REVERB_ENABLE_FLAG |
+ OFFLOAD_SEND_REVERB_DELAY);
+ if (context->hw_acc_fd > 0)
+ hw_acc_reverb_send_params(context->hw_acc_fd, &context->offload_reverb,
+ OFFLOAD_SEND_REVERB_ENABLE_FLAG |
+ OFFLOAD_SEND_REVERB_DELAY);
+}
+
+int16_t reverb_get_reflections_level(reverb_context_t *context)
+{
+ ALOGV("%s: ctxt %p, reflection level: %d", __func__, context,
+ context->reverb_settings.reflectionsLevel);
+ return context->reverb_settings.reflectionsLevel;
+}
+
+void reverb_set_reflections_level(reverb_context_t *context, int16_t level)
+{
+ ALOGV("%s: ctxt %p, reflection level: %d", __func__, context, level);
+ context->reverb_settings.reflectionsLevel = level;
+ offload_reverb_set_reflections_level(&(context->offload_reverb), level);
+ if (context->ctl)
+ offload_reverb_send_params(context->ctl, &context->offload_reverb,
+ OFFLOAD_SEND_REVERB_ENABLE_FLAG |
+ OFFLOAD_SEND_REVERB_REFLECTIONS_LEVEL);
+ if (context->hw_acc_fd > 0)
+ hw_acc_reverb_send_params(context->hw_acc_fd, &context->offload_reverb,
+ OFFLOAD_SEND_REVERB_ENABLE_FLAG |
+ OFFLOAD_SEND_REVERB_REFLECTIONS_LEVEL);
+}
+
+uint32_t reverb_get_reflections_delay(reverb_context_t *context)
+{
+ ALOGV("%s: ctxt %p, reflection delay: %d", __func__, context,
+ context->reverb_settings.reflectionsDelay);
+ return context->reverb_settings.reflectionsDelay;
+}
+
+void reverb_set_reflections_delay(reverb_context_t *context, uint32_t delay)
+{
+ ALOGV("%s: ctxt %p, reflection delay: %d", __func__, context, delay);
+ context->reverb_settings.reflectionsDelay = delay;
+ offload_reverb_set_reflections_delay(&(context->offload_reverb), delay);
+ if (context->ctl)
+ offload_reverb_send_params(context->ctl, &context->offload_reverb,
+ OFFLOAD_SEND_REVERB_ENABLE_FLAG |
+ OFFLOAD_SEND_REVERB_REFLECTIONS_DELAY);
+ if (context->hw_acc_fd > 0)
+ hw_acc_reverb_send_params(context->hw_acc_fd, &context->offload_reverb,
+ OFFLOAD_SEND_REVERB_ENABLE_FLAG |
+ OFFLOAD_SEND_REVERB_REFLECTIONS_DELAY);
+}
+
int16_t reverb_get_diffusion(reverb_context_t *context)
{
ALOGV("%s: ctxt %p, diffusion: %d", __func__, context,
@@ -305,8 +371,33 @@
context->reverb_settings.decayTime = reverb_settings->decayTime;
context->reverb_settings.decayHFRatio = reverb_settings->decayHFRatio;
context->reverb_settings.reverbLevel = reverb_settings->reverbLevel;
+ context->reverb_settings.reverbDelay = reverb_settings->reverbDelay;
+ context->reverb_settings.reflectionsLevel = reverb_settings->reflectionsLevel;
+ context->reverb_settings.reflectionsDelay = reverb_settings->reflectionsDelay;
context->reverb_settings.diffusion = reverb_settings->diffusion;
context->reverb_settings.density = reverb_settings->density;
+
+ offload_reverb_set_room_level(&(context->offload_reverb),
+ reverb_settings->roomLevel);
+ offload_reverb_set_room_hf_level(&(context->offload_reverb),
+ reverb_settings->roomHFLevel);
+ offload_reverb_set_decay_time(&(context->offload_reverb),
+ reverb_settings->decayTime);
+ offload_reverb_set_decay_hf_ratio(&(context->offload_reverb),
+ reverb_settings->decayHFRatio);
+ offload_reverb_set_reverb_level(&(context->offload_reverb),
+ reverb_settings->reverbLevel);
+ offload_reverb_set_delay(&(context->offload_reverb),
+ reverb_settings->reverbDelay);
+ offload_reverb_set_reflections_level(&(context->offload_reverb),
+ reverb_settings->reflectionsLevel);
+ offload_reverb_set_reflections_delay(&(context->offload_reverb),
+ reverb_settings->reflectionsDelay);
+ offload_reverb_set_diffusion(&(context->offload_reverb),
+ reverb_settings->diffusion);
+ offload_reverb_set_density(&(context->offload_reverb),
+ reverb_settings->density);
+
if (context->ctl)
offload_reverb_send_params(context->ctl, &context->offload_reverb,
OFFLOAD_SEND_REVERB_ENABLE_FLAG |
@@ -315,6 +406,9 @@
OFFLOAD_SEND_REVERB_DECAY_TIME |
OFFLOAD_SEND_REVERB_DECAY_HF_RATIO |
OFFLOAD_SEND_REVERB_LEVEL |
+ OFFLOAD_SEND_REVERB_DELAY |
+ OFFLOAD_SEND_REVERB_REFLECTIONS_LEVEL |
+ OFFLOAD_SEND_REVERB_REFLECTIONS_DELAY |
OFFLOAD_SEND_REVERB_DIFFUSION |
OFFLOAD_SEND_REVERB_DENSITY);
if (context->hw_acc_fd > 0)
@@ -325,6 +419,9 @@
OFFLOAD_SEND_REVERB_DECAY_TIME |
OFFLOAD_SEND_REVERB_DECAY_HF_RATIO |
OFFLOAD_SEND_REVERB_LEVEL |
+ OFFLOAD_SEND_REVERB_DELAY |
+ OFFLOAD_SEND_REVERB_REFLECTIONS_LEVEL |
+ OFFLOAD_SEND_REVERB_REFLECTIONS_DELAY |
OFFLOAD_SEND_REVERB_DIFFUSION |
OFFLOAD_SEND_REVERB_DENSITY);
}
@@ -388,16 +485,6 @@
p->status = -EINVAL;
p->vsize = sizeof(uint16_t);
break;
- case REVERB_PARAM_REFLECTIONS_LEVEL:
- if (p->vsize < sizeof(uint16_t))
- p->status = -EINVAL;
- p->vsize = sizeof(uint16_t);
- break;
- case REVERB_PARAM_REFLECTIONS_DELAY:
- if (p->vsize < sizeof(uint32_t))
- p->status = -EINVAL;
- p->vsize = sizeof(uint32_t);
- break;
case REVERB_PARAM_REVERB_LEVEL:
if (p->vsize < sizeof(uint16_t))
p->status = -EINVAL;
@@ -408,6 +495,16 @@
p->status = -EINVAL;
p->vsize = sizeof(uint32_t);
break;
+ case REVERB_PARAM_REFLECTIONS_LEVEL:
+ if (p->vsize < sizeof(uint16_t))
+ p->status = -EINVAL;
+ p->vsize = sizeof(uint16_t);
+ break;
+ case REVERB_PARAM_REFLECTIONS_DELAY:
+ if (p->vsize < sizeof(uint32_t))
+ p->status = -EINVAL;
+ p->vsize = sizeof(uint32_t);
+ break;
case REVERB_PARAM_DIFFUSION:
if (p->vsize < sizeof(uint16_t))
p->status = -EINVAL;
@@ -433,19 +530,6 @@
return 0;
switch (param) {
- case REVERB_PARAM_PROPERTIES:
- reverb_settings = (reverb_settings_t *)value;
- reverb_settings->roomLevel = reverb_get_room_level(reverb_ctxt);
- reverb_settings->roomHFLevel = reverb_get_room_hf_level(reverb_ctxt);
- reverb_settings->decayTime = reverb_get_decay_time(reverb_ctxt);
- reverb_settings->decayHFRatio = reverb_get_decay_hf_ratio(reverb_ctxt);
- reverb_settings->reflectionsLevel = 0;
- reverb_settings->reflectionsDelay = 0;
- reverb_settings->reverbDelay = 0;
- reverb_settings->reverbLevel = reverb_get_reverb_level(reverb_ctxt);
- reverb_settings->diffusion = reverb_get_diffusion(reverb_ctxt);
- reverb_settings->density = reverb_get_density(reverb_ctxt);
- break;
case REVERB_PARAM_ROOM_LEVEL:
*(int16_t *)value = reverb_get_room_level(reverb_ctxt);
break;
@@ -461,20 +545,33 @@
case REVERB_PARAM_REVERB_LEVEL:
*(int16_t *)value = reverb_get_reverb_level(reverb_ctxt);
break;
+ case REVERB_PARAM_REVERB_DELAY:
+ *(uint32_t *)value = reverb_get_reverb_delay(reverb_ctxt);
+ break;
+ case REVERB_PARAM_REFLECTIONS_LEVEL:
+ *(int16_t *)value = reverb_get_reflections_level(reverb_ctxt);
+ break;
+ case REVERB_PARAM_REFLECTIONS_DELAY:
+ *(uint32_t *)value = reverb_get_reflections_delay(reverb_ctxt);
+ break;
case REVERB_PARAM_DIFFUSION:
*(int16_t *)value = reverb_get_diffusion(reverb_ctxt);
break;
case REVERB_PARAM_DENSITY:
*(int16_t *)value = reverb_get_density(reverb_ctxt);
break;
- case REVERB_PARAM_REFLECTIONS_LEVEL:
- *(uint16_t *)value = 0;
- break;
- case REVERB_PARAM_REFLECTIONS_DELAY:
- *(uint32_t *)value = 0;
- break;
- case REVERB_PARAM_REVERB_DELAY:
- *(uint32_t *)value = 0;
+ case REVERB_PARAM_PROPERTIES:
+ reverb_settings = (reverb_settings_t *)value;
+ reverb_settings->roomLevel = reverb_get_room_level(reverb_ctxt);
+ reverb_settings->roomHFLevel = reverb_get_room_hf_level(reverb_ctxt);
+ reverb_settings->decayTime = reverb_get_decay_time(reverb_ctxt);
+ reverb_settings->decayHFRatio = reverb_get_decay_hf_ratio(reverb_ctxt);
+ reverb_settings->reverbLevel = reverb_get_reverb_level(reverb_ctxt);
+ reverb_settings->reverbDelay = reverb_get_reverb_delay(reverb_ctxt);
+ reverb_settings->reflectionsLevel = reverb_get_reflections_level(reverb_ctxt);
+ reverb_settings->reflectionsDelay = reverb_get_reflections_delay(reverb_ctxt);
+ reverb_settings->diffusion = reverb_get_diffusion(reverb_ctxt);
+ reverb_settings->density = reverb_get_density(reverb_ctxt);
break;
default:
p->status = -EINVAL;
@@ -496,6 +593,7 @@
int16_t level;
int16_t ratio;
uint32_t time;
+ uint32_t delay;
ALOGV("%s: ctxt %p, param %d", __func__, reverb_ctxt, param);
@@ -515,6 +613,7 @@
switch (param) {
case REVERB_PARAM_PROPERTIES:
reverb_settings = (reverb_settings_t *)value;
+ reverb_set_all_properties(reverb_ctxt, reverb_settings);
break;
case REVERB_PARAM_ROOM_LEVEL:
level = *(int16_t *)value;
@@ -536,6 +635,18 @@
level = *(int16_t *)value;
reverb_set_reverb_level(reverb_ctxt, level);
break;
+ case REVERB_PARAM_REVERB_DELAY:
+ delay = *(uint32_t *)value;
+ reverb_set_reverb_delay(reverb_ctxt, delay);
+ break;
+ case REVERB_PARAM_REFLECTIONS_LEVEL:
+ level = *(int16_t *)value;
+ reverb_set_reflections_level(reverb_ctxt, level);
+ break;
+ case REVERB_PARAM_REFLECTIONS_DELAY:
+ delay = *(uint32_t *)value;
+ reverb_set_reflections_delay(reverb_ctxt, delay);
+ break;
case REVERB_PARAM_DIFFUSION:
ratio = *(int16_t *)value;
reverb_set_diffusion(reverb_ctxt, ratio);
@@ -544,10 +655,6 @@
ratio = *(int16_t *)value;
reverb_set_density(reverb_ctxt, ratio);
break;
- case REVERB_PARAM_REFLECTIONS_LEVEL:
- case REVERB_PARAM_REFLECTIONS_DELAY:
- case REVERB_PARAM_REVERB_DELAY:
- break;
default:
p->status = -EINVAL;
break;
diff --git a/post_proc/reverb.h b/post_proc/reverb.h
index 1a5ca0d..3bdd9af 100644
--- a/post_proc/reverb.h
+++ b/post_proc/reverb.h
@@ -40,7 +40,7 @@
uint32_t reverbDelay;
int16_t diffusion;
int16_t density;
-} reverb_settings_t;
+} __attribute__((packed)) reverb_settings_t;
typedef struct reverb_context_s {
effect_context_t common;