From 23e1de74359f4bb1763aef0adfebe073122b032c Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Fri, 23 Jul 2010 00:19:11 -0700 Subject: Audio Effects: added methods to effects java classes to store and load current effect settings in a single call. Addional changes: - Fixed simulator build - Use effect interface UUIDs from OpenSL ES includes when available - Added cleanspec rules to remove now obsolete test effect libraries - Fixed bug in AudioEffect JNI setParameter function. Change-Id: Ic25ddb135e2cec5a68c181d727321f5ac7a1ab6b --- include/media/EffectBassBoostApi.h | 3 +- include/media/EffectEnvironmentalReverbApi.h | 12 ++-- include/media/EffectEqualizerApi.h | 15 ++++- include/media/EffectPresetReverbApi.h | 4 +- include/media/EffectVirtualizerApi.h | 3 +- include/media/EffectVisualizerApi.h | 3 +- media/libeffects/lvm/wrapper/Android.mk | 66 ++++++++++++---------- .../libeffects/lvm/wrapper/Bundle/EffectBundle.cpp | 30 ++++++++-- media/libeffects/lvm/wrapper/Bundle/EffectBundle.h | 47 ++------------- media/libeffects/testlibs/EffectReverb.c | 12 ++-- media/libeffects/visualizer/Android.mk | 2 +- 11 files changed, 98 insertions(+), 99 deletions(-) diff --git a/include/media/EffectBassBoostApi.h b/include/media/EffectBassBoostApi.h index b24a5f4..75f8d78 100644 --- a/include/media/EffectBassBoostApi.h +++ b/include/media/EffectBassBoostApi.h @@ -23,9 +23,10 @@ extern "C" { #endif -// TODO: include OpenSLES_IID.h instead +#ifndef OPENSL_ES_H_ static const effect_uuid_t SL_IID_BASSBOOST_ = { 0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }; const effect_uuid_t * const SL_IID_BASSBOOST = &SL_IID_BASSBOOST_; +#endif //OPENSL_ES_H_ /* enumerated parameter settings for BassBoost effect */ typedef enum diff --git a/include/media/EffectEnvironmentalReverbApi.h b/include/media/EffectEnvironmentalReverbApi.h index d490f71..2233e3f 100644 --- a/include/media/EffectEnvironmentalReverbApi.h +++ b/include/media/EffectEnvironmentalReverbApi.h @@ -23,9 +23,10 @@ extern "C" { #endif -// TODO: include OpenSLES_IID.h instead +#ifndef OPENSL_ES_H_ static const effect_uuid_t SL_IID_ENVIRONMENTALREVERB_ = { 0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, { 0x4e, 0x23, 0x4d, 0x6, 0x83, 0x9e } }; const effect_uuid_t * const SL_IID_ENVIRONMENTALREVERB = &SL_IID_ENVIRONMENTALREVERB_; +#endif //OPENSL_ES_H_ /* enumerated parameter settings for environmental reverb effect */ typedef enum @@ -45,20 +46,19 @@ typedef enum REVERB_PARAM_BYPASS } t_env_reverb_params; -//t_reverb_properties is equal to SLEnvironmentalReverbSettings defined in OpenSL ES specification. -typedef struct s_reverb_properties { +//t_reverb_settings is equal to SLEnvironmentalReverbSettings defined in OpenSL ES specification. +typedef struct s_reverb_settings { int16_t roomLevel; int16_t roomHFLevel; int32_t decayTime; int16_t decayHFRatio; int16_t reflectionsLevel; int32_t reflectionsDelay; - int32_t reverbDelay; int16_t reverbLevel; + int32_t reverbDelay; int16_t diffusion; int16_t density; - int16_t padding; -} t_reverb_properties; +} __attribute__((packed)) t_reverb_settings; #if __cplusplus diff --git a/include/media/EffectEqualizerApi.h b/include/media/EffectEqualizerApi.h index cb05b32..0492ea0 100644 --- a/include/media/EffectEqualizerApi.h +++ b/include/media/EffectEqualizerApi.h @@ -19,8 +19,10 @@ #include -// for the definition of SL_IID_EQUALIZER -#include "OpenSLES.h" +#ifndef OPENSL_ES_H_ +static const effect_uuid_t SL_IID_EQUALIZER_ = { 0x0bed4300, 0xddd6, 0x11db, 0x8f34, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }; +const effect_uuid_t * const SL_IID_EQUALIZER = &SL_IID_EQUALIZER_; +#endif //OPENSL_ES_H_ #if __cplusplus extern "C" { @@ -37,9 +39,16 @@ typedef enum EQ_PARAM_GET_BAND, // Gets the band that has the most effect on the given frequency. EQ_PARAM_CUR_PRESET, // Gets/Sets the current preset. EQ_PARAM_GET_NUM_OF_PRESETS, // Gets the total number of presets the equalizer supports. - EQ_PARAM_GET_PRESET_NAME // Gets the preset name based on the index. + EQ_PARAM_GET_PRESET_NAME, // Gets the preset name based on the index. + EQ_PARAM_PROPERTIES // Gets/Sets all parameters at a time. } t_equalizer_params; +//t_equalizer_settings groups all current equalizer setting for backup and restore. +typedef struct s_equalizer_settings { + uint16_t curPreset; + uint16_t numBands; + uint16_t bandLevels[]; +} t_equalizer_settings; #if __cplusplus } // extern "C" diff --git a/include/media/EffectPresetReverbApi.h b/include/media/EffectPresetReverbApi.h index 34ffffe..53205bb 100644 --- a/include/media/EffectPresetReverbApi.h +++ b/include/media/EffectPresetReverbApi.h @@ -23,10 +23,10 @@ extern "C" { #endif -// TODO: include OpenSLES_IID.h instead - +#ifndef OPENSL_ES_H_ static const effect_uuid_t SL_IID_PRESETREVERB_ = { 0x47382d60, 0xddd8, 0x11db, 0xbf3a, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }; const effect_uuid_t * const SL_IID_PRESETREVERB = &SL_IID_PRESETREVERB_; +#endif //OPENSL_ES_H_ /* enumerated parameter settings for preset reverb effect */ typedef enum diff --git a/include/media/EffectVirtualizerApi.h b/include/media/EffectVirtualizerApi.h index 601c384..c3d5131 100644 --- a/include/media/EffectVirtualizerApi.h +++ b/include/media/EffectVirtualizerApi.h @@ -23,9 +23,10 @@ extern "C" { #endif -// TODO: include OpenSLES_IID.h instead +#ifndef OPENSL_ES_H_ static const effect_uuid_t SL_IID_VIRTUALIZER_ = { 0x37cc2c00, 0xdddd, 0x11db, 0x8577, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }; const effect_uuid_t * const SL_IID_VIRTUALIZER = &SL_IID_VIRTUALIZER_; +#endif //OPENSL_ES_H_ /* enumerated parameter settings for virtualizer effect */ typedef enum diff --git a/include/media/EffectVisualizerApi.h b/include/media/EffectVisualizerApi.h index 1155db8..bef1a4f 100644 --- a/include/media/EffectVisualizerApi.h +++ b/include/media/EffectVisualizerApi.h @@ -23,10 +23,11 @@ extern "C" { #endif -//TODO replace by openSL ES include when available +#ifndef OPENSL_ES_H_ static const effect_uuid_t SL_IID_VISUALIZATION_ = { 0xe46b26a0, 0xdddd, 0x11db, 0x8afd, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }; const effect_uuid_t * const SL_IID_VISUALIZATION = &SL_IID_VISUALIZATION_; +#endif //OPENSL_ES_H_ #define VISUALIZER_CAPTURE_SIZE_MAX 1024 // maximum capture size in samples #define VISUALIZER_CAPTURE_SIZE_MIN 128 // minimum capture size in samples diff --git a/media/libeffects/lvm/wrapper/Android.mk b/media/libeffects/lvm/wrapper/Android.mk index 4ebc443..7855dcd 100644 --- a/media/libeffects/lvm/wrapper/Android.mk +++ b/media/libeffects/lvm/wrapper/Android.mk @@ -1,30 +1,36 @@ -LOCAL_PATH:= $(call my-dir) - -# music bundle wrapper -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_ARM_MODE := arm - -LOCAL_SRC_FILES:= \ - Bundle/EffectBundle.cpp - -LOCAL_MODULE:= libbundlewrapper - -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx - -LOCAL_PRELINK_MODULE := false - -LOCAL_STATIC_LIBRARIES += libmusicbundle - -LOCAL_SHARED_LIBRARIES := \ - libcutils \ - libdl - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/Bundle \ - $(LOCAL_PATH)/../lib/Common/lib/ \ - $(LOCAL_PATH)/../lib/Bundle/lib/ - - -include $(BUILD_SHARED_LIBRARY) +LOCAL_PATH:= $(call my-dir) + +# music bundle wrapper +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_ARM_MODE := arm + +LOCAL_SRC_FILES:= \ + Bundle/EffectBundle.cpp + +LOCAL_MODULE:= libbundlewrapper + +LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx + +LOCAL_PRELINK_MODULE := false + +LOCAL_STATIC_LIBRARIES += libmusicbundle + +LOCAL_SHARED_LIBRARIES := \ + libcutils \ + +ifeq ($(TARGET_SIMULATOR),true) +LOCAL_LDLIBS += -ldl +else +LOCAL_SHARED_LIBRARIES += libdl +endif + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/Bundle \ + $(LOCAL_PATH)/../lib/Common/lib/ \ + $(LOCAL_PATH)/../lib/Bundle/lib/ + + +include $(BUILD_SHARED_LIBRARY) diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp index 5e91974..4440447 100644 --- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp +++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp @@ -1625,7 +1625,7 @@ int BassBoost_getParameter(EffectContext *pContext, //LOGV("\tBassBoost_getParameter start"); switch (param){ - case BASSBOOST_PARAM_STRENGTH_SUP: + case BASSBOOST_PARAM_STRENGTH_SUPPORTED: case BASSBOOST_PARAM_STRENGTH: if (*pValueSize != sizeof(int16_t)){ LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize2 %d", *pValueSize); @@ -1640,10 +1640,10 @@ int BassBoost_getParameter(EffectContext *pContext, } switch (param){ - case BASSBOOST_PARAM_STRENGTH_SUP: + case BASSBOOST_PARAM_STRENGTH_SUPPORTED: *(uint32_t *)pValue = 1; - //LOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH_SUP Value is %d", + //LOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH_SUPPORTED Value is %d", // *(uint32_t *)pValue); break; @@ -1735,7 +1735,7 @@ int Virtualizer_getParameter(EffectContext *pContext, //LOGV("\tVirtualizer_getParameter start"); switch (param){ - case VIRTUALIZER_PARAM_STRENGTH_SUP: + case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: case VIRTUALIZER_PARAM_STRENGTH: if (*pValueSize != sizeof(int16_t)){ LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize2 %d",*pValueSize); @@ -1750,10 +1750,10 @@ int Virtualizer_getParameter(EffectContext *pContext, } switch (param){ - case VIRTUALIZER_PARAM_STRENGTH_SUP: + case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: *(uint32_t *)pValue = 1; - //LOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH_SUP Value is %d", + //LOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH_SUPPORTED Value is %d", // *(uint32_t *)pValue); break; @@ -1876,6 +1876,14 @@ int Equalizer_getParameter(EffectContext *pContext, case EQ_PARAM_GET_PRESET_NAME: break; + case EQ_PARAM_PROPERTIES: + if (*pValueSize < (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t)) { + LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); + return -EINVAL; + } + *pValueSize = (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t); + break; + default: LOGV("\tLVM_ERROR : Equalizer_getParameter unknown param %d", param); return -EINVAL; @@ -1959,6 +1967,16 @@ int Equalizer_getParameter(EffectContext *pContext, // param2, gEqualizerPresets[param2].name, *pValueSize); break; + case EQ_PARAM_PROPERTIES: { + uint16_t *p = (uint16_t *)pValue; + LOGV("\tEqualizer_getParameter() EQ_PARAM_PROPERTIES"); + p[0] = EqualizerGetPreset(pContext); + p[1] = FIVEBAND_NUMBANDS; + for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { + p[2 + i] = EqualizerGetBandLevel(pContext, i); + } + } break; + default: LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid param %d", param); status = -EINVAL; diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h index 029f843..d009bf9 100644 --- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h +++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h @@ -17,7 +17,9 @@ #ifndef ANDROID_EFFECTBUNDLE_H_ #define ANDROID_EFFECTBUNDLE_H_ -#include +#include +#include +#include #include #if __cplusplus @@ -29,22 +31,11 @@ extern "C" { #define MAX_CALL_SIZE 256 //#define LVM_PCM -//TODO: this should be included from each effect API include -static const effect_uuid_t SL_IID_BASSBOOST_ = { 0x0634f220, 0xddd4, 0x11db, 0xa0fc, - { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }; -const effect_uuid_t * const SL_IID_BASSBOOST = &SL_IID_BASSBOOST_; - -static const effect_uuid_t SL_IID_EQUALIZER_ = { 0x0bed4300, 0xddd6, 0x11db, 0x8f34, - { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }; -const effect_uuid_t * const SL_IID_EQUALIZER = &SL_IID_EQUALIZER_; - -static const effect_uuid_t SL_IID_VIRTUALIZER_ = { 0x37cc2c00, 0xdddd, 0x11db, 0x8577, - { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }; -const effect_uuid_t * const SL_IID_VIRTUALIZER = &SL_IID_VIRTUALIZER_; - +#ifndef OPENSL_ES_H_ static const effect_uuid_t SL_IID_VOLUME_ = { 0x09e8ede0, 0xddde, 0x11db, 0xb4f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }; const effect_uuid_t * const SL_IID_VOLUME = &SL_IID_VOLUME_; +#endif //OPENSL_ES_H_ typedef enum { @@ -112,34 +103,6 @@ struct EffectContext{ BundledEffectContext *pBundledContext; }; -//TODO: this should be included from each effect API include -/* enumerated parameter settings for BassBoost effect */ -typedef enum -{ - BASSBOOST_PARAM_STRENGTH_SUP, // type SLboolean = typedef SLuint32 - BASSBOOST_PARAM_STRENGTH // type SLpermille = typedef SLuint16 -} t_bassboost_params; - -/* enumerated parameter settings for Virtualizer effect */ -typedef enum -{ - VIRTUALIZER_PARAM_STRENGTH_SUP, // type SLboolean = typedef SLuint32 - VIRTUALIZER_PARAM_STRENGTH // type SLpermille = typedef SLuint16 -} t_virtualizer_params; - -/* enumerated parameter settings for Equalizer effect */ -typedef enum -{ - EQ_PARAM_NUM_BANDS, // Gets the number of frequency bands that the equalizer supports. - EQ_PARAM_LEVEL_RANGE, // Returns the minimum and maximum band levels supported. - EQ_PARAM_BAND_LEVEL, // Gets/Sets the gain set for the given equalizer band. - EQ_PARAM_CENTER_FREQ, // Gets the center frequency of the given band. - EQ_PARAM_BAND_FREQ_RANGE, // Gets the frequency range of the given frequency band. - EQ_PARAM_GET_BAND, // Gets the band that has the most effect on the given frequency. - EQ_PARAM_CUR_PRESET, // Gets/Sets the current preset. - EQ_PARAM_GET_NUM_OF_PRESETS, // Gets the total number of presets the equalizer supports. - EQ_PARAM_GET_PRESET_NAME // Gets the preset name based on the index. -} t_equalizer_params; /* enumerated parameter settings for Volume effect */ typedef enum diff --git a/media/libeffects/testlibs/EffectReverb.c b/media/libeffects/testlibs/EffectReverb.c index 2ce7558..3f9069f 100644 --- a/media/libeffects/testlibs/EffectReverb.c +++ b/media/libeffects/testlibs/EffectReverb.c @@ -688,7 +688,7 @@ int Reverb_getParameter(reverb_object_t *pReverb, int32_t param, size_t *pSize, void *pValue) { int32_t *pValue32; int16_t *pValue16; - t_reverb_properties *pProperties; + t_reverb_settings *pProperties; int32_t i; int32_t temp; int32_t temp2; @@ -727,7 +727,7 @@ int Reverb_getParameter(reverb_object_t *pReverb, int32_t param, size_t *pSize, break; case REVERB_PARAM_PROPERTIES: - size = sizeof(t_reverb_properties); + size = sizeof(t_reverb_settings); break; default: @@ -740,7 +740,7 @@ int Reverb_getParameter(reverb_object_t *pReverb, int32_t param, size_t *pSize, pValue32 = (int32_t *) pValue; pValue16 = (int16_t *) pValue; - pProperties = (t_reverb_properties *) pValue; + pProperties = (t_reverb_settings *) pValue; switch (param) { case REVERB_PARAM_BYPASS: @@ -971,7 +971,7 @@ int Reverb_setParameter(reverb_object_t *pReverb, int32_t param, size_t size, void *pValue) { int32_t value32; int16_t value16; - t_reverb_properties *pProperties; + t_reverb_settings *pProperties; int32_t i; int32_t temp; int32_t temp2; @@ -1019,7 +1019,7 @@ int Reverb_setParameter(reverb_object_t *pReverb, int32_t param, size_t size, break; case REVERB_PARAM_PROPERTIES: - paramSize = sizeof(t_reverb_properties); + paramSize = sizeof(t_reverb_settings); break; default: @@ -1035,7 +1035,7 @@ int Reverb_setParameter(reverb_object_t *pReverb, int32_t param, size_t size, } else if (paramSize == sizeof(int32_t)) { value32 = *(int32_t *) pValue; } else { - pProperties = (t_reverb_properties *) pValue; + pProperties = (t_reverb_settings *) pValue; } pPreset = &pReverb->m_sPreset.m_sPreset[pReverb->m_nNextRoom]; diff --git a/media/libeffects/visualizer/Android.mk b/media/libeffects/visualizer/Android.mk index 82cd925..48b45ff 100644 --- a/media/libeffects/visualizer/Android.mk +++ b/media/libeffects/visualizer/Android.mk @@ -15,7 +15,7 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx LOCAL_MODULE:= libvisualizer ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true) -LOCAL_LDLIBS += -ldlS +LOCAL_LDLIBS += -ldl endif ifneq ($(TARGET_SIMULATOR),true) -- cgit v1.1