diff options
Diffstat (limited to 'media/libeffects')
29 files changed, 267 insertions, 204 deletions
diff --git a/media/libeffects/downmix/Android.mk b/media/libeffects/downmix/Android.mk index 5d0a87c..2bb6dbe 100644 --- a/media/libeffects/downmix/Android.mk +++ b/media/libeffects/downmix/Android.mk @@ -13,7 +13,7 @@ LOCAL_MODULE:= libdownmix LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx +LOCAL_MODULE_RELATIVE_PATH := soundfx ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true) LOCAL_LDLIBS += -ldl diff --git a/media/libeffects/downmix/EffectDownmix.c b/media/libeffects/downmix/EffectDownmix.c index f779876..1663d47 100644 --- a/media/libeffects/downmix/EffectDownmix.c +++ b/media/libeffects/downmix/EffectDownmix.c @@ -16,7 +16,8 @@ #define LOG_TAG "EffectDownmix" //#define LOG_NDEBUG 0 -#include <cutils/log.h> +#include <log/log.h> +#include <inttypes.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> @@ -99,7 +100,7 @@ const int kNbEffects = sizeof(gDescriptors) / sizeof(const effect_descriptor_t * // strictly for testing, logs the indices of the channels for a given mask, // uses the same code as Downmix_foldGeneric() void Downmix_testIndexComputation(uint32_t mask) { - ALOGI("Testing index computation for 0x%x:", mask); + ALOGI("Testing index computation for 0x%" PRIx32 ":", mask); // check against unsupported channels if (mask & kUnsupported) { ALOGE("Unsupported channels (top or front left/right of center)"); @@ -220,7 +221,7 @@ int32_t DownmixLib_Create(const effect_uuid_t *uuid, *pHandle = (effect_handle_t) module; - ALOGV("DownmixLib_Create() %p , size %d", module, sizeof(downmix_module_t)); + ALOGV("DownmixLib_Create() %p , size %zu", module, sizeof(downmix_module_t)); return 0; } @@ -254,7 +255,7 @@ int32_t DownmixLib_GetDescriptor(const effect_uuid_t *uuid, effect_descriptor_t ALOGV("DownmixLib_GetDescriptor() i=%d", i); if (memcmp(uuid, &gDescriptors[i]->uuid, sizeof(effect_uuid_t)) == 0) { memcpy(pDescriptor, gDescriptors[i], sizeof(effect_descriptor_t)); - ALOGV("EffectGetDescriptor - UUID matched downmix type %d, UUID = %x", + ALOGV("EffectGetDescriptor - UUID matched downmix type %d, UUID = %" PRIx32, i, gDescriptors[i]->uuid.timeLow); return 0; } @@ -328,7 +329,7 @@ static int Downmix_Process(effect_handle_t self, // bypass the optimized downmix routines for the common formats if (!Downmix_foldGeneric( downmixInputChannelMask, pSrc, pDst, numFrames, accumulate)) { - ALOGE("Multichannel configuration 0x%x is not supported", downmixInputChannelMask); + ALOGE("Multichannel configuration 0x%" PRIx32 " is not supported", downmixInputChannelMask); return -EINVAL; } break; @@ -352,7 +353,7 @@ static int Downmix_Process(effect_handle_t self, default: if (!Downmix_foldGeneric( downmixInputChannelMask, pSrc, pDst, numFrames, accumulate)) { - ALOGE("Multichannel configuration 0x%x is not supported", downmixInputChannelMask); + ALOGE("Multichannel configuration 0x%" PRIx32 " is not supported", downmixInputChannelMask); return -EINVAL; } break; @@ -380,7 +381,7 @@ static int Downmix_Command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdS pDownmixer = (downmix_object_t*) &pDwmModule->context; - ALOGV("Downmix_Command command %d cmdSize %d",cmdCode, cmdSize); + ALOGV("Downmix_Command command %" PRIu32 " cmdSize %" PRIu32, cmdCode, cmdSize); switch (cmdCode) { case EFFECT_CMD_INIT: @@ -404,7 +405,7 @@ static int Downmix_Command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdS break; case EFFECT_CMD_GET_PARAM: - ALOGV("Downmix_Command EFFECT_CMD_GET_PARAM pCmdData %p, *replySize %d, pReplyData: %p", + ALOGV("Downmix_Command EFFECT_CMD_GET_PARAM pCmdData %p, *replySize %" PRIu32 ", pReplyData: %p", pCmdData, *replySize, pReplyData); if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || pReplyData == NULL || @@ -413,7 +414,7 @@ static int Downmix_Command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdS } effect_param_t *rep = (effect_param_t *) pReplyData; memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + sizeof(int32_t)); - ALOGV("Downmix_Command EFFECT_CMD_GET_PARAM param %d, replySize %d", + ALOGV("Downmix_Command EFFECT_CMD_GET_PARAM param %" PRId32 ", replySize %" PRIu32, *(int32_t *)rep->data, rep->vsize); rep->status = Downmix_getParameter(pDownmixer, *(int32_t *)rep->data, &rep->vsize, rep->data + sizeof(int32_t)); @@ -421,8 +422,8 @@ static int Downmix_Command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdS break; case EFFECT_CMD_SET_PARAM: - ALOGV("Downmix_Command EFFECT_CMD_SET_PARAM cmdSize %d pCmdData %p, *replySize %d, " \ - "pReplyData %p", cmdSize, pCmdData, *replySize, pReplyData); + ALOGV("Downmix_Command EFFECT_CMD_SET_PARAM cmdSize %d pCmdData %p, *replySize %" PRIu32 + ", pReplyData %p", cmdSize, pCmdData, *replySize, pReplyData); if (pCmdData == NULL || (cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t))) || pReplyData == NULL || *replySize != (int)sizeof(int32_t)) { return -EINVAL; @@ -471,7 +472,7 @@ static int Downmix_Command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdS return -EINVAL; } // FIXME change type if playing on headset vs speaker - ALOGV("Downmix_Command EFFECT_CMD_SET_DEVICE: 0x%08x", *(uint32_t *)pCmdData); + ALOGV("Downmix_Command EFFECT_CMD_SET_DEVICE: 0x%08" PRIx32, *(uint32_t *)pCmdData); break; case EFFECT_CMD_SET_VOLUME: { @@ -491,7 +492,7 @@ static int Downmix_Command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdS if (pCmdData == NULL || cmdSize != (int)sizeof(uint32_t)) { return -EINVAL; } - ALOGV("Downmix_Command EFFECT_CMD_SET_AUDIO_MODE: %d", *(uint32_t *)pCmdData); + ALOGV("Downmix_Command EFFECT_CMD_SET_AUDIO_MODE: %" PRIu32, *(uint32_t *)pCmdData); break; case EFFECT_CMD_SET_CONFIG_REVERSE: @@ -500,7 +501,7 @@ static int Downmix_Command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdS break; default: - ALOGW("Downmix_Command invalid command %d",cmdCode); + ALOGW("Downmix_Command invalid command %" PRIu32, cmdCode); return -EINVAL; } @@ -629,7 +630,9 @@ int Downmix_Configure(downmix_module_t *pDwmModule, effect_config_t *pConfig, bo return -EINVAL; } - memcpy(&pDwmModule->config, pConfig, sizeof(effect_config_t)); + if (&pDwmModule->config != pConfig) { + memcpy(&pDwmModule->config, pConfig, sizeof(effect_config_t)); + } if (init) { pDownmixer->type = DOWNMIX_TYPE_FOLD; @@ -697,31 +700,31 @@ int Downmix_Reset(downmix_object_t *pDownmixer, bool init) { * *---------------------------------------------------------------------------- */ -int Downmix_setParameter(downmix_object_t *pDownmixer, int32_t param, size_t size, void *pValue) { +int Downmix_setParameter(downmix_object_t *pDownmixer, int32_t param, uint32_t size, void *pValue) { int16_t value16; - ALOGV("Downmix_setParameter, context %p, param %d, value16 %d, value32 %d", + ALOGV("Downmix_setParameter, context %p, param %" PRId32 ", value16 %" PRId16 ", value32 %" PRId32, pDownmixer, param, *(int16_t *)pValue, *(int32_t *)pValue); switch (param) { case DOWNMIX_PARAM_TYPE: if (size != sizeof(downmix_type_t)) { - ALOGE("Downmix_setParameter(DOWNMIX_PARAM_TYPE) invalid size %d, should be %d", + ALOGE("Downmix_setParameter(DOWNMIX_PARAM_TYPE) invalid size %" PRIu32 ", should be %zu", size, sizeof(downmix_type_t)); return -EINVAL; } value16 = *(int16_t *)pValue; - ALOGV("set DOWNMIX_PARAM_TYPE, type %d", value16); + ALOGV("set DOWNMIX_PARAM_TYPE, type %" PRId16, value16); if (!((value16 > DOWNMIX_TYPE_INVALID) && (value16 <= DOWNMIX_TYPE_LAST))) { - ALOGE("Downmix_setParameter invalid DOWNMIX_PARAM_TYPE value %d", value16); + ALOGE("Downmix_setParameter invalid DOWNMIX_PARAM_TYPE value %" PRId16, value16); return -EINVAL; } else { pDownmixer->type = (downmix_type_t) value16; break; default: - ALOGE("Downmix_setParameter unknown parameter %d", param); + ALOGE("Downmix_setParameter unknown parameter %" PRId32, param); return -EINVAL; } } @@ -753,24 +756,24 @@ int Downmix_setParameter(downmix_object_t *pDownmixer, int32_t param, size_t siz * *---------------------------------------------------------------------------- */ -int Downmix_getParameter(downmix_object_t *pDownmixer, int32_t param, size_t *pSize, void *pValue) { +int Downmix_getParameter(downmix_object_t *pDownmixer, int32_t param, uint32_t *pSize, void *pValue) { int16_t *pValue16; switch (param) { case DOWNMIX_PARAM_TYPE: if (*pSize < sizeof(int16_t)) { - ALOGE("Downmix_getParameter invalid parameter size %d for DOWNMIX_PARAM_TYPE", *pSize); + ALOGE("Downmix_getParameter invalid parameter size %" PRIu32 " for DOWNMIX_PARAM_TYPE", *pSize); return -EINVAL; } pValue16 = (int16_t *)pValue; *pValue16 = (int16_t) pDownmixer->type; *pSize = sizeof(int16_t); - ALOGV("Downmix_getParameter DOWNMIX_PARAM_TYPE is %d", *pValue16); + ALOGV("Downmix_getParameter DOWNMIX_PARAM_TYPE is %" PRId16, *pValue16); break; default: - ALOGE("Downmix_getParameter unknown parameter %d", param); + ALOGE("Downmix_getParameter unknown parameter %" PRId16, param); return -EINVAL; } diff --git a/media/libeffects/downmix/EffectDownmix.h b/media/libeffects/downmix/EffectDownmix.h index cb6b957..fcb3c9e 100644 --- a/media/libeffects/downmix/EffectDownmix.h +++ b/media/libeffects/downmix/EffectDownmix.h @@ -93,8 +93,8 @@ static int Downmix_GetDescriptor(effect_handle_t self, int Downmix_Init(downmix_module_t *pDwmModule); int Downmix_Configure(downmix_module_t *pDwmModule, effect_config_t *pConfig, bool init); int Downmix_Reset(downmix_object_t *pDownmixer, bool init); -int Downmix_setParameter(downmix_object_t *pDownmixer, int32_t param, size_t size, void *pValue); -int Downmix_getParameter(downmix_object_t *pDownmixer, int32_t param, size_t *pSize, void *pValue); +int Downmix_setParameter(downmix_object_t *pDownmixer, int32_t param, uint32_t size, void *pValue); +int Downmix_getParameter(downmix_object_t *pDownmixer, int32_t param, uint32_t *pSize, void *pValue); void Downmix_foldFromQuad(int16_t *pSrc, int16_t*pDst, size_t numFrames, bool accumulate); void Downmix_foldFromSurround(int16_t *pSrc, int16_t*pDst, size_t numFrames, bool accumulate); diff --git a/media/libeffects/factory/Android.mk b/media/libeffects/factory/Android.mk index 60a6ce5..a932af7 100644 --- a/media/libeffects/factory/Android.mk +++ b/media/libeffects/factory/Android.mk @@ -9,7 +9,6 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libcutils liblog -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES) LOCAL_MODULE:= libeffects LOCAL_SHARED_LIBRARIES += libdl diff --git a/media/libeffects/factory/EffectsFactory.c b/media/libeffects/factory/EffectsFactory.c index f8d6041..6d30d64 100644 --- a/media/libeffects/factory/EffectsFactory.c +++ b/media/libeffects/factory/EffectsFactory.c @@ -368,27 +368,21 @@ int EffectRelease(effect_handle_t handle) } if (e1 == NULL) { ret = -ENOENT; - pthread_mutex_unlock(&gLibLock); goto exit; } // release effect in library if (fx->lib == NULL) { ALOGW("EffectRelease() fx %p library already unloaded", handle); - pthread_mutex_unlock(&gLibLock); } else { pthread_mutex_lock(&fx->lib->lock); - // Releasing the gLibLock here as the list access is over as the - // effect is removed from the list. - // If the gLibLock is not released, we will have a deadlock situation - // since we call the sub effect release inside the EffectRelease of Proxy - pthread_mutex_unlock(&gLibLock); fx->lib->desc->release_effect(fx->subItfe); pthread_mutex_unlock(&fx->lib->lock); } free(fx); exit: + pthread_mutex_unlock(&gLibLock); return ret; } @@ -404,8 +398,8 @@ int EffectIsNullUuid(const effect_uuid_t *uuid) // is pointed by the first argument. It searches the gSubEffectList for the // matching uuid and then copies the corresponding sub effect descriptors // to the inout param -int EffectGetSubEffects(const effect_uuid_t *uuid, - effect_descriptor_t *pDescriptors, size_t size) +int EffectGetSubEffects(const effect_uuid_t *uuid, sub_effect_entry_t **pSube, + size_t size) { ALOGV("EffectGetSubEffects() UUID: %08X-%04X-%04X-%04X-%02X%02X%02X%02X%02X" "%02X\n",uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion, @@ -413,8 +407,7 @@ int EffectGetSubEffects(const effect_uuid_t *uuid, uuid->node[3],uuid->node[4],uuid->node[5]); // Check if the size of the desc buffer is large enough for 2 subeffects - if ((uuid == NULL) || (pDescriptors == NULL) || - (size < 2*sizeof(effect_descriptor_t))) { + if ((uuid == NULL) || (pSube == NULL) || (size < 2)) { ALOGW("NULL pointer or insufficient memory. Cannot query subeffects"); return -EINVAL; } @@ -432,11 +425,10 @@ int EffectGetSubEffects(const effect_uuid_t *uuid, list_elem_t *subefx = e->sub_elem; while (subefx != NULL) { subeffect = (sub_effect_entry_t*)subefx->object; - d = (effect_descriptor_t*)(subeffect->object); - pDescriptors[count++] = *d; + pSube[count++] = subeffect; subefx = subefx->next; } - ALOGV("EffectGetSubEffects end - copied the sub effect descriptors"); + ALOGV("EffectGetSubEffects end - copied the sub effect structures"); return count; } e = e->next; diff --git a/media/libeffects/factory/EffectsFactory.h b/media/libeffects/factory/EffectsFactory.h index 147ff18..560b485 100644 --- a/media/libeffects/factory/EffectsFactory.h +++ b/media/libeffects/factory/EffectsFactory.h @@ -20,7 +20,7 @@ #include <cutils/log.h> #include <pthread.h> #include <dirent.h> -#include <media/EffectsFactoryApi.h> +#include <hardware/audio_effect.h> #if __cplusplus extern "C" { @@ -66,6 +66,32 @@ typedef struct sub_effect_entry_s { void *object; } sub_effect_entry_t; + +//////////////////////////////////////////////////////////////////////////////// +// +// Function: EffectGetSubEffects +// +// Description: Returns the descriptors of the sub effects of the effect +// whose uuid is pointed to by first argument. +// +// Input: +// pEffectUuid: pointer to the effect uuid. +// size: max number of sub_effect_entry_t * in pSube. +// +// Input/Output: +// pSube: address where to return the sub effect structures. +// Output: +// returned value: 0 successful operation. +// -ENODEV factory failed to initialize +// -EINVAL invalid pEffectUuid or pDescriptor +// -ENOENT no effect with this uuid found +// *pDescriptor: updated with the sub effect descriptors. +// +//////////////////////////////////////////////////////////////////////////////// +int EffectGetSubEffects(const effect_uuid_t *pEffectUuid, + sub_effect_entry_t **pSube, + size_t size); + #if __cplusplus } // extern "C" #endif diff --git a/media/libeffects/loudness/Android.mk b/media/libeffects/loudness/Android.mk index dcb7b27..edf964e 100644 --- a/media/libeffects/loudness/Android.mk +++ b/media/libeffects/loudness/Android.mk @@ -14,7 +14,7 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libstlport -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx +LOCAL_MODULE_RELATIVE_PATH := soundfx LOCAL_MODULE:= libldnhncr LOCAL_C_INCLUDES := \ diff --git a/media/libeffects/loudness/EffectLoudnessEnhancer.cpp b/media/libeffects/loudness/EffectLoudnessEnhancer.cpp index 91ed677..3c2b320 100644 --- a/media/libeffects/loudness/EffectLoudnessEnhancer.cpp +++ b/media/libeffects/loudness/EffectLoudnessEnhancer.cpp @@ -453,13 +453,13 @@ const struct effect_interface_s gLEInterface = { // This is the only symbol that needs to be exported __attribute__ ((visibility ("default"))) audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = { - tag : AUDIO_EFFECT_LIBRARY_TAG, - version : EFFECT_LIBRARY_API_VERSION, - name : "Loudness Enhancer Library", - implementor : "The Android Open Source Project", - create_effect : LELib_Create, - release_effect : LELib_Release, - get_descriptor : LELib_GetDescriptor, + .tag = AUDIO_EFFECT_LIBRARY_TAG, + .version = EFFECT_LIBRARY_API_VERSION, + .name = "Loudness Enhancer Library", + .implementor = "The Android Open Source Project", + .create_effect = LELib_Create, + .release_effect = LELib_Release, + .get_descriptor = LELib_GetDescriptor, }; }; // extern "C" diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c index 32c4ce0..35e5bc8 100644 --- a/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c +++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c @@ -178,7 +178,7 @@ LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t *phInstance, { return(LVDBE_NULLADDRESS); } - if (((LVM_UINT32)pMemoryTable->Region[i].pBaseAddress % pMemoryTable->Region[i].Alignment)!=0){ + if (((uintptr_t)pMemoryTable->Region[i].pBaseAddress % pMemoryTable->Region[i].Alignment)!=0){ return(LVDBE_ALIGNMENTERROR); } } diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c index 794271b..f5a01f3 100644 --- a/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c +++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Process.c @@ -99,7 +99,7 @@ LVM_ReturnStatus_en LVM_Process(LVM_Handle_t hInstance, /* * Check the buffer alignment */ - if((((LVM_UINT32)pInData % 4) != 0) || (((LVM_UINT32)pOutData % 4) != 0)) + if((((uintptr_t)pInData % 4) != 0) || (((uintptr_t)pOutData % 4) != 0)) { return(LVM_ALIGNMENTERROR); } diff --git a/media/libeffects/lvm/lib/Common/lib/InstAlloc.h b/media/libeffects/lvm/lib/Common/lib/InstAlloc.h index c6954f2..7f725f4 100644 --- a/media/libeffects/lvm/lib/Common/lib/InstAlloc.h +++ b/media/libeffects/lvm/lib/Common/lib/InstAlloc.h @@ -29,7 +29,7 @@ extern "C" { typedef struct { LVM_UINT32 TotalSize; /* Accumulative total memory size */ - LVM_UINT32 pNextMember; /* Pointer to the next instance member to be allocated */ + uintptr_t pNextMember; /* Pointer to the next instance member to be allocated */ } INST_ALLOC; diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Types.h b/media/libeffects/lvm/lib/Common/lib/LVM_Types.h index 81655dd..0c6fb25 100644 --- a/media/libeffects/lvm/lib/Common/lib/LVM_Types.h +++ b/media/libeffects/lvm/lib/Common/lib/LVM_Types.h @@ -29,6 +29,7 @@ extern "C" { #endif /* __cplusplus */ +#include <stdint.h> /****************************************************************************************/ /* */ @@ -85,14 +86,14 @@ extern "C" { typedef char LVM_CHAR; /* ASCII character */ -typedef char LVM_INT8; /* Signed 8-bit word */ -typedef unsigned char LVM_UINT8; /* Unsigned 8-bit word */ +typedef int8_t LVM_INT8; /* Signed 8-bit word */ +typedef uint8_t LVM_UINT8; /* Unsigned 8-bit word */ -typedef short LVM_INT16; /* Signed 16-bit word */ -typedef unsigned short LVM_UINT16; /* Unsigned 16-bit word */ +typedef int16_t LVM_INT16; /* Signed 16-bit word */ +typedef uint16_t LVM_UINT16; /* Unsigned 16-bit word */ -typedef long LVM_INT32; /* Signed 32-bit word */ -typedef unsigned long LVM_UINT32; /* Unsigned 32-bit word */ +typedef int32_t LVM_INT32; /* Signed 32-bit word */ +typedef uint32_t LVM_UINT32; /* Unsigned 32-bit word */ /****************************************************************************************/ diff --git a/media/libeffects/lvm/lib/Common/src/InstAlloc.c b/media/libeffects/lvm/lib/Common/src/InstAlloc.c index 481df84..a89a5c3 100644 --- a/media/libeffects/lvm/lib/Common/src/InstAlloc.c +++ b/media/libeffects/lvm/lib/Common/src/InstAlloc.c @@ -30,7 +30,7 @@ void InstAlloc_Init( INST_ALLOC *pms, void *StartAddr ) { pms->TotalSize = 3; - pms->pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC);/* This code will fail if the platform address space is more than 32-bits*/ + pms->pNextMember = (((uintptr_t)StartAddr + 3) & (uintptr_t)~3); } @@ -51,7 +51,7 @@ void* InstAlloc_AddMember( INST_ALLOC *pms, void *NewMemberAddress; /* Variable to temporarily store the return value */ NewMemberAddress = (void*)pms->pNextMember; - Size = ((Size + 3) & 0xFFFFFFFC); /* Ceil the size to a multiple of four */ + Size = ((Size + 3) & (LVM_UINT32)~3); /* Ceil the size to a multiple of four */ pms->TotalSize += Size; pms->pNextMember += Size; @@ -84,30 +84,30 @@ LVM_UINT32 InstAlloc_GetTotal( INST_ALLOC *pms) void InstAlloc_InitAll( INST_ALLOC *pms, LVM_MemoryTable_st *pMemoryTable) { - LVM_UINT32 StartAddr; + uintptr_t StartAddr; - StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress; + StartAddr = (uintptr_t)pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress; pms[0].TotalSize = 3; - pms[0].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC); + pms[0].pNextMember = ((StartAddr + 3) & (uintptr_t)~3); - StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress; + StartAddr = (uintptr_t)pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress; pms[1].TotalSize = 3; - pms[1].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC); + pms[1].pNextMember = ((StartAddr + 3) & (uintptr_t)~3); - StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress; + StartAddr = (uintptr_t)pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress; pms[2].TotalSize = 3; - pms[2].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC); + pms[2].pNextMember = ((StartAddr + 3) & (uintptr_t)~3); - StartAddr = (LVM_UINT32)pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress; + StartAddr = (uintptr_t)pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress; pms[3].TotalSize = 3; - pms[3].pNextMember = (LVM_UINT32)(((LVM_UINT32)StartAddr + 3) & 0xFFFFFFFC); + pms[3].pNextMember = ((StartAddr + 3) & (uintptr_t)~3); } diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c index c4767a8..e01c1c5 100644 --- a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c +++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c @@ -25,6 +25,7 @@ #include "LVEQNB.h" #include "LVEQNB_Private.h" #include "InstAlloc.h" +#include <string.h> /* For memset */ /****************************************************************************************/ /* */ diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.c index ac3c740..58f58ed 100644 --- a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.c +++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Process.c @@ -77,7 +77,7 @@ LVEQNB_ReturnStatus_en LVEQNB_Process(LVEQNB_Handle_t hInstance, } /* Check if the input and output data buffers are 32-bit aligned */ - if ((((LVM_INT32)pInData % 4) != 0) || (((LVM_INT32)pOutData % 4) != 0)) + if ((((uintptr_t)pInData % 4) != 0) || (((uintptr_t)pOutData % 4) != 0)) { return LVEQNB_ALIGNMENTERROR; } diff --git a/media/libeffects/lvm/wrapper/Android.mk b/media/libeffects/lvm/wrapper/Android.mk index f1af389..68ba34c 100644 --- a/media/libeffects/lvm/wrapper/Android.mk +++ b/media/libeffects/lvm/wrapper/Android.mk @@ -13,7 +13,7 @@ LOCAL_CFLAGS += -fvisibility=hidden LOCAL_MODULE:= libbundlewrapper -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx +LOCAL_MODULE_RELATIVE_PATH := soundfx LOCAL_STATIC_LIBRARIES += libmusicbundle @@ -42,7 +42,7 @@ LOCAL_CFLAGS += -fvisibility=hidden LOCAL_MODULE:= libreverbwrapper -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx +LOCAL_MODULE_RELATIVE_PATH := soundfx LOCAL_STATIC_LIBRARIES += libreverb diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp index 28d239a..db5c78f 100644 --- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp +++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp @@ -138,22 +138,22 @@ void Effect_getConfig (EffectContext *pContext, effect_config_t *pConfi int BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue); int BassBoost_getParameter (EffectContext *pContext, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue); int Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValue); int Virtualizer_getParameter (EffectContext *pContext, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue); int Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue); int Equalizer_getParameter (EffectContext *pContext, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue); int Volume_setParameter (EffectContext *pContext, void *pParam, void *pValue); int Volume_getParameter (EffectContext *pContext, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue); int Effect_setEnabled(EffectContext *pContext, bool enabled); @@ -1758,7 +1758,7 @@ int32_t VolumeEnableStereoPosition(EffectContext *pContext, uint32_t enabled){ int BassBoost_getParameter(EffectContext *pContext, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue){ int status = 0; int32_t *pParamTemp = (int32_t *)pParam; @@ -1876,7 +1876,7 @@ int BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue) int Virtualizer_getParameter(EffectContext *pContext, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue){ int status = 0; int32_t *pParamTemp = (int32_t *)pParam; @@ -1994,7 +1994,7 @@ int Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValu //---------------------------------------------------------------------------- int Equalizer_getParameter(EffectContext *pContext, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue){ int status = 0; int bMute = 0; @@ -2252,7 +2252,7 @@ int Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue) int Volume_getParameter(EffectContext *pContext, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue){ int status = 0; int bMute = 0; @@ -2813,9 +2813,9 @@ int Effect_command(effect_handle_t self, if(pContext->EffectType == LVM_BASS_BOOST){ if (pCmdData == NULL || - cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || + cmdSize < (sizeof(effect_param_t) + sizeof(int32_t)) || pReplyData == NULL || - *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ + *replySize < (sizeof(effect_param_t) + sizeof(int32_t))){ ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " "EFFECT_CMD_GET_PARAM: ERROR"); return -EINVAL; @@ -2830,7 +2830,7 @@ int Effect_command(effect_handle_t self, p->status = android::BassBoost_getParameter(pContext, p->data, - (size_t *)&p->vsize, + &p->vsize, p->data + voffset); *replySize = sizeof(effect_param_t) + voffset + p->vsize; @@ -2844,9 +2844,9 @@ int Effect_command(effect_handle_t self, if(pContext->EffectType == LVM_VIRTUALIZER){ if (pCmdData == NULL || - cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || + cmdSize < (sizeof(effect_param_t) + sizeof(int32_t)) || pReplyData == NULL || - *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ + *replySize < (sizeof(effect_param_t) + sizeof(int32_t))){ ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " "EFFECT_CMD_GET_PARAM: ERROR"); return -EINVAL; @@ -2860,8 +2860,8 @@ int Effect_command(effect_handle_t self, int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); p->status = android::Virtualizer_getParameter(pContext, - (void *)p->data, - (size_t *)&p->vsize, + (void *)p->data, + &p->vsize, p->data + voffset); *replySize = sizeof(effect_param_t) + voffset + p->vsize; @@ -2876,7 +2876,7 @@ int Effect_command(effect_handle_t self, //ALOGV("\tEqualizer_command cmdCode Case: " // "EFFECT_CMD_GET_PARAM start"); if (pCmdData == NULL || - cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || + cmdSize < (sizeof(effect_param_t) + sizeof(int32_t)) || pReplyData == NULL || *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))) { ALOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " @@ -2908,7 +2908,7 @@ int Effect_command(effect_handle_t self, if(pContext->EffectType == LVM_VOLUME){ //ALOGV("\tVolume_command cmdCode Case: EFFECT_CMD_GET_PARAM start"); if (pCmdData == NULL || - cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || + cmdSize < (sizeof(effect_param_t) + sizeof(int32_t)) || pReplyData == NULL || *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ ALOGV("\tLVM_ERROR : Volume_command cmdCode Case: " @@ -2925,7 +2925,7 @@ int Effect_command(effect_handle_t self, p->status = android::Volume_getParameter(pContext, (void *)p->data, - (size_t *)&p->vsize, + &p->vsize, p->data + voffset); *replySize = sizeof(effect_param_t) + voffset + p->vsize; @@ -2947,7 +2947,7 @@ int Effect_command(effect_handle_t self, // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); if (pCmdData == NULL|| - cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| + cmdSize != (sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| pReplyData == NULL|| *replySize != sizeof(int32_t)){ ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " @@ -2980,7 +2980,7 @@ int Effect_command(effect_handle_t self, // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); if (pCmdData == NULL|| - cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| + cmdSize != (sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| pReplyData == NULL|| *replySize != sizeof(int32_t)){ ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " @@ -3014,7 +3014,7 @@ int Effect_command(effect_handle_t self, // *replySize, // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); - if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || + if (pCmdData == NULL || cmdSize < (sizeof(effect_param_t) + sizeof(int32_t)) || pReplyData == NULL || *replySize != sizeof(int32_t)) { ALOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " "EFFECT_CMD_SET_PARAM: ERROR"); @@ -3034,7 +3034,7 @@ int Effect_command(effect_handle_t self, // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) +sizeof(int32_t))); if ( pCmdData == NULL|| - cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t))|| + cmdSize < (sizeof(effect_param_t) + sizeof(int32_t))|| pReplyData == NULL|| *replySize != sizeof(int32_t)){ ALOGV("\tLVM_ERROR : Volume_command cmdCode Case: " diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp index 0367302..c6d3759 100644 --- a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp +++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp @@ -181,7 +181,7 @@ void Reverb_getConfig (ReverbContext *pContext, effect_config_t *pConfig); int Reverb_setParameter (ReverbContext *pContext, void *pParam, void *pValue); int Reverb_getParameter (ReverbContext *pContext, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue); int Reverb_LoadPreset (ReverbContext *pContext); @@ -1534,7 +1534,7 @@ int Reverb_LoadPreset(ReverbContext *pContext) int Reverb_getParameter(ReverbContext *pContext, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue){ int status = 0; int32_t *pParamTemp = (int32_t *)pParam; @@ -1956,9 +1956,9 @@ int Reverb_command(effect_handle_t self, //ALOGV("\tReverb_command cmdCode Case: " // "EFFECT_CMD_GET_PARAM start"); if (pCmdData == NULL || - cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || + cmdSize < (sizeof(effect_param_t) + sizeof(int32_t)) || pReplyData == NULL || - *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ + *replySize < (sizeof(effect_param_t) + sizeof(int32_t))){ ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: " "EFFECT_CMD_GET_PARAM: ERROR"); return -EINVAL; @@ -1973,7 +1973,7 @@ int Reverb_command(effect_handle_t self, p->status = android::Reverb_getParameter(pContext, (void *)p->data, - (size_t *)&p->vsize, + &p->vsize, p->data + voffset); *replySize = sizeof(effect_param_t) + voffset + p->vsize; @@ -1994,8 +1994,8 @@ int Reverb_command(effect_handle_t self, // *replySize, // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); - if (pCmdData == NULL || (cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t))) - || pReplyData == NULL || *replySize != (int)sizeof(int32_t)) { + if (pCmdData == NULL || (cmdSize < (sizeof(effect_param_t) + sizeof(int32_t))) + || pReplyData == NULL || *replySize != sizeof(int32_t)) { ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: " "EFFECT_CMD_SET_PARAM: ERROR"); return -EINVAL; diff --git a/media/libeffects/preprocessing/Android.mk b/media/libeffects/preprocessing/Android.mk index c344352..9e8cb83 100644 --- a/media/libeffects/preprocessing/Android.mk +++ b/media/libeffects/preprocessing/Android.mk @@ -5,7 +5,7 @@ include $(CLEAR_VARS) LOCAL_MODULE:= libaudiopreprocessing LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx +LOCAL_MODULE_RELATIVE_PATH := soundfx LOCAL_SRC_FILES:= \ PreProcessing.cpp diff --git a/media/libeffects/preprocessing/PreProcessing.cpp b/media/libeffects/preprocessing/PreProcessing.cpp index d72eaf5..a96a703 100644 --- a/media/libeffects/preprocessing/PreProcessing.cpp +++ b/media/libeffects/preprocessing/PreProcessing.cpp @@ -77,7 +77,7 @@ struct preproc_ops_s { void (* enable)(preproc_effect_t *fx); void (* disable)(preproc_effect_t *fx); int (* set_parameter)(preproc_effect_t *fx, void *param, void *value); - int (* get_parameter)(preproc_effect_t *fx, void *param, size_t *size, void *value); + int (* get_parameter)(preproc_effect_t *fx, void *param, uint32_t *size, void *value); int (* set_device)(preproc_effect_t *fx, uint32_t device); }; @@ -291,7 +291,7 @@ int AgcCreate(preproc_effect_t *effect) int AgcGetParameter(preproc_effect_t *effect, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue) { int status = 0; @@ -452,9 +452,9 @@ int AecCreate(preproc_effect_t *effect) return 0; } -int AecGetParameter(preproc_effect_t *effect, +int AecGetParameter(preproc_effect_t *effect, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue) { int status = 0; @@ -575,9 +575,9 @@ int NsCreate(preproc_effect_t *effect) return 0; } -int NsGetParameter(preproc_effect_t *effect, +int NsGetParameter(preproc_effect_t *effect, void *pParam, - size_t *pValueSize, + uint32_t *pValueSize, void *pValue) { int status = 0; @@ -1233,8 +1233,8 @@ int PreProcessingFx_Process(effect_handle_t self, if (session->framesIn < session->frameCount) { return 0; } - size_t frIn = session->framesIn; - size_t frOut = session->apmFrameCount; + spx_uint32_t frIn = session->framesIn; + spx_uint32_t frOut = session->apmFrameCount; if (session->inChannelCount == 1) { speex_resampler_process_int(session->inResampler, 0, @@ -1290,8 +1290,8 @@ int PreProcessingFx_Process(effect_handle_t self, } if (session->outResampler != NULL) { - size_t frIn = session->apmFrameCount; - size_t frOut = session->frameCount; + spx_uint32_t frIn = session->apmFrameCount; + spx_uint32_t frOut = session->frameCount; if (session->inChannelCount == 1) { speex_resampler_process_int(session->outResampler, 0, @@ -1453,7 +1453,7 @@ int PreProcessingFx_Command(effect_handle_t self, if (effect->ops->get_parameter) { p->status = effect->ops->get_parameter(effect, p->data, - (size_t *)&p->vsize, + &p->vsize, p->data + voffset); *replySize = sizeof(effect_param_t) + voffset + p->vsize; } @@ -1754,8 +1754,8 @@ int PreProcessingFx_ProcessReverse(effect_handle_t self, if (session->framesRev < session->frameCount) { return 0; } - size_t frIn = session->framesRev; - size_t frOut = session->apmFrameCount; + spx_uint32_t frIn = session->framesRev; + spx_uint32_t frOut = session->apmFrameCount; if (session->inChannelCount == 1) { speex_resampler_process_int(session->revResampler, 0, diff --git a/media/libeffects/proxy/Android.mk b/media/libeffects/proxy/Android.mk index 01b3be1..b438796 100644 --- a/media/libeffects/proxy/Android.mk +++ b/media/libeffects/proxy/Android.mk @@ -15,7 +15,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:= libeffectproxy -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx +LOCAL_MODULE_RELATIVE_PATH := soundfx LOCAL_MODULE_TAGS := optional @@ -28,7 +28,8 @@ LOCAL_SHARED_LIBRARIES := liblog libcutils libutils libdl libeffects LOCAL_C_INCLUDES := \ system/media/audio_effects/include \ - bionic/libc/include + bionic/libc/include \ + frameworks/av/media/libeffects/factory include $(BUILD_SHARED_LIBRARY) diff --git a/media/libeffects/proxy/EffectProxy.cpp b/media/libeffects/proxy/EffectProxy.cpp index dd4ad08..62d3fd3 100644 --- a/media/libeffects/proxy/EffectProxy.cpp +++ b/media/libeffects/proxy/EffectProxy.cpp @@ -56,6 +56,8 @@ int EffectProxyCreate(const effect_uuid_t *uuid, effect_handle_t *pHandle) { effect_descriptor_t* desc; + audio_effect_library_t** aeli; + sub_effect_entry_t** sube; EffectContext* pContext; if (pHandle == NULL || uuid == NULL) { ALOGE("EffectProxyCreate() called with NULL pointer"); @@ -74,31 +76,52 @@ int EffectProxyCreate(const effect_uuid_t *uuid, // Get the HW and SW sub effect descriptors from the effects factory desc = new effect_descriptor_t[SUB_FX_COUNT]; + aeli = new audio_effect_library_t*[SUB_FX_COUNT]; + sube = new sub_effect_entry_t*[SUB_FX_COUNT]; + pContext->sube = new sub_effect_entry_t*[SUB_FX_COUNT]; pContext->desc = new effect_descriptor_t[SUB_FX_COUNT]; - int retValue = EffectGetSubEffects(uuid, desc, - sizeof(effect_descriptor_t) * SUB_FX_COUNT); + pContext->aeli = new audio_effect_library_t*[SUB_FX_COUNT]; + int retValue = EffectGetSubEffects(uuid, sube, SUB_FX_COUNT); // EffectGetSubEffects returns the number of sub-effects copied. if (retValue != SUB_FX_COUNT) { ALOGE("EffectCreate() could not get the sub effects"); - delete desc; - delete pContext->desc; + delete[] sube; + delete[] desc; + delete[] aeli; + delete[] pContext->sube; + delete[] pContext->desc; + delete[] pContext->aeli; return -EINVAL; } // Check which is the HW descriptor and copy the descriptors // to the Context desc array // Also check if there is only one HW and one SW descriptor. // HW descriptor alone has the HW_TUNNEL flag. + desc[0] = *(effect_descriptor_t*)(sube[0])->object; + desc[1] = *(effect_descriptor_t*)(sube[1])->object; + aeli[0] = sube[0]->lib->desc; + aeli[1] = sube[1]->lib->desc; if ((desc[0].flags & EFFECT_FLAG_HW_ACC_TUNNEL) && !(desc[1].flags & EFFECT_FLAG_HW_ACC_TUNNEL)) { + pContext->sube[SUB_FX_OFFLOAD] = sube[0]; pContext->desc[SUB_FX_OFFLOAD] = desc[0]; + pContext->aeli[SUB_FX_OFFLOAD] = aeli[0]; + pContext->sube[SUB_FX_HOST] = sube[1]; pContext->desc[SUB_FX_HOST] = desc[1]; + pContext->aeli[SUB_FX_HOST] = aeli[1]; } else if ((desc[1].flags & EFFECT_FLAG_HW_ACC_TUNNEL) && !(desc[0].flags & EFFECT_FLAG_HW_ACC_TUNNEL)) { + pContext->sube[SUB_FX_HOST] = sube[0]; pContext->desc[SUB_FX_HOST] = desc[0]; + pContext->aeli[SUB_FX_HOST] = aeli[0]; + pContext->sube[SUB_FX_OFFLOAD] = sube[1]; pContext->desc[SUB_FX_OFFLOAD] = desc[1]; + pContext->aeli[SUB_FX_OFFLOAD] = aeli[1]; } - delete desc; + delete[] desc; + delete[] aeli; + delete[] sube; #if (LOG_NDEBUG == 0) effect_uuid_t uuid_print = pContext->desc[SUB_FX_HOST].uuid; ALOGV("EffectCreate() UUID of HOST: %08X-%04X-%04X-%04X-%02X%02X%02X%02X" @@ -128,13 +151,15 @@ int EffectProxyRelease(effect_handle_t handle) { return -EINVAL; } ALOGV("EffectRelease"); - delete pContext->desc; + delete[] pContext->desc; free(pContext->replyData); if (pContext->eHandle[SUB_FX_HOST]) - EffectRelease(pContext->eHandle[SUB_FX_HOST]); + pContext->aeli[SUB_FX_HOST]->release_effect(pContext->eHandle[SUB_FX_HOST]); if (pContext->eHandle[SUB_FX_OFFLOAD]) - EffectRelease(pContext->eHandle[SUB_FX_OFFLOAD]); + pContext->aeli[SUB_FX_OFFLOAD]->release_effect(pContext->eHandle[SUB_FX_OFFLOAD]); + delete[] pContext->aeli; + delete[] pContext->sube; delete pContext; pContext = NULL; return 0; @@ -187,7 +212,8 @@ int Effect_command(effect_handle_t self, } if (pContext->eHandle[SUB_FX_HOST] == NULL) { ALOGV("Effect_command() Calling HOST EffectCreate"); - status = EffectCreate(&pContext->desc[SUB_FX_HOST].uuid, + status = pContext->aeli[SUB_FX_HOST]->create_effect( + &pContext->desc[SUB_FX_HOST].uuid, pContext->sessionId, pContext->ioId, &(pContext->eHandle[SUB_FX_HOST])); if (status != NO_ERROR || (pContext->eHandle[SUB_FX_HOST] == NULL)) { @@ -197,11 +223,13 @@ int Effect_command(effect_handle_t self, } if (pContext->eHandle[SUB_FX_OFFLOAD] == NULL) { ALOGV("Effect_command() Calling OFFLOAD EffectCreate"); - status = EffectCreate(&pContext->desc[SUB_FX_OFFLOAD].uuid, + status = pContext->aeli[SUB_FX_OFFLOAD]->create_effect( + &pContext->desc[SUB_FX_OFFLOAD].uuid, pContext->sessionId, pContext->ioId, &(pContext->eHandle[SUB_FX_OFFLOAD])); if (status != NO_ERROR || (pContext->eHandle[SUB_FX_OFFLOAD] == NULL)) { ALOGV("Effect_command() Error creating HW effect"); + pContext->eHandle[SUB_FX_OFFLOAD] = NULL; // Do not return error here as SW effect is created // Return error if the CMD_OFFLOAD sends the index as OFFLOAD } @@ -233,11 +261,17 @@ int Effect_command(effect_handle_t self, // Update the DSP wrapper with the new ioHandle. // Pass the OFFLOAD command to the wrapper. // The DSP wrapper needs to handle this CMD - if (pContext->eHandle[SUB_FX_OFFLOAD]) - status = (*pContext->eHandle[SUB_FX_OFFLOAD])->command( - pContext->eHandle[SUB_FX_OFFLOAD], cmdCode, cmdSize, - pCmdData, replySize, pReplyData); - return status; + if (pContext->eHandle[SUB_FX_OFFLOAD]) { + ALOGV("Effect_command: Calling OFFLOAD command"); + return (*pContext->eHandle[SUB_FX_OFFLOAD])->command( + pContext->eHandle[SUB_FX_OFFLOAD], cmdCode, cmdSize, + pCmdData, replySize, pReplyData); + } + *(int*)pReplyData = NO_ERROR; + ALOGV("Effect_command OFFLOAD return 0, replyData %d", + *(int*)pReplyData); + + return NO_ERROR; } int index = pContext->index; @@ -329,11 +363,11 @@ int Effect_getDescriptor(effect_handle_t self, __attribute__ ((visibility ("default"))) audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = { - tag : AUDIO_EFFECT_LIBRARY_TAG, - version : EFFECT_LIBRARY_API_VERSION, - name : "Effect Proxy", - implementor : "AOSP", - create_effect : android::EffectProxyCreate, - release_effect : android::EffectProxyRelease, - get_descriptor : android::EffectProxyGetDescriptor, + .tag = AUDIO_EFFECT_LIBRARY_TAG, + .version = EFFECT_LIBRARY_API_VERSION, + .name = "Effect Proxy", + .implementor = "AOSP", + .create_effect = android::EffectProxyCreate, + .release_effect = android::EffectProxyRelease, + .get_descriptor = android::EffectProxyGetDescriptor, }; diff --git a/media/libeffects/proxy/EffectProxy.h b/media/libeffects/proxy/EffectProxy.h index acbe17e..046b93e 100644 --- a/media/libeffects/proxy/EffectProxy.h +++ b/media/libeffects/proxy/EffectProxy.h @@ -16,6 +16,8 @@ #include <hardware/audio.h> #include <hardware/audio_effect.h> +#include "EffectsFactory.h" + namespace android { enum { SUB_FX_HOST, // Index of HOST in the descriptor and handle arrays @@ -62,7 +64,9 @@ const struct effect_interface_s gEffectInterface = { struct EffectContext { const struct effect_interface_s *common_itfe; // Holds the itfe of the Proxy + sub_effect_entry_t** sube; // Points to the sub effects effect_descriptor_t* desc; // Points to the sub effect descriptors + audio_effect_library_t** aeli; // Points to the sub effect aeli effect_handle_t eHandle[SUB_FX_COUNT]; // The effect handles of the sub effects int index; // The index that is currently active - HOST or OFFLOAD int32_t sessionId; // The sessiond in which the effect is created. diff --git a/media/libeffects/testlibs/Android.mk_ b/media/libeffects/testlibs/Android.mk_ index 2954908..672ebba 100644 --- a/media/libeffects/testlibs/Android.mk_ +++ b/media/libeffects/testlibs/Android.mk_ @@ -11,7 +11,7 @@ LOCAL_CFLAGS+= -O2 LOCAL_SHARED_LIBRARIES := \ libcutils -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx +LOCAL_MODULE_RELATIVE_PATH := soundfx LOCAL_MODULE:= libreverbtest ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true) @@ -47,7 +47,7 @@ LOCAL_CFLAGS+= -O2 LOCAL_SHARED_LIBRARIES := \ libcutils -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx +LOCAL_MODULE_RELATIVE_PATH := soundfx LOCAL_MODULE:= libequalizertest ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true) diff --git a/media/libeffects/testlibs/EffectEqualizer.cpp b/media/libeffects/testlibs/EffectEqualizer.cpp index 8d00206..3cb13f2 100644 --- a/media/libeffects/testlibs/EffectEqualizer.cpp +++ b/media/libeffects/testlibs/EffectEqualizer.cpp @@ -115,7 +115,7 @@ struct EqualizerContext { int Equalizer_init(EqualizerContext *pContext); int Equalizer_setConfig(EqualizerContext *pContext, effect_config_t *pConfig); -int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t *pValueSize, void *pValue); +int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, uint32_t *pValueSize, void *pValue); int Equalizer_setParameter(AudioEqualizer * pEqualizer, int32_t *pParam, void *pValue); @@ -360,7 +360,7 @@ int Equalizer_init(EqualizerContext *pContext) // //---------------------------------------------------------------------------- -int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t *pValueSize, void *pValue) +int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, uint32_t *pValueSize, void *pValue) { int status = 0; int32_t param = *pParam++; @@ -662,8 +662,8 @@ extern "C" int Equalizer_command(effect_handle_t self, uint32_t cmdCode, uint32_ Equalizer_setConfig(pContext, &pContext->config); break; case EFFECT_CMD_GET_PARAM: { - if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || - pReplyData == NULL || *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))) { + if (pCmdData == NULL || cmdSize < (sizeof(effect_param_t) + sizeof(int32_t)) || + pReplyData == NULL || *replySize < (sizeof(effect_param_t) + sizeof(int32_t))) { return -EINVAL; } effect_param_t *p = (effect_param_t *)pCmdData; @@ -682,7 +682,7 @@ extern "C" int Equalizer_command(effect_handle_t self, uint32_t cmdCode, uint32_ case EFFECT_CMD_SET_PARAM: { ALOGV("Equalizer_command EFFECT_CMD_SET_PARAM cmdSize %d pCmdData %p, *replySize %d, pReplyData %p", cmdSize, pCmdData, *replySize, pReplyData); - if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || + if (pCmdData == NULL || cmdSize < (sizeof(effect_param_t) + sizeof(int32_t)) || pReplyData == NULL || *replySize != sizeof(int32_t)) { return -EINVAL; } diff --git a/media/libeffects/testlibs/EffectReverb.c b/media/libeffects/testlibs/EffectReverb.c index c37f392..f056d19 100644 --- a/media/libeffects/testlibs/EffectReverb.c +++ b/media/libeffects/testlibs/EffectReverb.c @@ -750,7 +750,7 @@ void Reverb_Reset(reverb_object_t *pReverb, bool init) { * *---------------------------------------------------------------------------- */ -int Reverb_getParameter(reverb_object_t *pReverb, int32_t param, size_t *pSize, +int Reverb_getParameter(reverb_object_t *pReverb, int32_t param, uint32_t *pSize, void *pValue) { int32_t *pValue32; int16_t *pValue16; @@ -758,7 +758,7 @@ int Reverb_getParameter(reverb_object_t *pReverb, int32_t param, size_t *pSize, int32_t i; int32_t temp; int32_t temp2; - size_t size; + uint32_t size; if (pReverb->m_Preset) { if (param != REVERB_PARAM_PRESET || *pSize < sizeof(int16_t)) { @@ -1033,7 +1033,7 @@ int Reverb_getParameter(reverb_object_t *pReverb, int32_t param, size_t *pSize, * *---------------------------------------------------------------------------- */ -int Reverb_setParameter(reverb_object_t *pReverb, int32_t param, size_t size, +int Reverb_setParameter(reverb_object_t *pReverb, int32_t param, uint32_t size, void *pValue) { int32_t value32; int16_t value16; @@ -1044,7 +1044,7 @@ int Reverb_setParameter(reverb_object_t *pReverb, int32_t param, size_t size, reverb_preset_t *pPreset; int maxSamples; int32_t averageDelay; - size_t paramSize; + uint32_t paramSize; ALOGV("Reverb_setParameter, context %p, param %d, value16 %d, value32 %d", pReverb, param, *(int16_t *)pValue, *(int32_t *)pValue); diff --git a/media/libeffects/testlibs/EffectReverb.h b/media/libeffects/testlibs/EffectReverb.h index e5248fe..756c5ea 100644 --- a/media/libeffects/testlibs/EffectReverb.h +++ b/media/libeffects/testlibs/EffectReverb.h @@ -330,8 +330,8 @@ int Reverb_setConfig(reverb_module_t *pRvbModule, effect_config_t *pConfig, bool void Reverb_getConfig(reverb_module_t *pRvbModule, effect_config_t *pConfig); void Reverb_Reset(reverb_object_t *pReverb, bool init); -int Reverb_setParameter (reverb_object_t *pReverb, int32_t param, size_t size, void *pValue); -int Reverb_getParameter(reverb_object_t *pReverb, int32_t param, size_t *pSize, void *pValue); +int Reverb_setParameter (reverb_object_t *pReverb, int32_t param, uint32_t size, void *pValue); +int Reverb_getParameter(reverb_object_t *pReverb, int32_t param, uint32_t *pSize, void *pValue); /*---------------------------------------------------------------------------- * ReverbUpdateXfade diff --git a/media/libeffects/visualizer/Android.mk b/media/libeffects/visualizer/Android.mk index e196eb2..dd2d306 100644 --- a/media/libeffects/visualizer/Android.mk +++ b/media/libeffects/visualizer/Android.mk @@ -13,7 +13,7 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libdl -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx +LOCAL_MODULE_RELATIVE_PATH := soundfx LOCAL_MODULE:= libvisualizer LOCAL_C_INCLUDES := \ diff --git a/media/libeffects/visualizer/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp index 2d66eef..47cab62 100644 --- a/media/libeffects/visualizer/EffectVisualizer.cpp +++ b/media/libeffects/visualizer/EffectVisualizer.cpp @@ -16,8 +16,9 @@ #define LOG_TAG "EffectVisualizer" //#define LOG_NDEBUG 0 -#include <cutils/log.h> +#include <log/log.h> #include <assert.h> +#include <inttypes.h> #include <stdlib.h> #include <string.h> #include <new> @@ -226,8 +227,8 @@ int Visualizer_init(VisualizerContext *pContext) // int VisualizerLib_Create(const effect_uuid_t *uuid, - int32_t sessionId, - int32_t ioId, + int32_t /*sessionId*/, + int32_t /*ioId*/, effect_handle_t *pHandle) { int ret; int i; @@ -418,7 +419,7 @@ int Visualizer_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, return -EINVAL; } -// ALOGV("Visualizer_command command %d cmdSize %d",cmdCode, cmdSize); +// ALOGV("Visualizer_command command %" PRIu32 " cmdSize %" PRIu32, cmdCode, cmdSize); switch (cmdCode) { case EFFECT_CMD_INIT: @@ -484,19 +485,19 @@ int Visualizer_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, } switch (*(uint32_t *)p->data) { case VISUALIZER_PARAM_CAPTURE_SIZE: - ALOGV("get mCaptureSize = %d", pContext->mCaptureSize); + ALOGV("get mCaptureSize = %" PRIu32, pContext->mCaptureSize); *((uint32_t *)p->data + 1) = pContext->mCaptureSize; p->vsize = sizeof(uint32_t); *replySize += sizeof(uint32_t); break; case VISUALIZER_PARAM_SCALING_MODE: - ALOGV("get mScalingMode = %d", pContext->mScalingMode); + ALOGV("get mScalingMode = %" PRIu32, pContext->mScalingMode); *((uint32_t *)p->data + 1) = pContext->mScalingMode; p->vsize = sizeof(uint32_t); *replySize += sizeof(uint32_t); break; case VISUALIZER_PARAM_MEASUREMENT_MODE: - ALOGV("get mMeasurementMode = %d", pContext->mMeasurementMode); + ALOGV("get mMeasurementMode = %" PRIu32, pContext->mMeasurementMode); *((uint32_t *)p->data + 1) = pContext->mMeasurementMode; p->vsize = sizeof(uint32_t); *replySize += sizeof(uint32_t); @@ -520,19 +521,19 @@ int Visualizer_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, switch (*(uint32_t *)p->data) { case VISUALIZER_PARAM_CAPTURE_SIZE: pContext->mCaptureSize = *((uint32_t *)p->data + 1); - ALOGV("set mCaptureSize = %d", pContext->mCaptureSize); + ALOGV("set mCaptureSize = %" PRIu32, pContext->mCaptureSize); break; case VISUALIZER_PARAM_SCALING_MODE: pContext->mScalingMode = *((uint32_t *)p->data + 1); - ALOGV("set mScalingMode = %d", pContext->mScalingMode); + ALOGV("set mScalingMode = %" PRIu32, pContext->mScalingMode); break; case VISUALIZER_PARAM_LATENCY: pContext->mLatency = *((uint32_t *)p->data + 1); - ALOGV("set mLatency = %d", pContext->mLatency); + ALOGV("set mLatency = %" PRIu32, pContext->mLatency); break; case VISUALIZER_PARAM_MEASUREMENT_MODE: pContext->mMeasurementMode = *((uint32_t *)p->data + 1); - ALOGV("set mMeasurementMode = %d", pContext->mMeasurementMode); + ALOGV("set mMeasurementMode = %" PRIu32, pContext->mMeasurementMode); break; default: *(int32_t *)pReplyData = -EINVAL; @@ -544,56 +545,57 @@ int Visualizer_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, break; - case VISUALIZER_CMD_CAPTURE: - if (pReplyData == NULL || *replySize != pContext->mCaptureSize) { - ALOGV("VISUALIZER_CMD_CAPTURE() error *replySize %d pContext->mCaptureSize %d", - *replySize, pContext->mCaptureSize); + case VISUALIZER_CMD_CAPTURE: { + uint32_t captureSize = pContext->mCaptureSize; + if (pReplyData == NULL || *replySize != captureSize) { + ALOGV("VISUALIZER_CMD_CAPTURE() error *replySize %" PRIu32 " captureSize %" PRIu32, + *replySize, captureSize); return -EINVAL; } if (pContext->mState == VISUALIZER_STATE_ACTIVE) { - int32_t latencyMs = pContext->mLatency; const uint32_t deltaMs = Visualizer_getDeltaTimeMsFromUpdatedTime(pContext); - latencyMs -= deltaMs; - if (latencyMs < 0) { - latencyMs = 0; - } - const uint32_t deltaSmpl = pContext->mConfig.inputCfg.samplingRate * latencyMs / 1000; - - int32_t capturePoint = pContext->mCaptureIdx - pContext->mCaptureSize - deltaSmpl; - int32_t captureSize = pContext->mCaptureSize; - if (capturePoint < 0) { - int32_t size = -capturePoint; - if (size > captureSize) { - size = captureSize; - } - memcpy(pReplyData, - pContext->mCaptureBuf + CAPTURE_BUF_SIZE + capturePoint, - size); - pReplyData = (char *)pReplyData + size; - captureSize -= size; - capturePoint = 0; - } - memcpy(pReplyData, - pContext->mCaptureBuf + capturePoint, - captureSize); - // if audio framework has stopped playing audio although the effect is still // active we must clear the capture buffer to return silence if ((pContext->mLastCaptureIdx == pContext->mCaptureIdx) && - (pContext->mBufferUpdateTime.tv_sec != 0)) { - if (deltaMs > MAX_STALL_TIME_MS) { + (pContext->mBufferUpdateTime.tv_sec != 0) && + (deltaMs > MAX_STALL_TIME_MS)) { ALOGV("capture going to idle"); pContext->mBufferUpdateTime.tv_sec = 0; - memset(pReplyData, 0x80, pContext->mCaptureSize); + memset(pReplyData, 0x80, captureSize); + } else { + int32_t latencyMs = pContext->mLatency; + latencyMs -= deltaMs; + if (latencyMs < 0) { + latencyMs = 0; } + const uint32_t deltaSmpl = + pContext->mConfig.inputCfg.samplingRate * latencyMs / 1000; + int32_t capturePoint = pContext->mCaptureIdx - captureSize - deltaSmpl; + + if (capturePoint < 0) { + uint32_t size = -capturePoint; + if (size > captureSize) { + size = captureSize; + } + memcpy(pReplyData, + pContext->mCaptureBuf + CAPTURE_BUF_SIZE + capturePoint, + size); + pReplyData = (char *)pReplyData + size; + captureSize -= size; + capturePoint = 0; + } + memcpy(pReplyData, + pContext->mCaptureBuf + capturePoint, + captureSize); } + pContext->mLastCaptureIdx = pContext->mCaptureIdx; } else { - memset(pReplyData, 0x80, pContext->mCaptureSize); + memset(pReplyData, 0x80, captureSize); } - break; + } break; case VISUALIZER_CMD_MEASURE: { uint16_t peakU16 = 0; @@ -603,7 +605,7 @@ int Visualizer_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, // measurements aren't relevant anymore and shouldn't bias the new one) const int32_t delayMs = Visualizer_getDeltaTimeMsFromUpdatedTime(pContext); if (delayMs > DISCARD_MEASUREMENTS_TIME_MS) { - ALOGV("Discarding measurements, last measurement is %dms old", delayMs); + ALOGV("Discarding measurements, last measurement is %" PRId32 "ms old", delayMs); for (uint32_t i=0 ; i<pContext->mMeasurementWindowSizeInBuffers ; i++) { pContext->mPastMeasurements[i].mIsValid = false; pContext->mPastMeasurements[i].mPeakU16 = 0; @@ -637,14 +639,14 @@ int Visualizer_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, } else { pIntReplyData[MEASUREMENT_IDX_PEAK] = (int32_t) (2000 * log10(peakU16 / 32767.0f)); } - ALOGV("VISUALIZER_CMD_MEASURE peak=%d (%dmB), rms=%.1f (%dmB)", + ALOGV("VISUALIZER_CMD_MEASURE peak=%" PRIu16 " (%" PRId32 "mB), rms=%.1f (%" PRId32 "mB)", peakU16, pIntReplyData[MEASUREMENT_IDX_PEAK], rms, pIntReplyData[MEASUREMENT_IDX_RMS]); } break; default: - ALOGW("Visualizer_command invalid command %d",cmdCode); + ALOGW("Visualizer_command invalid command %" PRIu32, cmdCode); return -EINVAL; } |