author | Jian Xu <jian.xu@amlogic.com> | 2016-04-26 10:28:40 (GMT) |
---|---|---|
committer | Gerrit Code Review <gituser@git.myamlogic.com> | 2016-04-26 10:28:40 (GMT) |
commit | 361d6c358ab7ed904e2c515d59dfd1df94179354 (patch) | |
tree | a3f0ab1ac9a853013b85fbb656a3d9cef060461b | |
parent | c58c7c6a907d57b4d82a51fe137d883c9316a6a7 (diff) | |
parent | ba849f444f4d0b5f41a9a09da3d5167eb26b450b (diff) | |
download | audio-361d6c358ab7ed904e2c515d59dfd1df94179354.zip audio-361d6c358ab7ed904e2c515d59dfd1df94179354.tar.gz audio-361d6c358ab7ed904e2c515d59dfd1df94179354.tar.bz2 |
Merge "PD#123003: add a new effect LPF, merge from l-amlogic" into m-amlogic
-rw-r--r-- | audio_hw.c | 27 | ||||
-rw-r--r-- | libTVaudio/audio/aml_audio.c | 33 | ||||
-rw-r--r-- | libTVaudio/audio/audio_amaudio.cpp | 1 | ||||
-rw-r--r-- | libTVaudio/audio/audio_effect_control.c | 72 | ||||
-rw-r--r-- | libTVaudio/audio/audio_effect_control.h | 8 |
5 files changed, 132 insertions, 9 deletions
@@ -169,6 +169,7 @@ struct aml_stream_out { int has_SRS_lib; int has_EQ_lib; unsigned char pause_status; + int has_aml_IIR_lib; }; #define MAX_PREPROCESSORS 3 /* maximum one AGC + one NS + one AEC per input stream */ @@ -1135,12 +1136,24 @@ static int audio_effect_process(struct audio_stream_out *stream, { struct aml_stream_out *out = (struct aml_stream_out *)stream; int output_size = frame_size << 2; + if (out->has_SRS_lib) { output_size = srs_process(buffer, buffer, frame_size); } if (out->has_EQ_lib) { HPEQ_process(buffer, buffer, frame_size); } + if (out->has_aml_IIR_lib) { + short *ptr = buffer; + short data; + int i; + for (i = 0; i < frame_size; i++) { + data = (short)aml_IIR_process((int)(*ptr), 0); + *ptr++ = data; + data = (short)aml_IIR_process((int)(*ptr), 1); + *ptr++ = data; + } + } return output_size; } @@ -2493,6 +2506,20 @@ static int adev_open_output_stream(struct audio_hw_device *dev, out->has_SRS_lib = 1; } } + //load aml_IIR lib + ret = load_aml_IIR_lib(); + if (ret < 0) { + ALOGE("%s, Load aml_IIR lib fail!\n", __FUNCTION__); + out->has_aml_IIR_lib = 0; + } else { + char value[PROPERTY_VALUE_MAX]; + int paramter = 0; + if (property_get("media.audio.LFP.paramter", value, NULL) > 0) { + paramter = atoi(value); + } + aml_IIR_init(paramter); + out->has_aml_IIR_lib = 1; + } } return 0; diff --git a/libTVaudio/audio/aml_audio.c b/libTVaudio/audio/aml_audio.c index 31c546b..5bdb021 100644 --- a/libTVaudio/audio/aml_audio.c +++ b/libTVaudio/audio/aml_audio.c @@ -121,6 +121,7 @@ struct aml_dev { int aml_Audio_ThreadExecFlag; int has_EQ_lib; int has_SRS_lib; + int has_aml_IIR_lib; int output_deviceID; pthread_t android_check_ThreadID; }; @@ -198,6 +199,7 @@ static struct aml_dev gmAmlDevice = { .aml_Audio_ThreadExecFlag = 0, .has_EQ_lib = 0, .has_SRS_lib = 0, + .has_aml_IIR_lib = 0, .output_deviceID = 0, .android_check_ThreadID = 0, }; @@ -889,7 +891,7 @@ static int set_input_device(int flag) { static int new_audiotrack(struct aml_stream_out *out) { int ret = 0; pthread_mutex_lock(&out->lock); - ALOGD("%s, entering...\n", __FUNCTION__); + //ALOGD("%s, entering...\n", __FUNCTION__); set_amaudio2_enable(1); ret = new_android_audiotrack(); if (ret < 0) { @@ -1109,6 +1111,7 @@ static int release_buffer(struct aml_dev *device) { static int audio_effect_release() { unload_EQ_lib(); unload_SRS_lib(); + unload_aml_IIR_lib(); return 0; } @@ -1219,7 +1222,7 @@ static int aml_device_init(struct aml_dev *device) { //load srs lib and init it. SRS is behand resampling, so sample rate is as default sr. ret = load_SRS_lib(); if (ret < 0) { - ALOGE("%s, Load EQ lib fail!\n", __FUNCTION__); + ALOGE("%s, Load SRS lib fail!\n", __FUNCTION__); device->has_SRS_lib = 0; } else { ret = srs_init(device->out.config.rate); @@ -1230,6 +1233,21 @@ static int aml_device_init(struct aml_dev *device) { } } + //load aml_IIR lib + ret = load_aml_IIR_lib(); + if (ret < 0) { + ALOGE("%s, Load aml_IIR lib fail!\n", __FUNCTION__); + device->has_aml_IIR_lib = 0; + } else { + char value[PROPERTY_VALUE_MAX]; + int paramter = 0; + if (property_get("media.audio.LFP.paramter", value, NULL) > 0) { + paramter = atoi(value); + } + aml_IIR_init(paramter); + device->has_aml_IIR_lib = 1; + } + ALOGD("%s, exiting...\n", __FUNCTION__); return 0; @@ -1498,6 +1516,17 @@ static int audio_effect_process(short* buffer, int frame_size) { if (gpAmlDevice->has_EQ_lib) { HPEQ_process(buffer, buffer, frame_size); } + if (gpAmlDevice->has_aml_IIR_lib) { + short *ptr = buffer; + short data; + int i; + for (i = 0; i < frame_size; i++) { + data = (short)aml_IIR_process((int)(*ptr), 0); + *ptr++ = data; + data = (short)aml_IIR_process((int)(*ptr), 1); + *ptr++ = data; + } + } return output_size; } diff --git a/libTVaudio/audio/audio_amaudio.cpp b/libTVaudio/audio/audio_amaudio.cpp index a3105d5..b5e2658 100644 --- a/libTVaudio/audio/audio_amaudio.cpp +++ b/libTVaudio/audio/audio_amaudio.cpp @@ -35,7 +35,6 @@ int amGetAudioDelay(void) { int amAudioOpen(unsigned int sr, int input_device, int output_device) { int ret; ret = aml_audio_open(sr, input_device, output_device); - ret |= set_audio_delay(60); return ret; } diff --git a/libTVaudio/audio/audio_effect_control.c b/libTVaudio/audio/audio_effect_control.c index c58d558..c6c546f 100644 --- a/libTVaudio/audio/audio_effect_control.c +++ b/libTVaudio/audio/audio_effect_control.c @@ -26,8 +26,7 @@ int (*EQ_release)(void); static void *gEQLibHandler = NULL; int unload_EQ_lib(void) { - ALOGD("%s, entering...\n", __FUNCTION__); - + /*ALOGD("%s, entering...\n", __FUNCTION__);*/ HPEQ_release(); EQ_process = NULL; @@ -50,7 +49,7 @@ int load_EQ_lib(void) { unload_EQ_lib(); - ALOGD("%s, entering...\n", __FUNCTION__); + /*ALOGD("%s, entering...\n", __FUNCTION__);*/ gEQLibHandler = dlopen("/system/lib/soundfx/libhpeq.so", RTLD_NOW); if (!gEQLibHandler) { @@ -94,7 +93,7 @@ int load_EQ_lib(void) { return 0; - Error: // + Error: unload_EQ_lib(); return -1; } @@ -193,7 +192,7 @@ int (*SRS_set_gain)(float input_gain, float output_gain); static void *gSRSLibHandler = NULL; int unload_SRS_lib(void) { - ALOGD("%s, entering...\n", __FUNCTION__); + /*ALOGD("%s, entering...\n", __FUNCTION__);*/ srs_release(); @@ -219,7 +218,7 @@ int load_SRS_lib(void) { unload_SRS_lib(); - ALOGD("%s, entering...\n", __FUNCTION__); + /*ALOGD("%s, entering...\n", __FUNCTION__);*/ gSRSLibHandler = dlopen("/system/lib/soundfx/libsrs.so", RTLD_NOW); if (!gSRSLibHandler) { @@ -434,3 +433,64 @@ int srs_process(short *in, short *out, int framecount) { return output_framecount << 2; } + +//----------------------aml_IIR------------------------------------------------- +int (*audio_IIR_process_api)(int input, int channel); +void (*audio_IIR_init_api)(int param_index); +static void *gAML_IIR_LibHandler = NULL; + +int aml_IIR_process(int input, int channel) { + int ret = 0; + if (audio_IIR_process_api == NULL) { + return input; + } + ret = (*audio_IIR_process_api)(input, channel); + return ret; +} + +void aml_IIR_init(int param_index) { + if (audio_IIR_init_api == NULL) { + return; + } + (*audio_IIR_init_api)(param_index); + return; +} + +int unload_aml_IIR_lib(void) { + audio_IIR_process_api = NULL; + audio_IIR_init_api = NULL; + if (gAML_IIR_LibHandler != NULL) { + dlclose(gAML_IIR_LibHandler); + gAML_IIR_LibHandler = NULL; + } + return 0; +} + +int load_aml_IIR_lib(void) { + char *error; + + unload_aml_IIR_lib(); + + gAML_IIR_LibHandler = dlopen("/system/lib/soundfx/libaml_IIR.so", RTLD_NOW); + if (!gAML_IIR_LibHandler) { + ALOGE("%s, failed to load aml_IIR lib (libaml_IIR.so)\n", __FUNCTION__); + goto Error; + } + + audio_IIR_init_api = (void (*)(int))dlsym(gAML_IIR_LibHandler, "audio_IIR_init"); + if (audio_IIR_init_api == NULL) { + ALOGE("%s, fail find func audio_IIR_init()\n", __FUNCTION__); + goto Error; + } + + audio_IIR_process_api = (int (*)(int, int)) + dlsym(gAML_IIR_LibHandler, "audio_IIR_process"); + if (audio_IIR_process_api == NULL) { + ALOGE("%s, fail find func audio_IIR_process()\n", __FUNCTION__); + goto Error; + } + return 0; +Error: + unload_aml_IIR_lib(); + return -1; +}
\ No newline at end of file diff --git a/libTVaudio/audio/audio_effect_control.h b/libTVaudio/audio/audio_effect_control.h index ad7984d..0587756 100644 --- a/libTVaudio/audio/audio_effect_control.h +++ b/libTVaudio/audio/audio_effect_control.h @@ -42,6 +42,14 @@ int srs_dialogclarity_enable(int enable); int srs_surround_enable(int enable); int srs_process(short *in, short *out, int framecount); +/* + IIR Lowpass Filter from amlogic +*/ +int unload_aml_IIR_lib(void); +int load_aml_IIR_lib(void); +int aml_IIR_process(int input, int channel); +void aml_IIR_init(int param_index); + #ifdef __cplusplus } #endif |