audio: Re-worked sound pre- and post-processing

In order to activate proprietary sound pre- and post-processing,
the following parts of audio HAL were revised:

* Activated ENABLE_PREPROCESSING directive in Android.mk
* Removed unused variables and functions
* Re-written set_preprocessor_echo_delay() function

Change-Id: I868087f422764895df7d2bc6bbf4bbd76672b8e7
tirimbino
Basil Gello 7 years ago committed by Jan Altensen
parent 5ca267a185
commit efdfdba35a
No known key found for this signature in database
GPG Key ID: 3E45BB95F7AD33DA
  1. 2
      audio/Android.mk
  2. 79
      audio/audio_hw.c
  3. 6
      audio/compress_offload.c

@ -51,7 +51,7 @@ LOCAL_C_INCLUDES += \
$(call include-path-for, audio-effects)
LOCAL_CFLAGS := -Werror -Wall
#LOCAL_CFLAGS += -DPREPROCESSING_ENABLED
LOCAL_CFLAGS += -DPREPROCESSING_ENABLED
LOCAL_MODULE := audio.primary.$(TARGET_BOOTLOADER_BOARD_NAME)

@ -1144,46 +1144,6 @@ static ssize_t read_frames(struct stream_in *in, void *buffer, ssize_t frames);
static int do_in_standby_l(struct stream_in *in);
#ifdef PREPROCESSING_ENABLED
static void get_capture_reference_delay(struct stream_in *in,
size_t frames __unused,
struct echo_reference_buffer *buffer)
{
ALOGVV("%s: enter:)", __func__);
/* read frames available in kernel driver buffer */
unsigned int kernel_frames;
struct timespec tstamp;
long buf_delay;
long kernel_delay;
long delay_ns;
struct pcm_device *ref_device;
long rsmp_delay = 0;
ref_device = node_to_item(list_tail(&in->pcm_dev_list),
struct pcm_device, stream_list_node);
if (pcm_get_htimestamp(ref_device->pcm, &kernel_frames, &tstamp) < 0) {
buffer->time_stamp.tv_sec = 0;
buffer->time_stamp.tv_nsec = 0;
buffer->delay_ns = 0;
ALOGW("read get_capture_reference_delay(): pcm_htimestamp error");
return;
}
/* adjust render time stamp with delay added by current driver buffer.
* Add the duration of current frame as we want the render time of the last
* sample being written. */
kernel_delay = (long)(((int64_t)kernel_frames * 1000000000) / ref_device->pcm_profile->config.rate);
buffer->time_stamp = tstamp;
buffer->delay_ns = kernel_delay;
ALOGVV("get_capture_reference_delay_time_stamp Secs: [%10ld], nSecs: [%9ld], kernel_frames: [%5d],"
" delay_ns: [%d] , frames:[%zd]",
buffer->time_stamp.tv_sec , buffer->time_stamp.tv_nsec, kernel_frames, buffer->delay_ns, frames);
}
static void get_capture_delay(struct stream_in *in,
size_t frames __unused,
struct echo_reference_buffer *buffer)
@ -1280,12 +1240,13 @@ static int set_preprocessor_param(effect_handle_t handle,
effect_param_t *param)
{
uint32_t size = sizeof(int);
uint32_t psize = ((param->psize - 1) / sizeof(int) + 1) * sizeof(int) +
param->vsize;
uint32_t bufsize = sizeof(effect_param_t) +
((param->psize - 1) / sizeof(int) + 1) * sizeof(int) +
param->vsize;
int status = (*handle)->command(handle,
EFFECT_CMD_SET_PARAM,
sizeof (effect_param_t) + psize,
bufsize,
param,
&size,
&param->status);
@ -1298,19 +1259,27 @@ static int set_preprocessor_param(effect_handle_t handle,
static int set_preprocessor_echo_delay(effect_handle_t handle,
int32_t delay_us)
{
struct {
effect_param_t param;
uint32_t data_0;
int32_t data_1;
} buf;
memset(&buf, 0, sizeof(buf));
const uint32_t param_size = sizeof(uint32_t);
const uint32_t value_size = sizeof(uint32_t);
const uint32_t param_padded_size =
((param_size - 1) / sizeof(int) + 1) * sizeof(int);
const uint32_t bufsize = sizeof(effect_param_t) +
param_padded_size + value_size;
uint8_t buf[bufsize];
memset(&buf, 0, bufsize);
effect_param_t *effect_param = (effect_param_t *)&buf;
effect_param->psize = param_size;
effect_param->vsize = value_size;
buf.param.psize = sizeof(uint32_t);
buf.param.vsize = sizeof(uint32_t);
buf.data_0 = AEC_PARAM_ECHO_DELAY;
buf.data_1 = delay_us;
*(uint32_t *)&buf[sizeof(effect_param_t)] = AEC_PARAM_ECHO_DELAY;
*(int32_t *)&buf[sizeof(effect_param_t) + param_padded_size] = delay_us;
return set_preprocessor_param(handle, &buf.param);
return set_preprocessor_param(handle, effect_param);
}
static void push_echo_reference(struct stream_in *in, size_t frames)
@ -1320,7 +1289,6 @@ static void push_echo_reference(struct stream_in *in, size_t frames)
* in->ref_buf_frames is updated with frames available in in->ref_buf */
int32_t delay_us = update_echo_reference(in, frames)/1000;
int32_t size_in_bytes = 0;
int i;
audio_buffer_t buf;
@ -1413,7 +1381,6 @@ static int get_playback_delay(struct stream_out *out,
{
unsigned int kernel_frames;
int status;
int primary_pcm = 0;
struct pcm_device *pcm_device;
pcm_device = node_to_item(list_head(&out->pcm_dev_list),

@ -291,12 +291,6 @@ ssize_t out_write_offload(struct audio_stream_out *stream, const void *buffer,
out->offload_state = OFFLOAD_STATE_PLAYING;
}
pthread_mutex_unlock(&out->lock);
#ifdef PREPROCESSING_ENABLED
if (in) {
/* This mutex was left locked iff in != NULL */
pthread_mutex_unlock(&adev->lock_inputs);
}
#endif
return ret;
}

Loading…
Cancel
Save