summaryrefslogtreecommitdiffstats
path: root/media/libeffects
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2011-05-17 19:16:02 -0700
committerEric Laurent <elaurent@google.com>2011-05-27 15:15:00 -0700
commit0fb66c2b83084a16989afaf949d0101cb6505398 (patch)
tree82955066a3cd98e23ecfb4b33ba0beec715331d2 /media/libeffects
parent03edf6b36469a504bd17a5010c788c8d4e44085c (diff)
downloadframeworks_base-0fb66c2b83084a16989afaf949d0101cb6505398.zip
frameworks_base-0fb66c2b83084a16989afaf949d0101cb6505398.tar.gz
frameworks_base-0fb66c2b83084a16989afaf949d0101cb6505398.tar.bz2
New effect library API
Moved and renamed media/EffectApi.h to hardware/audio_effect.h Modified the effect library API to expose a library info structure containing an interface functions table. Also removed enums for audio channels, audio format and devices from effect API and use values from system/audio.h instead. Modified effects factory to support new library interface format and load libraries and efffects listed in audio_effects.conf file. The file audio_effects.conf is first loaded from /vendor/etc and then from /system/etc/audio_effects.conf if not found. Modified existing effect libraries to implement the new library interface. Change-Id: Ie52351e071b6d352fa2fbc06c3846686f8c45df9
Diffstat (limited to 'media/libeffects')
-rw-r--r--media/libeffects/data/audio_effects.conf57
-rw-r--r--media/libeffects/factory/EffectsFactory.c479
-rw-r--r--media/libeffects/factory/EffectsFactory.h18
-rw-r--r--media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp133
-rwxr-xr-xmedia/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp125
-rw-r--r--media/libeffects/testlibs/Android.mk_4
-rw-r--r--media/libeffects/testlibs/AudioFormatAdapter.h8
-rw-r--r--media/libeffects/testlibs/EffectEqualizer.cpp117
-rw-r--r--media/libeffects/testlibs/EffectReverb.c122
-rw-r--r--media/libeffects/testlibs/EffectReverb.h15
-rw-r--r--media/libeffects/visualizer/EffectVisualizer.cpp113
11 files changed, 812 insertions, 379 deletions
diff --git a/media/libeffects/data/audio_effects.conf b/media/libeffects/data/audio_effects.conf
new file mode 100644
index 0000000..e6a7b37
--- /dev/null
+++ b/media/libeffects/data/audio_effects.conf
@@ -0,0 +1,57 @@
+# List of effect libraries to load. Each library element must contain a "path" element
+# giving the full path of the library .so file.
+libraries {
+ bundle {
+ path /system/lib/soundfx/libbundlewrapper.so
+ }
+ reverb {
+ path /system/lib/soundfx/libreverbwrapper.so
+ }
+ visualizer {
+ path /system/lib/soundfx/libvisualizer.so
+ }
+}
+
+# list of effects to load. Each effect element must contain a "library" and a "uuid" element.
+# The value of the "library" element must correspond to the name of one library element in the
+# "libraries" element.
+# The name of the effect element is indicative, only the value of the "uuid" element
+# designates the effect.
+effects {
+ bassboost {
+ library bundle
+ uuid 8631f300-72e2-11df-b57e-0002a5d5c51b
+ }
+ virtualizer {
+ library bundle
+ uuid 1d4033c0-8557-11df-9f2d-0002a5d5c51b
+ }
+ equalizer {
+ library bundle
+ uuid ce772f20-847d-11df-bb17-0002a5d5c51b
+ }
+ volume {
+ library bundle
+ uuid 119341a0-8469-11df-81f9- 0002a5d5c51b
+ }
+ reverb_env_aux {
+ library reverb
+ uuid 4a387fc0-8ab3-11df-8bad- 0002a5d5c51b
+ }
+ reverb_env_ins {
+ library reverb
+ uuid c7a511a0-a3bb-11df-860e-0002a5d5c51b
+ }
+ reverb_pre_aux {
+ library reverb
+ uuid f29a1400-a3bb-11df-8ddc-0002a5d5c51b
+ }
+ reverb_pre_ins {
+ library reverb
+ uuid 172cdf00-a3bc-11df-a72f-0002a5d5c51b
+ }
+ visualizer {
+ library visualizer
+ uuid d069d9e0-8329-11df-9168-0002a5d5c51b
+ }
+}
diff --git a/media/libeffects/factory/EffectsFactory.c b/media/libeffects/factory/EffectsFactory.c
index c19a505..b541be5 100644
--- a/media/libeffects/factory/EffectsFactory.c
+++ b/media/libeffects/factory/EffectsFactory.c
@@ -22,6 +22,8 @@
#include <stdlib.h>
#include <dlfcn.h>
+#include <cutils/misc.h>
+#include <cutils/config_utils.h>
static list_elem_t *gEffectList; // list of effect_entry_t: all currently created effects
static list_elem_t *gLibraryList; // list of lib_entry_t: all currently loaded libraries
@@ -30,30 +32,39 @@ static uint32_t gNumEffects; // total number number of effects
static list_elem_t *gCurLib; // current library in enumeration process
static list_elem_t *gCurEffect; // current effect in enumeration process
static uint32_t gCurEffectIdx; // current effect index in enumeration process
+static lib_entry_t *gCachedLibrary; // last library accessed by getLibrary()
-const char * const gEffectLibPath = "/system/lib/soundfx"; // path to built-in effect libraries
static int gInitDone; // true is global initialization has been preformed
-static int gNextLibId; // used by loadLibrary() to allocate unique library handles
static int gCanQueryEffect; // indicates that call to EffectQueryEffect() is valid, i.e. that the list of effects
// was not modified since last call to EffectQueryNumberEffects()
+
/////////////////////////////////////////////////
// Local functions prototypes
/////////////////////////////////////////////////
static int init();
-static int loadLibrary(const char *libPath, int *handle);
-static int unloadLibrary(int handle);
+static int loadEffectConfigFile(const char *path);
+static int loadLibraries(cnode *root);
+static int loadLibrary(cnode *root, const char *name);
+static int loadEffects(cnode *root);
+static int loadEffect(cnode *node);
+static lib_entry_t *getLibrary(const char *path);
static void resetEffectEnumeration();
static uint32_t updateNumEffects();
-static int findEffect(effect_uuid_t *uuid, lib_entry_t **lib, effect_descriptor_t **desc);
+static int findEffect(effect_uuid_t *type,
+ effect_uuid_t *uuid,
+ lib_entry_t **lib,
+ effect_descriptor_t **desc);
static void dumpEffectDescriptor(effect_descriptor_t *desc, char *str, size_t len);
+static int stringToUuid(const char *str, effect_uuid_t *uuid);
+static int uuidToString(const effect_uuid_t *uuid, char *str, size_t maxLen);
/////////////////////////////////////////////////
// Effect Control Interface functions
/////////////////////////////////////////////////
-int Effect_Process(effect_interface_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer)
+int Effect_Process(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer)
{
int ret = init();
if (ret < 0) {
@@ -73,7 +84,7 @@ int Effect_Process(effect_interface_t self, audio_buffer_t *inBuffer, audio_buff
return ret;
}
-int Effect_Command(effect_interface_t self,
+int Effect_Command(effect_handle_t self,
uint32_t cmdCode,
uint32_t cmdSize,
void *pCmdData,
@@ -98,9 +109,31 @@ int Effect_Command(effect_interface_t self,
return ret;
}
+int Effect_GetDescriptor(effect_handle_t self,
+ effect_descriptor_t *desc)
+{
+ int ret = init();
+ if (ret < 0) {
+ return ret;
+ }
+ effect_entry_t *fx = (effect_entry_t *)self;
+ pthread_mutex_lock(&gLibLock);
+ if (fx->lib == NULL) {
+ pthread_mutex_unlock(&gLibLock);
+ return -EPIPE;
+ }
+ pthread_mutex_lock(&fx->lib->lock);
+ pthread_mutex_unlock(&gLibLock);
+
+ ret = (*fx->subItfe)->get_descriptor(fx->subItfe, desc);
+ pthread_mutex_unlock(&fx->lib->lock);
+ return ret;
+}
+
const struct effect_interface_s gInterface = {
Effect_Process,
- Effect_Command
+ Effect_Command,
+ Effect_GetDescriptor
};
/////////////////////////////////////////////////
@@ -182,7 +215,7 @@ int EffectGetDescriptor(effect_uuid_t *uuid, effect_descriptor_t *pDescriptor)
return -EINVAL;
}
pthread_mutex_lock(&gLibLock);
- ret = findEffect(uuid, &l, &d);
+ ret = findEffect(NULL, uuid, &l, &d);
if (ret == 0) {
memcpy(pDescriptor, d, sizeof(effect_descriptor_t));
}
@@ -190,17 +223,17 @@ int EffectGetDescriptor(effect_uuid_t *uuid, effect_descriptor_t *pDescriptor)
return ret;
}
-int EffectCreate(effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_interface_t *pInterface)
+int EffectCreate(effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle)
{
list_elem_t *e = gLibraryList;
lib_entry_t *l = NULL;
effect_descriptor_t *d = NULL;
- effect_interface_t itfe;
+ effect_handle_t itfe;
effect_entry_t *fx;
int found = 0;
int ret;
- if (uuid == NULL || pInterface == NULL) {
+ if (uuid == NULL || pHandle == NULL) {
return -EINVAL;
}
@@ -218,15 +251,15 @@ int EffectCreate(effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_in
pthread_mutex_lock(&gLibLock);
- ret = findEffect(uuid, &l, &d);
+ ret = findEffect(NULL, uuid, &l, &d);
if (ret < 0){
goto exit;
}
// create effect in library
- ret = l->createFx(uuid, sessionId, ioId, &itfe);
+ l->desc->create_effect(uuid, sessionId, ioId, &itfe);
if (ret != 0) {
- LOGW("EffectCreate() library %s: could not create fx %s, error %d", l->path, d->name, ret);
+ LOGW("EffectCreate() library %s: could not create fx %s, error %d", l->name, d->name, ret);
goto exit;
}
@@ -241,16 +274,16 @@ int EffectCreate(effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_in
e->next = gEffectList;
gEffectList = e;
- *pInterface = (effect_interface_t)fx;
+ *pHandle = (effect_handle_t)fx;
- LOGV("EffectCreate() created entry %p with sub itfe %p in library %s", *pInterface, itfe, l->path);
+ LOGV("EffectCreate() created entry %p with sub itfe %p in library %s", *pHandle, itfe, l->name);
exit:
pthread_mutex_unlock(&gLibLock);
return ret;
}
-int EffectRelease(effect_interface_t interface)
+int EffectRelease(effect_handle_t handle)
{
effect_entry_t *fx;
list_elem_t *e1;
@@ -266,7 +299,7 @@ int EffectRelease(effect_interface_t interface)
e1 = gEffectList;
e2 = NULL;
while (e1) {
- if (e1->object == interface) {
+ if (e1->object == handle) {
if (e2) {
e2->next = e1->next;
} else {
@@ -286,10 +319,10 @@ int EffectRelease(effect_interface_t interface)
// release effect in library
if (fx->lib == NULL) {
- LOGW("EffectRelease() fx %p library already unloaded", interface);
+ LOGW("EffectRelease() fx %p library already unloaded", handle);
} else {
pthread_mutex_lock(&fx->lib->lock);
- fx->lib->releaseFx(fx->subItfe);
+ fx->lib->desc->release_effect(fx->subItfe);
pthread_mutex_unlock(&fx->lib->lock);
}
free(fx);
@@ -301,29 +334,14 @@ exit:
int EffectLoadLibrary(const char *libPath, int *handle)
{
- int ret = init();
- if (ret < 0) {
- return ret;
- }
- if (libPath == NULL) {
- return -EINVAL;
- }
-
- ret = loadLibrary(libPath, handle);
- updateNumEffects();
- return ret;
+ // TODO: see if this interface still makes sense with the use of config files
+ return -ENOSYS;
}
int EffectUnloadLibrary(int handle)
{
- int ret = init();
- if (ret < 0) {
- return ret;
- }
-
- ret = unloadLibrary(handle);
- updateNumEffects();
- return ret;
+ // TODO: see if this interface still makes sense with the use of config files
+ return -ENOSYS;
}
int EffectIsNullUuid(effect_uuid_t *uuid)
@@ -339,9 +357,6 @@ int EffectIsNullUuid(effect_uuid_t *uuid)
/////////////////////////////////////////////////
int init() {
- struct dirent *ent;
- DIR *dir = NULL;
- char libpath[PATH_MAX];
int hdl;
if (gInitDone) {
@@ -350,214 +365,210 @@ int init() {
pthread_mutex_init(&gLibLock, NULL);
- // load built-in libraries
- dir = opendir(gEffectLibPath);
- if (dir == NULL) {
- return -ENODEV;
+ if (access(AUDIO_EFFECT_VENDOR_CONFIG_FILE, R_OK) == 0) {
+ loadEffectConfigFile(AUDIO_EFFECT_VENDOR_CONFIG_FILE);
+ } else if (access(AUDIO_EFFECT_DEFAULT_CONFIG_FILE, R_OK) == 0) {
+ loadEffectConfigFile(AUDIO_EFFECT_DEFAULT_CONFIG_FILE);
}
- while ((ent = readdir(dir)) != NULL) {
- LOGV("init() reading file %s", ent->d_name);
- if ((strlen(ent->d_name) < 3) ||
- strncmp(ent->d_name, "lib", 3) != 0 ||
- strncmp(ent->d_name + strlen(ent->d_name) - 3, ".so", 3) != 0) {
- continue;
- }
- strcpy(libpath, gEffectLibPath);
- strcat(libpath, "/");
- strcat(libpath, ent->d_name);
- if (loadLibrary(libpath, &hdl) < 0) {
- LOGW("init() failed to load library %s",libpath);
- }
- }
- closedir(dir);
+
updateNumEffects();
gInitDone = 1;
LOGV("init() done");
return 0;
}
-
-int loadLibrary(const char *libPath, int *handle)
+int loadEffectConfigFile(const char *path)
{
- void *hdl;
- effect_QueryNumberEffects_t queryNumFx;
- effect_QueryEffect_t queryFx;
- effect_CreateEffect_t createFx;
- effect_ReleaseEffect_t releaseFx;
- uint32_t numFx;
- uint32_t fx;
- int ret;
- list_elem_t *e, *descHead = NULL;
- lib_entry_t *l;
+ cnode *root;
+ char *data;
- if (handle == NULL) {
- return -EINVAL;
+ data = load_file(path, NULL);
+ if (data == NULL) {
+ return -ENODEV;
}
+ root = config_node("", "");
+ config_load(root, data);
+ loadLibraries(root);
+ loadEffects(root);
+ config_free(root);
+ free(root);
+ free(data);
- *handle = 0;
+ return 0;
+}
- hdl = dlopen(libPath, RTLD_NOW);
- if (hdl == 0) {
- LOGW("could open lib %s", libPath);
- return -ENODEV;
- }
+int loadLibraries(cnode *root)
+{
+ cnode *node;
- // Check functions availability
- queryNumFx = (effect_QueryNumberEffects_t)dlsym(hdl, "EffectQueryNumberEffects");
- if (queryNumFx == NULL) {
- LOGW("could not get EffectQueryNumberEffects from lib %s", libPath);
- ret = -ENODEV;
- goto error;
+ node = config_find(root, LIBRARIES_TAG);
+ if (node == NULL) {
+ return -ENOENT;
}
- queryFx = (effect_QueryEffect_t)dlsym(hdl, "EffectQueryEffect");
- if (queryFx == NULL) {
- LOGW("could not get EffectQueryEffect from lib %s", libPath);
- ret = -ENODEV;
- goto error;
+ node = node->first_child;
+ while (node) {
+ loadLibrary(node, node->name);
+ node = node->next;
}
- createFx = (effect_CreateEffect_t)dlsym(hdl, "EffectCreate");
- if (createFx == NULL) {
- LOGW("could not get EffectCreate from lib %s", libPath);
- ret = -ENODEV;
- goto error;
+ return 0;
+}
+
+int loadLibrary(cnode *root, const char *name)
+{
+ cnode *node;
+ void *hdl;
+ audio_effect_library_t *desc;
+ list_elem_t *e;
+ lib_entry_t *l;
+
+ node = config_find(root, PATH_TAG);
+ if (node == NULL) {
+ return -EINVAL;
}
- releaseFx = (effect_ReleaseEffect_t)dlsym(hdl, "EffectRelease");
- if (releaseFx == NULL) {
- LOGW("could not get EffectRelease from lib %s", libPath);
- ret = -ENODEV;
+
+ hdl = dlopen(node->value, RTLD_NOW);
+ if (hdl == NULL) {
+ LOGW("loadLibrary() failed to open %s", node->value);
goto error;
}
- // load effect descriptors
- ret = queryNumFx(&numFx);
- if (ret) {
+ desc = (audio_effect_library_t *)dlsym(hdl, AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR);
+ if (desc == NULL) {
+ LOGW("loadLibrary() could not find symbol %s", AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR);
goto error;
}
- for (fx = 0; fx < numFx; fx++) {
- effect_descriptor_t *d = malloc(sizeof(effect_descriptor_t));
- if (d == NULL) {
- ret = -ENOMEM;
- goto error;
- }
- ret = queryFx(fx, d);
- if (ret == 0) {
-#if (LOG_NDEBUG==0)
- char s[256];
- dumpEffectDescriptor(d, s, 256);
- LOGV("loadLibrary() read descriptor %p:%s",d, s);
-#endif
- if (d->apiVersion != EFFECT_API_VERSION) {
- LOGW("Bad API version %04x on lib %s", d->apiVersion, libPath);
- free(d);
- continue;
- }
- e = malloc(sizeof(list_elem_t));
- if (e == NULL) {
- free(d);
- ret = -ENOMEM;
- goto error;
- }
- e->object = d;
- e->next = descHead;
- descHead = e;
- } else {
- LOGW("Error querying effect # %d on lib %s", fx, libPath);
- }
+ if (AUDIO_EFFECT_LIBRARY_TAG != desc->tag) {
+ LOGW("getLibrary() bad tag %08x in lib info struct", desc->tag);
+ goto error;
}
- pthread_mutex_lock(&gLibLock);
+ if (EFFECT_API_VERSION_MAJOR(desc->version) !=
+ EFFECT_API_VERSION_MAJOR(EFFECT_LIBRARY_API_VERSION)) {
+ LOGW("loadLibrary() bad lib version %08x", desc->version);
+ goto error;
+ }
// add entry for library in gLibraryList
l = malloc(sizeof(lib_entry_t));
- l->id = ++gNextLibId;
+ l->name = strndup(name, PATH_MAX);
+ l->path = strndup(node->value, PATH_MAX);
l->handle = hdl;
- strncpy(l->path, libPath, PATH_MAX);
- l->createFx = createFx;
- l->releaseFx = releaseFx;
- l->effects = descHead;
+ l->desc = desc;
+ l->effects = NULL;
pthread_mutex_init(&l->lock, NULL);
e = malloc(sizeof(list_elem_t));
- e->next = gLibraryList;
e->object = l;
+ pthread_mutex_lock(&gLibLock);
+ e->next = gLibraryList;
gLibraryList = e;
pthread_mutex_unlock(&gLibLock);
- LOGV("loadLibrary() linked library %p", l);
-
- *handle = l->id;
+ LOGV("getLibrary() linked library %p for path %s", l, node->value);
return 0;
error:
- LOGW("loadLibrary() error: %d on lib: %s", ret, libPath);
- while (descHead) {
- free(descHead->object);
- e = descHead->next;
- free(descHead);
- descHead = e;;
- }
- dlclose(hdl);
- return ret;
+ if (hdl != NULL) {
+ dlclose(hdl);
+ }
+ return -EINVAL;
}
-int unloadLibrary(int handle)
+int loadEffects(cnode *root)
{
- void *hdl;
- int ret;
- list_elem_t *el1, *el2;
+ cnode *node;
+
+ node = config_find(root, EFFECTS_TAG);
+ if (node == NULL) {
+ return -ENOENT;
+ }
+ node = node->first_child;
+ while (node) {
+ loadEffect(node);
+ node = node->next;
+ }
+ return 0;
+}
+
+int loadEffect(cnode *root)
+{
+ cnode *node;
+ effect_uuid_t uuid;
lib_entry_t *l;
- effect_entry_t *fx;
+ effect_descriptor_t *d;
+ list_elem_t *e;
- pthread_mutex_lock(&gLibLock);
- el1 = gLibraryList;
- el2 = NULL;
- while (el1) {
- l = (lib_entry_t *)el1->object;
- if (handle == l->id) {
- if (el2) {
- el2->next = el1->next;
- } else {
- gLibraryList = el1->next;
- }
- free(el1);
- break;
- }
- el2 = el1;
- el1 = el1->next;
+ node = config_find(root, LIBRARY_TAG);
+ if (node == NULL) {
+ return -EINVAL;
}
- pthread_mutex_unlock(&gLibLock);
- if (el1 == NULL) {
- return -ENOENT;
+
+ l = getLibrary(node->value);
+ if (l == NULL) {
+ LOGW("loadEffect() could not get library %s", node->value);
+ return -EINVAL;
}
- // clear effect descriptor list
- el1 = l->effects;
- while (el1) {
- free(el1->object);
- el2 = el1->next;
- free(el1);
- el1 = el2;
+ node = config_find(root, UUID_TAG);
+ if (node == NULL) {
+ return -EINVAL;
+ }
+ if (stringToUuid(node->value, &uuid) != 0) {
+ LOGW("loadEffect() invalid uuid %s", node->value);
+ return -EINVAL;
+ }
+
+ d = malloc(sizeof(effect_descriptor_t));
+ if (l->desc->get_descriptor(&uuid, d) != 0) {
+ char s[40];
+ uuidToString(&uuid, s, 40);
+ LOGW("Error querying effect %s on lib %s", s, l->name);
+ free(d);
+ return -EINVAL;
+ }
+#if (LOG_NDEBUG==0)
+ char s[256];
+ dumpEffectDescriptor(d, s, 256);
+ LOGV("loadEffect() read descriptor %p:%s",d, s);
+#endif
+ if (EFFECT_API_VERSION_MAJOR(d->apiVersion) !=
+ EFFECT_API_VERSION_MAJOR(EFFECT_CONTROL_API_VERSION)) {
+ LOGW("Bad API version %08x on lib %s", d->apiVersion, l->name);
+ free(d);
+ return -EINVAL;
}
+ e = malloc(sizeof(list_elem_t));
+ e->object = d;
+ e->next = l->effects;
+ l->effects = e;
+
+ return 0;
+}
- // disable all effects from this library
- pthread_mutex_lock(&l->lock);
+lib_entry_t *getLibrary(const char *name)
+{
+ list_elem_t *e;
- el1 = gEffectList;
- while (el1) {
- fx = (effect_entry_t *)el1->object;
- if (fx->lib == l) {
- fx->lib = NULL;
+ if (gCachedLibrary &&
+ !strncmp(gCachedLibrary->name, name, PATH_MAX)) {
+ return gCachedLibrary;
+ }
+
+ e = gLibraryList;
+ while (e) {
+ lib_entry_t *l = (lib_entry_t *)e->object;
+ if (!strcmp(l->name, name)) {
+ gCachedLibrary = l;
+ return l;
}
- el1 = el1->next;
+ e = e->next;
}
- pthread_mutex_unlock(&l->lock);
- dlclose(l->handle);
- free(l);
- return 0;
+ return NULL;
}
+
void resetEffectEnumeration()
{
gCurLib = gLibraryList;
@@ -589,7 +600,10 @@ uint32_t updateNumEffects() {
return cnt;
}
-int findEffect(effect_uuid_t *uuid, lib_entry_t **lib, effect_descriptor_t **desc)
+int findEffect(effect_uuid_t *type,
+ effect_uuid_t *uuid,
+ lib_entry_t **lib,
+ effect_descriptor_t **desc)
{
list_elem_t *e = gLibraryList;
lib_entry_t *l = NULL;
@@ -602,7 +616,11 @@ int findEffect(effect_uuid_t *uuid, lib_entry_t **lib, effect_descriptor_t **des
list_elem_t *efx = l->effects;
while (efx) {
d = (effect_descriptor_t *)efx->object;
- if (memcmp(&d->uuid, uuid, sizeof(effect_uuid_t)) == 0) {
+ if (type != NULL && memcmp(&d->type, type, sizeof(effect_uuid_t)) == 0) {
+ found = 1;
+ break;
+ }
+ if (uuid != NULL && memcmp(&d->uuid, uuid, sizeof(effect_uuid_t)) == 0) {
found = 1;
break;
}
@@ -614,9 +632,11 @@ int findEffect(effect_uuid_t *uuid, lib_entry_t **lib, effect_descriptor_t **des
LOGV("findEffect() effect not found");
ret = -ENOENT;
} else {
- LOGV("findEffect() found effect: %s in lib %s", d->name, l->path);
+ LOGV("findEffect() found effect: %s in lib %s", d->name, l->name);
*lib = l;
- *desc = d;
+ if (desc) {
+ *desc = d;
+ }
}
return ret;
@@ -626,17 +646,12 @@ void dumpEffectDescriptor(effect_descriptor_t *desc, char *str, size_t len) {
char s[256];
snprintf(str, len, "\nEffect Descriptor %p:\n", desc);
- sprintf(s, "- UUID: %08X-%04X-%04X-%04X-%02X%02X%02X%02X%02X%02X\n",
- desc->uuid.timeLow, desc->uuid.timeMid, desc->uuid.timeHiAndVersion,
- desc->uuid.clockSeq, desc->uuid.node[0], desc->uuid.node[1],desc->uuid.node[2],
- desc->uuid.node[3],desc->uuid.node[4],desc->uuid.node[5]);
- strncat(str, s, len);
- sprintf(s, "- TYPE: %08X-%04X-%04X-%04X-%02X%02X%02X%02X%02X%02X\n",
- desc->type.timeLow, desc->type.timeMid, desc->type.timeHiAndVersion,
- desc->type.clockSeq, desc->type.node[0], desc->type.node[1],desc->type.node[2],
- desc->type.node[3],desc->type.node[4],desc->type.node[5]);
- strncat(str, s, len);
- sprintf(s, "- apiVersion: %04X\n- flags: %08X\n",
+ strncat(str, "- TYPE: ", len);
+ uuidToString(&desc->uuid, s, 256);
+ snprintf(str, len, "- UUID: %s\n", s);
+ uuidToString(&desc->type, s, 256);
+ snprintf(str, len, "- TYPE: %s\n", s);
+ sprintf(s, "- apiVersion: %08X\n- flags: %08X\n",
desc->apiVersion, desc->flags);
strncat(str, s, len);
sprintf(s, "- name: %s\n", desc->name);
@@ -645,3 +660,43 @@ void dumpEffectDescriptor(effect_descriptor_t *desc, char *str, size_t len) {
strncat(str, s, len);
}
+int stringToUuid(const char *str, effect_uuid_t *uuid)
+{
+ int tmp[10];
+
+ if (sscanf(str, "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
+ tmp, tmp+1, tmp+2, tmp+3, tmp+4, tmp+5, tmp+6, tmp+7, tmp+8, tmp+9) < 10) {
+ return -EINVAL;
+ }
+ uuid->timeLow = (uint32_t)tmp[0];
+ uuid->timeMid = (uint16_t)tmp[1];
+ uuid->timeHiAndVersion = (uint16_t)tmp[2];
+ uuid->clockSeq = (uint16_t)tmp[3];
+ uuid->node[0] = (uint8_t)tmp[4];
+ uuid->node[1] = (uint8_t)tmp[5];
+ uuid->node[2] = (uint8_t)tmp[6];
+ uuid->node[3] = (uint8_t)tmp[7];
+ uuid->node[4] = (uint8_t)tmp[8];
+ uuid->node[5] = (uint8_t)tmp[9];
+
+ return 0;
+}
+
+int uuidToString(const effect_uuid_t *uuid, char *str, size_t maxLen)
+{
+
+ snprintf(str, maxLen, "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
+ uuid->timeLow,
+ uuid->timeMid,
+ uuid->timeHiAndVersion,
+ uuid->clockSeq,
+ uuid->node[0],
+ uuid->node[1],
+ uuid->node[2],
+ uuid->node[3],
+ uuid->node[4],
+ uuid->node[5]);
+
+ return 0;
+}
+
diff --git a/media/libeffects/factory/EffectsFactory.h b/media/libeffects/factory/EffectsFactory.h
index 8f543ca..fcc0dba 100644
--- a/media/libeffects/factory/EffectsFactory.h
+++ b/media/libeffects/factory/EffectsFactory.h
@@ -22,29 +22,35 @@
#include <dirent.h>
#include <media/EffectsFactoryApi.h>
-
#if __cplusplus
extern "C" {
#endif
+#define AUDIO_EFFECT_DEFAULT_CONFIG_FILE "/system/etc/audio_effects.conf"
+#define AUDIO_EFFECT_VENDOR_CONFIG_FILE "/vendor/etc/audio_effects.conf"
+#define EFFECTS_TAG "effects"
+#define LIBRARIES_TAG "libraries"
+#define PATH_TAG "path"
+#define LIBRARY_TAG "library"
+#define UUID_TAG "uuid"
+
typedef struct list_elem_s {
void *object;
struct list_elem_s *next;
} list_elem_t;
typedef struct lib_entry_s {
- char path[PATH_MAX];
+ audio_effect_library_t *desc;
+ char *name;
+ char *path;
void *handle;
- int id;
- effect_CreateEffect_t createFx;
- effect_ReleaseEffect_t releaseFx;
list_elem_t *effects; //list of effect_descriptor_t
pthread_mutex_t lock;
} lib_entry_t;
typedef struct effect_entry_s {
struct effect_interface_s *itfe;
- effect_interface_t subItfe;
+ effect_handle_t subItfe;
lib_entry_t *lib;
} effect_entry_t;
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index 0b061db..21c451f 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -27,7 +27,7 @@
#include <EffectBundle.h>
-// effect_interface_t interface implementation for bass boost
+// effect_handle_t interface implementation for bass boost
extern "C" const struct effect_interface_s gLvmEffectInterface;
#define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\
@@ -71,7 +71,7 @@ int SessionIndex[LVM_MAX_SESSIONS];
const effect_descriptor_t gBassBoostDescriptor = {
{0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }},
{0x8631f300, 0x72e2, 0x11df, 0xb57e, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
(EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_DEVICE_IND
| EFFECT_FLAG_VOLUME_CTRL),
BASS_BOOST_CUP_LOAD_ARM9E,
@@ -84,7 +84,7 @@ const effect_descriptor_t gBassBoostDescriptor = {
const effect_descriptor_t gVirtualizerDescriptor = {
{0x37cc2c00, 0xdddd, 0x11db, 0x8577, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
{0x1d4033c0, 0x8557, 0x11df, 0x9f2d, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
(EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_DEVICE_IND
| EFFECT_FLAG_VOLUME_CTRL),
VIRTUALIZER_CUP_LOAD_ARM9E,
@@ -97,7 +97,7 @@ const effect_descriptor_t gVirtualizerDescriptor = {
const effect_descriptor_t gEqualizerDescriptor = {
{0x0bed4300, 0xddd6, 0x11db, 0x8f34, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // type
{0xce772f20, 0x847d, 0x11df, 0xbb17, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid Eq NXP
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
(EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_VOLUME_CTRL),
EQUALIZER_CUP_LOAD_ARM9E,
BUNDLE_MEM_USAGE,
@@ -109,7 +109,7 @@ const effect_descriptor_t gEqualizerDescriptor = {
const effect_descriptor_t gVolumeDescriptor = {
{0x09e8ede0, 0xddde, 0x11db, 0xb4f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }},
{0x119341a0, 0x8469, 0x11df, 0x81f9, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, //uuid VOL NXP
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
(EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_VOLUME_CTRL),
VOLUME_CUP_LOAD_ARM9E,
BUNDLE_MEM_USAGE,
@@ -187,7 +187,7 @@ extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescripto
extern "C" int EffectCreate(effect_uuid_t *uuid,
int32_t sessionId,
int32_t ioId,
- effect_interface_t *pInterface){
+ effect_handle_t *pHandle){
int ret = 0;
int sessionNo;
int i;
@@ -197,7 +197,7 @@ extern "C" int EffectCreate(effect_uuid_t *uuid,
LOGV("\n\tEffectCreate start session %d", sessionId);
- if (pInterface == NULL || uuid == NULL){
+ if (pHandle == NULL || uuid == NULL){
LOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer");
ret = -EINVAL;
goto exit;
@@ -355,19 +355,19 @@ exit:
}
delete pContext;
}
- *pInterface = (effect_interface_t)NULL;
+ *pHandle = (effect_handle_t)NULL;
} else {
- *pInterface = (effect_interface_t)pContext;
+ *pHandle = (effect_handle_t)pContext;
}
LOGV("\tEffectCreate end..\n\n");
return ret;
} /* end EffectCreate */
-extern "C" int EffectRelease(effect_interface_t interface){
- LOGV("\n\tEffectRelease start %p", interface);
- EffectContext * pContext = (EffectContext *)interface;
+extern "C" int EffectRelease(effect_handle_t handle){
+ LOGV("\n\tEffectRelease start %p", handle);
+ EffectContext * pContext = (EffectContext *)handle;
- LOGV("\tEffectRelease start interface: %p, context %p", interface, pContext->pBundledContext);
+ LOGV("\tEffectRelease start handle: %p, context %p", handle, pContext->pBundledContext);
if (pContext == NULL){
LOGV("\tLVM_ERROR : EffectRelease called with NULL pointer");
return -EINVAL;
@@ -460,6 +460,34 @@ extern "C" int EffectRelease(effect_interface_t interface){
} /* end EffectRelease */
+extern "C" int EffectGetDescriptor(effect_uuid_t *uuid,
+ effect_descriptor_t *pDescriptor) {
+ const effect_descriptor_t *desc = NULL;
+
+ if (pDescriptor == NULL || uuid == NULL){
+ LOGV("EffectGetDescriptor() called with NULL pointer");
+ return -EINVAL;
+ }
+
+ if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0) {
+ desc = &gBassBoostDescriptor;
+ } else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) {
+ desc = &gVirtualizerDescriptor;
+ } else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) {
+ desc = &gEqualizerDescriptor;
+ } else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0) {
+ desc = &gVolumeDescriptor;
+ }
+
+ if (desc == NULL) {
+ return -EINVAL;
+ }
+
+ memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+
+ return 0;
+} /* end EffectGetDescriptor */
+
void LvmGlobalBundle_init(){
LOGV("\tLvmGlobalBundle_init start");
for(int i=0; i<LVM_MAX_SESSIONS; i++){
@@ -493,16 +521,16 @@ int LvmBundle_init(EffectContext *pContext){
LOGV("\tLvmBundle_init start");
pContext->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
- pContext->config.inputCfg.channels = CHANNEL_STEREO;
- pContext->config.inputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pContext->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
+ pContext->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pContext->config.inputCfg.samplingRate = 44100;
pContext->config.inputCfg.bufferProvider.getBuffer = NULL;
pContext->config.inputCfg.bufferProvider.releaseBuffer = NULL;
pContext->config.inputCfg.bufferProvider.cookie = NULL;
pContext->config.inputCfg.mask = EFFECT_CONFIG_ALL;
pContext->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE;
- pContext->config.outputCfg.channels = CHANNEL_STEREO;
- pContext->config.outputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pContext->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
+ pContext->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pContext->config.outputCfg.samplingRate = 44100;
pContext->config.outputCfg.bufferProvider.getBuffer = NULL;
pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL;
@@ -928,10 +956,10 @@ int Effect_configure(EffectContext *pContext, effect_config_t *pConfig){
CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate);
CHECK_ARG(pConfig->inputCfg.channels == pConfig->outputCfg.channels);
CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format);
- CHECK_ARG(pConfig->inputCfg.channels == CHANNEL_STEREO);
+ CHECK_ARG(pConfig->inputCfg.channels == AUDIO_CHANNEL_OUT_STEREO);
CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE
|| pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE);
- CHECK_ARG(pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S15);
+ CHECK_ARG(pConfig->inputCfg.format == AUDIO_FORMAT_PCM_16_BIT);
memcpy(&pContext->config, pConfig, sizeof(effect_config_t));
@@ -2545,8 +2573,9 @@ int16_t LVC_Convert_VolToDb(uint32_t vol){
} // namespace
} // namespace
+extern "C" {
/* Effect Control Interface Implementation: Process */
-extern "C" int Effect_process(effect_interface_t self,
+int Effect_process(effect_handle_t self,
audio_buffer_t *inBuffer,
audio_buffer_t *outBuffer){
EffectContext * pContext = (EffectContext *) self;
@@ -2666,7 +2695,7 @@ extern "C" int Effect_process(effect_interface_t self,
} /* end Effect_process */
/* Effect Control Interface Implementation: Command */
-extern "C" int Effect_command(effect_interface_t self,
+int Effect_command(effect_handle_t self,
uint32_t cmdCode,
uint32_t cmdSize,
void *pCmdData,
@@ -3016,11 +3045,11 @@ extern "C" int Effect_command(effect_interface_t self,
case EFFECT_CMD_SET_DEVICE:
{
LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE start");
- audio_device_e device = *(audio_device_e *)pCmdData;
+ uint32_t device = *(uint32_t *)pCmdData;
if(pContext->EffectType == LVM_BASS_BOOST){
- if((device == DEVICE_SPEAKER)||(device == DEVICE_BLUETOOTH_SCO_CARKIT)||
- (device == DEVICE_BLUETOOTH_A2DP_SPEAKER)){
+ if((device == AUDIO_DEVICE_OUT_SPEAKER)||(device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT)||
+ (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){
LOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_BASS_BOOST %d",
*(int32_t *)pCmdData);
LOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BAS_BOOST");
@@ -3051,8 +3080,8 @@ extern "C" int Effect_command(effect_interface_t self,
}
}
if(pContext->EffectType == LVM_VIRTUALIZER){
- if((device == DEVICE_SPEAKER)||(device == DEVICE_BLUETOOTH_SCO_CARKIT)||
- (device == DEVICE_BLUETOOTH_A2DP_SPEAKER)){
+ if((device == AUDIO_DEVICE_OUT_SPEAKER)||(device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT)||
+ (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){
LOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_VIRTUALIZER %d",
*(int32_t *)pCmdData);
LOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_VIRTUALIZER");
@@ -3164,9 +3193,57 @@ extern "C" int Effect_command(effect_interface_t self,
return 0;
} /* end Effect_command */
-// effect_interface_t interface implementation for effect
+/* Effect Control Interface Implementation: get_descriptor */
+int Effect_getDescriptor(effect_handle_t self,
+ effect_descriptor_t *pDescriptor)
+{
+ EffectContext * pContext = (EffectContext *) self;
+ const effect_descriptor_t *desc;
+
+ if (pContext == NULL || pDescriptor == NULL) {
+ LOGV("Effect_getDescriptor() invalid param");
+ return -EINVAL;
+ }
+
+ switch(pContext->EffectType) {
+ case LVM_BASS_BOOST:
+ desc = &android::gBassBoostDescriptor;
+ break;
+ case LVM_VIRTUALIZER:
+ desc = &android::gVirtualizerDescriptor;
+ break;
+ case LVM_EQUALIZER:
+ desc = &android::gEqualizerDescriptor;
+ break;
+ case LVM_VOLUME:
+ desc = &android::gVolumeDescriptor;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+
+ return 0;
+} /* end Effect_getDescriptor */
+
+// effect_handle_t interface implementation for effect
const struct effect_interface_s gLvmEffectInterface = {
Effect_process,
- Effect_command
+ Effect_command,
+ Effect_getDescriptor
}; /* end gLvmEffectInterface */
+audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
+ tag : AUDIO_EFFECT_LIBRARY_TAG,
+ version : EFFECT_LIBRARY_API_VERSION,
+ name : "Effect Bundle Library",
+ implementor : "NXP Software Ltd.",
+ query_num_effects : android::EffectQueryNumberEffects,
+ query_effect : android::EffectQueryEffect,
+ create_effect : android::EffectCreate,
+ release_effect : android::EffectRelease,
+ get_descriptor : android::EffectGetDescriptor,
+};
+
+}
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
index 9097e20..2727375 100755
--- a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
@@ -27,7 +27,7 @@
#include <EffectReverb.h>
#include <LVREV.h>
-// effect_interface_t interface implementation for reverb
+// effect_handle_t interface implementation for reverb
extern "C" const struct effect_interface_s gReverbInterface;
#define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\
@@ -77,7 +77,7 @@ const static t_reverb_settings sReverbPresets[] = {
const effect_descriptor_t gAuxEnvReverbDescriptor = {
{ 0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, { 0x4e, 0x23, 0x4d, 0x06, 0x83, 0x9e } },
{ 0x4a387fc0, 0x8ab3, 0x11df, 0x8bad, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
EFFECT_FLAG_TYPE_AUXILIARY,
LVREV_CUP_LOAD_ARM9E,
LVREV_MEM_USAGE,
@@ -89,7 +89,7 @@ const effect_descriptor_t gAuxEnvReverbDescriptor = {
static const effect_descriptor_t gInsertEnvReverbDescriptor = {
{0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, {0x4e, 0x23, 0x4d, 0x06, 0x83, 0x9e}},
{0xc7a511a0, 0xa3bb, 0x11df, 0x860e, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_FIRST | EFFECT_FLAG_VOLUME_CTRL,
LVREV_CUP_LOAD_ARM9E,
LVREV_MEM_USAGE,
@@ -101,7 +101,7 @@ static const effect_descriptor_t gInsertEnvReverbDescriptor = {
static const effect_descriptor_t gAuxPresetReverbDescriptor = {
{0x47382d60, 0xddd8, 0x11db, 0xbf3a, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
{0xf29a1400, 0xa3bb, 0x11df, 0x8ddc, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
EFFECT_FLAG_TYPE_AUXILIARY,
LVREV_CUP_LOAD_ARM9E,
LVREV_MEM_USAGE,
@@ -113,7 +113,7 @@ static const effect_descriptor_t gAuxPresetReverbDescriptor = {
static const effect_descriptor_t gInsertPresetReverbDescriptor = {
{0x47382d60, 0xddd8, 0x11db, 0xbf3a, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
{0x172cdf00, 0xa3bc, 0x11df, 0xa72f, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_FIRST | EFFECT_FLAG_VOLUME_CTRL,
LVREV_CUP_LOAD_ARM9E,
LVREV_MEM_USAGE,
@@ -192,7 +192,8 @@ extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects){
return 0;
} /* end EffectQueryNumberEffects */
-extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor){
+extern "C" int EffectQueryEffect(uint32_t index,
+ effect_descriptor_t *pDescriptor){
LOGV("\n\tEffectQueryEffect start");
LOGV("\tEffectQueryEffect processing index %d", index);
if (pDescriptor == NULL){
@@ -211,7 +212,7 @@ extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescripto
extern "C" int EffectCreate(effect_uuid_t *uuid,
int32_t sessionId,
int32_t ioId,
- effect_interface_t *pInterface){
+ effect_handle_t *pHandle){
int ret;
int i;
int length = sizeof(gDescriptors) / sizeof(const effect_descriptor_t *);
@@ -219,7 +220,7 @@ extern "C" int EffectCreate(effect_uuid_t *uuid,
LOGV("\t\nEffectCreate start");
- if (pInterface == NULL || uuid == NULL){
+ if (pHandle == NULL || uuid == NULL){
LOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer");
return -EINVAL;
}
@@ -270,7 +271,7 @@ extern "C" int EffectCreate(effect_uuid_t *uuid,
return ret;
}
- *pInterface = (effect_interface_t)pContext;
+ *pHandle = (effect_handle_t)pContext;
#ifdef LVM_PCM
pContext->PcmInPtr = NULL;
@@ -295,10 +296,10 @@ extern "C" int EffectCreate(effect_uuid_t *uuid,
return 0;
} /* end EffectCreate */
-extern "C" int EffectRelease(effect_interface_t interface){
- ReverbContext * pContext = (ReverbContext *)interface;
+extern "C" int EffectRelease(effect_handle_t handle){
+ ReverbContext * pContext = (ReverbContext *)handle;
- LOGV("\tEffectRelease %p", interface);
+ LOGV("\tEffectRelease %p", handle);
if (pContext == NULL){
LOGV("\tLVM_ERROR : EffectRelease called with NULL pointer");
return -EINVAL;
@@ -315,6 +316,28 @@ extern "C" int EffectRelease(effect_interface_t interface){
return 0;
} /* end EffectRelease */
+extern "C" int EffectGetDescriptor(effect_uuid_t *uuid,
+ effect_descriptor_t *pDescriptor) {
+ int i;
+ int length = sizeof(gDescriptors) / sizeof(const effect_descriptor_t *);
+
+ if (pDescriptor == NULL || uuid == NULL){
+ LOGV("EffectGetDescriptor() called with NULL pointer");
+ return -EINVAL;
+ }
+
+ for (i = 0; i < length; i++) {
+ if (memcmp(uuid, &gDescriptors[i]->uuid, sizeof(effect_uuid_t)) == 0) {
+ memcpy(pDescriptor, gDescriptors[i], sizeof(effect_descriptor_t));
+ LOGV("EffectGetDescriptor - UUID matched Reverb type %d, UUID = %x",
+ i, gDescriptors[i]->uuid.timeLow);
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+} /* end EffectGetDescriptor */
+
/* local functions */
#define CHECK_ARG(cond) { \
if (!(cond)) { \
@@ -418,9 +441,9 @@ int process( LVM_INT16 *pIn,
// Check that the input is either mono or stereo
- if (pContext->config.inputCfg.channels == CHANNEL_STEREO) {
+ if (pContext->config.inputCfg.channels == AUDIO_CHANNEL_OUT_STEREO) {
samplesPerFrame = 2;
- } else if (pContext->config.inputCfg.channels != CHANNEL_MONO) {
+ } else if (pContext->config.inputCfg.channels != AUDIO_CHANNEL_OUT_MONO) {
LOGV("\tLVREV_ERROR : process invalid PCM format");
return -EINVAL;
}
@@ -608,12 +631,12 @@ int Reverb_configure(ReverbContext *pContext, effect_config_t *pConfig){
CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate);
CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format);
- CHECK_ARG((pContext->auxiliary && pConfig->inputCfg.channels == CHANNEL_MONO) ||
- ((!pContext->auxiliary) && pConfig->inputCfg.channels == CHANNEL_STEREO));
- CHECK_ARG(pConfig->outputCfg.channels == CHANNEL_STEREO);
+ CHECK_ARG((pContext->auxiliary && pConfig->inputCfg.channels == AUDIO_CHANNEL_OUT_MONO) ||
+ ((!pContext->auxiliary) && pConfig->inputCfg.channels == AUDIO_CHANNEL_OUT_STEREO));
+ CHECK_ARG(pConfig->outputCfg.channels == AUDIO_CHANNEL_OUT_STEREO);
CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE
|| pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE);
- CHECK_ARG(pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S15);
+ CHECK_ARG(pConfig->inputCfg.format == AUDIO_FORMAT_PCM_16_BIT);
if(pConfig->inputCfg.samplingRate != 44100){
return -EINVAL;
@@ -700,20 +723,20 @@ int Reverb_init(ReverbContext *pContext){
pContext->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
if (pContext->auxiliary) {
- pContext->config.inputCfg.channels = CHANNEL_MONO;
+ pContext->config.inputCfg.channels = AUDIO_CHANNEL_OUT_MONO;
} else {
- pContext->config.inputCfg.channels = CHANNEL_STEREO;
+ pContext->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
}
- pContext->config.inputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pContext->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pContext->config.inputCfg.samplingRate = 44100;
pContext->config.inputCfg.bufferProvider.getBuffer = NULL;
pContext->config.inputCfg.bufferProvider.releaseBuffer = NULL;
pContext->config.inputCfg.bufferProvider.cookie = NULL;
pContext->config.inputCfg.mask = EFFECT_CONFIG_ALL;
pContext->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE;
- pContext->config.outputCfg.channels = CHANNEL_STEREO;
- pContext->config.outputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pContext->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
+ pContext->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pContext->config.outputCfg.samplingRate = 44100;
pContext->config.outputCfg.bufferProvider.getBuffer = NULL;
pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL;
@@ -800,7 +823,7 @@ int Reverb_init(ReverbContext *pContext){
params.OperatingMode = LVM_MODE_ON;
params.SampleRate = LVM_FS_44100;
- if(pContext->config.inputCfg.channels == CHANNEL_MONO){
+ if(pContext->config.inputCfg.channels == AUDIO_CHANNEL_OUT_MONO){
params.SourceFormat = LVM_MONO;
} else {
params.SourceFormat = LVM_STEREO;
@@ -1832,8 +1855,9 @@ int Reverb_setParameter (ReverbContext *pContext, void *pParam, void *pValue){
} // namespace
} // namespace
+extern "C" {
/* Effect Control Interface Implementation: Process */
-extern "C" int Reverb_process(effect_interface_t self,
+int Reverb_process(effect_handle_t self,
audio_buffer_t *inBuffer,
audio_buffer_t *outBuffer){
android::ReverbContext * pContext = (android::ReverbContext *) self;
@@ -1868,7 +1892,7 @@ extern "C" int Reverb_process(effect_interface_t self,
} /* end Reverb_process */
/* Effect Control Interface Implementation: Command */
-extern "C" int Reverb_command(effect_interface_t self,
+int Reverb_command(effect_handle_t self,
uint32_t cmdCode,
uint32_t cmdSize,
void *pCmdData,
@@ -2075,9 +2099,54 @@ extern "C" int Reverb_command(effect_interface_t self,
return 0;
} /* end Reverb_command */
-// effect_interface_t interface implementation for Reverb effect
+/* Effect Control Interface Implementation: get_descriptor */
+int Reverb_getDescriptor(effect_handle_t self,
+ effect_descriptor_t *pDescriptor)
+{
+ android::ReverbContext * pContext = (android::ReverbContext *)self;
+ const effect_descriptor_t *desc;
+
+ if (pContext == NULL || pDescriptor == NULL) {
+ LOGV("Reverb_getDescriptor() invalid param");
+ return -EINVAL;
+ }
+
+ if (pContext->auxiliary) {
+ if (pContext->preset) {
+ desc = &android::gAuxPresetReverbDescriptor;
+ } else {
+ desc = &android::gAuxEnvReverbDescriptor;
+ }
+ } else {
+ if (pContext->preset) {
+ desc = &android::gInsertPresetReverbDescriptor;
+ } else {
+ desc = &android::gInsertEnvReverbDescriptor;
+ }
+ }
+
+ memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+
+ return 0;
+} /* end Reverb_getDescriptor */
+
+// effect_handle_t interface implementation for Reverb effect
const struct effect_interface_s gReverbInterface = {
Reverb_process,
- Reverb_command
+ Reverb_command,
+ Reverb_getDescriptor
}; /* end gReverbInterface */
+audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
+ tag : AUDIO_EFFECT_LIBRARY_TAG,
+ version : EFFECT_LIBRARY_API_VERSION,
+ name : "Reverb Library",
+ implementor : "NXP Software Ltd.",
+ query_num_effects : android::EffectQueryNumberEffects,
+ query_effect : android::EffectQueryEffect,
+ create_effect : android::EffectCreate,
+ release_effect : android::EffectRelease,
+ get_descriptor : android::EffectGetDescriptor,
+};
+
+}
diff --git a/media/libeffects/testlibs/Android.mk_ b/media/libeffects/testlibs/Android.mk_
index 9ba71ed..98d477b 100644
--- a/media/libeffects/testlibs/Android.mk_
+++ b/media/libeffects/testlibs/Android.mk_
@@ -25,7 +25,7 @@ endif
LOCAL_C_INCLUDES := \
$(call include-path-for, graphics corecg)
-LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
@@ -60,7 +60,7 @@ endif
LOCAL_C_INCLUDES := \
$(call include-path-for, graphics corecg)
-LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libeffects/testlibs/AudioFormatAdapter.h b/media/libeffects/testlibs/AudioFormatAdapter.h
index d93ebe9..41f1810 100644
--- a/media/libeffects/testlibs/AudioFormatAdapter.h
+++ b/media/libeffects/testlibs/AudioFormatAdapter.h
@@ -18,7 +18,7 @@
#ifndef AUDIOFORMATADAPTER_H_
#define AUDIOFORMATADAPTER_H_
-#include <media/EffectApi.h>
+#include <hardware/audio_effect.h>
#define min(x,y) (((x) < (y)) ? (x) : (y))
@@ -75,7 +75,7 @@ public:
while (numSamples > 0) {
uint32_t numSamplesIter = min(numSamples, mMaxSamplesPerCall);
uint32_t nSamplesChannels = numSamplesIter * mNumChannels;
- if (mPcmFormat == SAMPLE_FORMAT_PCM_S7_24) {
+ if (mPcmFormat == AUDIO_FORMAT_PCM_8_24_BIT) {
if (mBehavior == EFFECT_BUFFER_ACCESS_WRITE) {
mpProcessor->process(
reinterpret_cast<const audio_sample_t *> (pIn),
@@ -125,7 +125,7 @@ private:
// sample.
// numSamples The number of single-channel samples to process.
void ConvertInput(const void *& pIn, uint32_t numSamples) {
- if (mPcmFormat == SAMPLE_FORMAT_PCM_S15) {
+ if (mPcmFormat == AUDIO_FORMAT_PCM_16_BIT) {
const int16_t * pIn16 = reinterpret_cast<const int16_t *>(pIn);
audio_sample_t * pOut = mBuffer;
while (numSamples-- > 0) {
@@ -143,7 +143,7 @@ private:
// When function exist will point to the next output sample.
// numSamples The number of single-channel samples to process.
void ConvertOutput(void *& pOut, uint32_t numSamples) {
- if (mPcmFormat == SAMPLE_FORMAT_PCM_S15) {
+ if (mPcmFormat == AUDIO_FORMAT_PCM_16_BIT) {
const audio_sample_t * pIn = mBuffer;
int16_t * pOut16 = reinterpret_cast<int16_t *>(pOut);
if (mBehavior == EFFECT_BUFFER_ACCESS_WRITE) {
diff --git a/media/libeffects/testlibs/EffectEqualizer.cpp b/media/libeffects/testlibs/EffectEqualizer.cpp
index f8e4357..43dfa82 100644
--- a/media/libeffects/testlibs/EffectEqualizer.cpp
+++ b/media/libeffects/testlibs/EffectEqualizer.cpp
@@ -28,7 +28,7 @@
#include "AudioFormatAdapter.h"
#include <media/EffectEqualizerApi.h>
-// effect_interface_t interface implementation for equalizer effect
+// effect_handle_t interface implementation for equalizer effect
extern "C" const struct effect_interface_s gEqualizerInterface;
enum equalizer_state_e {
@@ -44,12 +44,12 @@ namespace {
const effect_descriptor_t gEqualizerDescriptor = {
{0x0bed4300, 0xddd6, 0x11db, 0x8f34, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // type
{0xe25aa840, 0x543b, 0x11df, 0x98a5, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
(EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST),
0, // TODO
1,
"Graphic Equalizer",
- "Google Inc.",
+ "The Android Open Source Project",
};
/////////////////// BEGIN EQ PRESETS ///////////////////////////////////////////
@@ -127,7 +127,8 @@ extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects) {
return 0;
} /* end EffectQueryNumberEffects */
-extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor) {
+extern "C" int EffectQueryEffect(uint32_t index,
+ effect_descriptor_t *pDescriptor) {
if (pDescriptor == NULL) {
return -EINVAL;
}
@@ -139,15 +140,15 @@ extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescripto
} /* end EffectQueryNext */
extern "C" int EffectCreate(effect_uuid_t *uuid,
- int32_t sessionId,
- int32_t ioId,
- effect_interface_t *pInterface) {
+ int32_t sessionId,
+ int32_t ioId,
+ effect_handle_t *pHandle) {
int ret;
int i;
LOGV("EffectLibCreateEffect start");
- if (pInterface == NULL || uuid == NULL) {
+ if (pHandle == NULL || uuid == NULL) {
return -EINVAL;
}
@@ -168,19 +169,20 @@ extern "C" int EffectCreate(effect_uuid_t *uuid,
return ret;
}
- *pInterface = (effect_interface_t)pContext;
+ *pHandle = (effect_handle_t)pContext;
pContext->state = EQUALIZER_STATE_INITIALIZED;
- LOGV("EffectLibCreateEffect %p, size %d", pContext, AudioEqualizer::GetInstanceSize(kNumBands)+sizeof(EqualizerContext));
+ LOGV("EffectLibCreateEffect %p, size %d",
+ pContext, AudioEqualizer::GetInstanceSize(kNumBands)+sizeof(EqualizerContext));
return 0;
} /* end EffectCreate */
-extern "C" int EffectRelease(effect_interface_t interface) {
- EqualizerContext * pContext = (EqualizerContext *)interface;
+extern "C" int EffectRelease(effect_handle_t handle) {
+ EqualizerContext * pContext = (EqualizerContext *)handle;
- LOGV("EffectLibReleaseEffect %p", interface);
+ LOGV("EffectLibReleaseEffect %p", handle);
if (pContext == NULL) {
return -EINVAL;
}
@@ -192,6 +194,22 @@ extern "C" int EffectRelease(effect_interface_t interface) {
return 0;
} /* end EffectRelease */
+extern "C" int EffectGetDescriptor(effect_uuid_t *uuid,
+ effect_descriptor_t *pDescriptor) {
+
+ if (pDescriptor == NULL || uuid == NULL){
+ LOGV("EffectGetDescriptor() called with NULL pointer");
+ return -EINVAL;
+ }
+
+ if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) {
+ memcpy(pDescriptor, &gEqualizerDescriptor, sizeof(effect_descriptor_t));
+ return 0;
+ }
+
+ return -EINVAL;
+} /* end EffectGetDescriptor */
+
//
//--- local functions
@@ -228,14 +246,15 @@ int Equalizer_configure(EqualizerContext *pContext, effect_config_t *pConfig)
CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate);
CHECK_ARG(pConfig->inputCfg.channels == pConfig->outputCfg.channels);
CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format);
- CHECK_ARG((pConfig->inputCfg.channels == CHANNEL_MONO) || (pConfig->inputCfg.channels == CHANNEL_STEREO));
+ CHECK_ARG((pConfig->inputCfg.channels == AUDIO_CHANNEL_OUT_MONO) ||
+ (pConfig->inputCfg.channels == AUDIO_CHANNEL_OUT_STEREO));
CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE
|| pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE);
- CHECK_ARG(pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S7_24
- || pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S15);
+ CHECK_ARG(pConfig->inputCfg.format == AUDIO_FORMAT_PCM_8_24_BIT
+ || pConfig->inputCfg.format == AUDIO_FORMAT_PCM_16_BIT);
int channelCount;
- if (pConfig->inputCfg.channels == CHANNEL_MONO) {
+ if (pConfig->inputCfg.channels == AUDIO_CHANNEL_OUT_MONO) {
channelCount = 1;
} else {
channelCount = 2;
@@ -281,16 +300,16 @@ int Equalizer_init(EqualizerContext *pContext)
}
pContext->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
- pContext->config.inputCfg.channels = CHANNEL_STEREO;
- pContext->config.inputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pContext->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
+ pContext->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pContext->config.inputCfg.samplingRate = 44100;
pContext->config.inputCfg.bufferProvider.getBuffer = NULL;
pContext->config.inputCfg.bufferProvider.releaseBuffer = NULL;
pContext->config.inputCfg.bufferProvider.cookie = NULL;
pContext->config.inputCfg.mask = EFFECT_CONFIG_ALL;
pContext->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE;
- pContext->config.outputCfg.channels = CHANNEL_STEREO;
- pContext->config.outputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pContext->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
+ pContext->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pContext->config.outputCfg.samplingRate = 44100;
pContext->config.outputCfg.bufferProvider.getBuffer = NULL;
pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL;
@@ -402,7 +421,8 @@ int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t
case EQ_PARAM_LEVEL_RANGE:
*(int16_t *)pValue = -9600;
*((int16_t *)pValue + 1) = 4800;
- LOGV("Equalizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d", *(int32_t *)pValue, *((int32_t *)pValue + 1));
+ LOGV("Equalizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d",
+ *(int32_t *)pValue, *((int32_t *)pValue + 1));
break;
case EQ_PARAM_BAND_LEVEL:
@@ -412,7 +432,8 @@ int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t
break;
}
*(int16_t *)pValue = (int16_t)pEqualizer->getGain(param2);
- LOGV("Equalizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", param2, *(int32_t *)pValue);
+ LOGV("Equalizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d",
+ param2, *(int32_t *)pValue);
break;
case EQ_PARAM_CENTER_FREQ:
@@ -422,7 +443,8 @@ int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t
break;
}
*(int32_t *)pValue = pEqualizer->getFrequency(param2);
- LOGV("Equalizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d", param2, *(int32_t *)pValue);
+ LOGV("Equalizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d",
+ param2, *(int32_t *)pValue);
break;
case EQ_PARAM_BAND_FREQ_RANGE:
@@ -432,13 +454,15 @@ int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t
break;
}
pEqualizer->getBandRange(param2, *(uint32_t *)pValue, *((uint32_t *)pValue + 1));
- LOGV("Equalizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d", param2, *(int32_t *)pValue, *((int32_t *)pValue + 1));
+ LOGV("Equalizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d",
+ param2, *(int32_t *)pValue, *((int32_t *)pValue + 1));
break;
case EQ_PARAM_GET_BAND:
param2 = *pParam;
*(uint16_t *)pValue = (uint16_t)pEqualizer->getMostRelevantBand(param2);
- LOGV("Equalizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d", param2, *(int32_t *)pValue);
+ LOGV("Equalizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d",
+ param2, *(int32_t *)pValue);
break;
case EQ_PARAM_CUR_PRESET:
@@ -461,7 +485,8 @@ int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t
strncpy(name, pEqualizer->getPresetName(param2), *pValueSize - 1);
name[*pValueSize - 1] = 0;
*pValueSize = strlen(name) + 1;
- LOGV("Equalizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d", param2, gEqualizerPresets[param2].name, *pValueSize);
+ LOGV("Equalizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d",
+ param2, gEqualizerPresets[param2].name, *pValueSize);
break;
case EQ_PARAM_PROPERTIES: {
@@ -571,7 +596,7 @@ int Equalizer_setParameter (AudioEqualizer * pEqualizer, int32_t *pParam, void *
//--- Effect Control Interface Implementation
//
-extern "C" int Equalizer_process(effect_interface_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer)
+extern "C" int Equalizer_process(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer)
{
android::EqualizerContext * pContext = (android::EqualizerContext *) self;
@@ -596,7 +621,7 @@ extern "C" int Equalizer_process(effect_interface_t self, audio_buffer_t *inBuff
return 0;
} // end Equalizer_process
-extern "C" int Equalizer_command(effect_interface_t self, uint32_t cmdCode, uint32_t cmdSize,
+extern "C" int Equalizer_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize,
void *pCmdData, uint32_t *replySize, void *pReplyData) {
android::EqualizerContext * pContext = (android::EqualizerContext *) self;
@@ -647,7 +672,8 @@ extern "C" int Equalizer_command(effect_interface_t self, uint32_t cmdCode, uint
} break;
case EFFECT_CMD_SET_PARAM: {
- LOGV("Equalizer_command EFFECT_CMD_SET_PARAM cmdSize %d pCmdData %p, *replySize %d, pReplyData %p", cmdSize, pCmdData, *replySize, pReplyData);
+ LOGV("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)) ||
pReplyData == NULL || *replySize != sizeof(int32_t)) {
return -EINVAL;
@@ -690,10 +716,37 @@ extern "C" int Equalizer_command(effect_interface_t self, uint32_t cmdCode, uint
return 0;
}
-// effect_interface_t interface implementation for equalizer effect
+extern "C" int Equalizer_getDescriptor(effect_handle_t self,
+ effect_descriptor_t *pDescriptor)
+{
+ android::EqualizerContext * pContext = (android::EqualizerContext *) self;
+
+ if (pContext == NULL || pDescriptor == NULL) {
+ LOGV("Equalizer_getDescriptor() invalid param");
+ return -EINVAL;
+ }
+
+ memcpy(pDescriptor, &android::gEqualizerDescriptor, sizeof(effect_descriptor_t));
+
+ return 0;
+}
+
+// effect_handle_t interface implementation for equalizer effect
const struct effect_interface_s gEqualizerInterface = {
Equalizer_process,
- Equalizer_command
+ Equalizer_command,
+ Equalizer_getDescriptor
};
+audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
+ tag : AUDIO_EFFECT_LIBRARY_TAG,
+ version : EFFECT_LIBRARY_API_VERSION,
+ name : "Test Equalizer Library",
+ implementor : "The Android Open Source Project",
+ query_num_effects : android::EffectQueryNumberEffects,
+ query_effect : android::EffectQueryEffect,
+ create_effect : android::EffectCreate,
+ release_effect : android::EffectRelease,
+ get_descriptor : android::EffectGetDescriptor,
+};
diff --git a/media/libeffects/testlibs/EffectReverb.c b/media/libeffects/testlibs/EffectReverb.c
index 3eb8b2c..02762c9 100644
--- a/media/libeffects/testlibs/EffectReverb.c
+++ b/media/libeffects/testlibs/EffectReverb.c
@@ -23,59 +23,60 @@
#include "EffectReverb.h"
#include "EffectsMath.h"
-// effect_interface_t interface implementation for reverb effect
+// effect_handle_t interface implementation for reverb effect
const struct effect_interface_s gReverbInterface = {
Reverb_Process,
- Reverb_Command
+ Reverb_Command,
+ Reverb_GetDescriptor
};
// Google auxiliary environmental reverb UUID: 1f0ae2e0-4ef7-11df-bc09-0002a5d5c51b
static const effect_descriptor_t gAuxEnvReverbDescriptor = {
{0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, {0x4e, 0x23, 0x4d, 0x06, 0x83, 0x9e}},
{0x1f0ae2e0, 0x4ef7, 0x11df, 0xbc09, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
// flags other than EFFECT_FLAG_TYPE_AUXILIARY set for test purpose
EFFECT_FLAG_TYPE_AUXILIARY | EFFECT_FLAG_DEVICE_IND | EFFECT_FLAG_AUDIO_MODE_IND,
0, // TODO
33,
"Aux Environmental Reverb",
- "Google Inc."
+ "The Android Open Source Project"
};
// Google insert environmental reverb UUID: aa476040-6342-11df-91a4-0002a5d5c51b
static const effect_descriptor_t gInsertEnvReverbDescriptor = {
{0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, {0x4e, 0x23, 0x4d, 0x06, 0x83, 0x9e}},
{0xaa476040, 0x6342, 0x11df, 0x91a4, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_FIRST,
0, // TODO
33,
"Insert Environmental reverb",
- "Google Inc."
+ "The Android Open Source Project"
};
// Google auxiliary preset reverb UUID: 63909320-53a6-11df-bdbd-0002a5d5c51b
static const effect_descriptor_t gAuxPresetReverbDescriptor = {
{0x47382d60, 0xddd8, 0x11db, 0xbf3a, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
{0x63909320, 0x53a6, 0x11df, 0xbdbd, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
EFFECT_FLAG_TYPE_AUXILIARY,
0, // TODO
33,
"Aux Preset Reverb",
- "Google Inc."
+ "The Android Open Source Project"
};
// Google insert preset reverb UUID: d93dc6a0-6342-11df-b128-0002a5d5c51b
static const effect_descriptor_t gInsertPresetReverbDescriptor = {
{0x47382d60, 0xddd8, 0x11db, 0xbf3a, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
{0xd93dc6a0, 0x6342, 0x11df, 0xb128, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_FIRST,
0, // TODO
33,
"Insert Preset Reverb",
- "Google Inc."
+ "The Android Open Source Project"
};
// gDescriptors contains pointers to all defined effect descriptor in this library
@@ -112,7 +113,7 @@ int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor) {
int EffectCreate(effect_uuid_t *uuid,
int32_t sessionId,
int32_t ioId,
- effect_interface_t *pInterface) {
+ effect_handle_t *pHandle) {
int ret;
int i;
reverb_module_t *module;
@@ -122,7 +123,7 @@ int EffectCreate(effect_uuid_t *uuid,
LOGV("EffectLibCreateEffect start");
- if (pInterface == NULL || uuid == NULL) {
+ if (pHandle == NULL || uuid == NULL) {
return -EINVAL;
}
@@ -157,7 +158,7 @@ int EffectCreate(effect_uuid_t *uuid,
return ret;
}
- *pInterface = (effect_interface_t) module;
+ *pHandle = (effect_handle_t) module;
module->context.mState = REVERB_STATE_INITIALIZED;
@@ -166,11 +167,11 @@ int EffectCreate(effect_uuid_t *uuid,
return 0;
}
-int EffectRelease(effect_interface_t interface) {
- reverb_module_t *pRvbModule = (reverb_module_t *)interface;
+int EffectRelease(effect_handle_t handle) {
+ reverb_module_t *pRvbModule = (reverb_module_t *)handle;
- LOGV("EffectLibReleaseEffect %p", interface);
- if (interface == NULL) {
+ LOGV("EffectLibReleaseEffect %p", handle);
+ if (handle == NULL) {
return -EINVAL;
}
@@ -180,10 +181,31 @@ int EffectRelease(effect_interface_t interface) {
return 0;
}
+int EffectGetDescriptor(effect_uuid_t *uuid,
+ effect_descriptor_t *pDescriptor) {
+ int i;
+ int length = sizeof(gDescriptors) / sizeof(const effect_descriptor_t *);
+
+ if (pDescriptor == NULL || uuid == NULL){
+ LOGV("EffectGetDescriptor() called with NULL pointer");
+ return -EINVAL;
+ }
+
+ for (i = 0; i < length; i++) {
+ if (memcmp(uuid, &gDescriptors[i]->uuid, sizeof(effect_uuid_t)) == 0) {
+ memcpy(pDescriptor, gDescriptors[i], sizeof(effect_descriptor_t));
+ LOGV("EffectGetDescriptor - UUID matched Reverb type %d, UUID = %x",
+ i, gDescriptors[i]->uuid.timeLow);
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+} /* end EffectGetDescriptor */
/*--- Effect Control Interface Implementation ---*/
-static int Reverb_Process(effect_interface_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer) {
+static int Reverb_Process(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer) {
reverb_object_t *pReverb;
int16_t *pSrc, *pDst;
reverb_module_t *pRvbModule = (reverb_module_t *)self;
@@ -270,7 +292,7 @@ static int Reverb_Process(effect_interface_t self, audio_buffer_t *inBuffer, aud
}
-static int Reverb_Command(effect_interface_t self, uint32_t cmdCode, uint32_t cmdSize,
+static int Reverb_Command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize,
void *pCmdData, uint32_t *replySize, void *pReplyData) {
reverb_module_t *pRvbModule = (reverb_module_t *) self;
reverb_object_t *pReverb;
@@ -383,6 +405,38 @@ static int Reverb_Command(effect_interface_t self, uint32_t cmdCode, uint32_t cm
return 0;
}
+int Reverb_GetDescriptor(effect_handle_t self,
+ effect_descriptor_t *pDescriptor)
+{
+ reverb_module_t *pRvbModule = (reverb_module_t *) self;
+ reverb_object_t *pReverb;
+ const effect_descriptor_t *desc;
+
+ if (pRvbModule == NULL ||
+ pRvbModule->context.mState == REVERB_STATE_UNINITIALIZED) {
+ return -EINVAL;
+ }
+
+ pReverb = (reverb_object_t*) &pRvbModule->context;
+
+ if (pReverb->m_Aux) {
+ if (pReverb->m_Preset) {
+ desc = &gAuxPresetReverbDescriptor;
+ } else {
+ desc = &gAuxEnvReverbDescriptor;
+ }
+ } else {
+ if (pReverb->m_Preset) {
+ desc = &gInsertPresetReverbDescriptor;
+ } else {
+ desc = &gInsertEnvReverbDescriptor;
+ }
+ }
+
+ memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+
+ return 0;
+} /* end Reverb_getDescriptor */
/*----------------------------------------------------------------------------
* Reverb internal functions
@@ -418,19 +472,19 @@ int Reverb_Init(reverb_module_t *pRvbModule, int aux, int preset) {
pRvbModule->config.inputCfg.samplingRate = 44100;
if (aux) {
- pRvbModule->config.inputCfg.channels = CHANNEL_MONO;
+ pRvbModule->config.inputCfg.channels = AUDIO_CHANNEL_OUT_MONO;
} else {
- pRvbModule->config.inputCfg.channels = CHANNEL_STEREO;
+ pRvbModule->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
}
- pRvbModule->config.inputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pRvbModule->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pRvbModule->config.inputCfg.bufferProvider.getBuffer = NULL;
pRvbModule->config.inputCfg.bufferProvider.releaseBuffer = NULL;
pRvbModule->config.inputCfg.bufferProvider.cookie = NULL;
pRvbModule->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
pRvbModule->config.inputCfg.mask = EFFECT_CONFIG_ALL;
pRvbModule->config.outputCfg.samplingRate = 44100;
- pRvbModule->config.outputCfg.channels = CHANNEL_STEREO;
- pRvbModule->config.outputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pRvbModule->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
+ pRvbModule->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pRvbModule->config.outputCfg.bufferProvider.getBuffer = NULL;
pRvbModule->config.outputCfg.bufferProvider.releaseBuffer = NULL;
pRvbModule->config.outputCfg.bufferProvider.cookie = NULL;
@@ -474,13 +528,13 @@ int Reverb_Configure(reverb_module_t *pRvbModule, effect_config_t *pConfig,
if (pConfig->inputCfg.samplingRate
!= pConfig->outputCfg.samplingRate
|| pConfig->outputCfg.channels != OUTPUT_CHANNELS
- || pConfig->inputCfg.format != SAMPLE_FORMAT_PCM_S15
- || pConfig->outputCfg.format != SAMPLE_FORMAT_PCM_S15) {
+ || pConfig->inputCfg.format != AUDIO_FORMAT_PCM_16_BIT
+ || pConfig->outputCfg.format != AUDIO_FORMAT_PCM_16_BIT) {
LOGV("Reverb_Configure invalid config");
return -EINVAL;
}
- if ((pReverb->m_Aux && (pConfig->inputCfg.channels != CHANNEL_MONO)) ||
- (!pReverb->m_Aux && (pConfig->inputCfg.channels != CHANNEL_STEREO))) {
+ if ((pReverb->m_Aux && (pConfig->inputCfg.channels != AUDIO_CHANNEL_OUT_MONO)) ||
+ (!pReverb->m_Aux && (pConfig->inputCfg.channels != AUDIO_CHANNEL_OUT_STEREO))) {
LOGV("Reverb_Configure invalid config");
return -EINVAL;
}
@@ -2133,3 +2187,15 @@ static int ReverbReadInPresets(reverb_object_t *pReverb) {
return 0;
}
+
+audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
+ .tag = AUDIO_EFFECT_LIBRARY_TAG,
+ .version = EFFECT_LIBRARY_API_VERSION,
+ .name = "Test Equalizer Library",
+ .implementor = "The Android Open Source Project",
+ .query_num_effects = EffectQueryNumberEffects,
+ .query_effect = EffectQueryEffect,
+ .create_effect = EffectCreate,
+ .release_effect = EffectRelease,
+ .get_descriptor = EffectGetDescriptor,
+};
diff --git a/media/libeffects/testlibs/EffectReverb.h b/media/libeffects/testlibs/EffectReverb.h
index dbcd192..a239814 100644
--- a/media/libeffects/testlibs/EffectReverb.h
+++ b/media/libeffects/testlibs/EffectReverb.h
@@ -40,7 +40,7 @@ if the buffer size is a power of two.
)
#define NUM_OUTPUT_CHANNELS 2
-#define OUTPUT_CHANNELS CHANNEL_STEREO
+#define OUTPUT_CHANNELS AUDIO_CHANNEL_OUT_STEREO
#define REVERB_BUFFER_SIZE_IN_SAMPLES_MAX 16384
@@ -306,19 +306,22 @@ int EffectQueryEffect(uint32_t index,
int EffectCreate(effect_uuid_t *effectUID,
int32_t sessionId,
int32_t ioId,
- effect_interface_t *pInterface);
-int EffectRelease(effect_interface_t interface);
+ effect_handle_t *pHandle);
+int EffectRelease(effect_handle_t handle);
+int EffectGetDescriptor(effect_uuid_t *uuid,
+ effect_descriptor_t *pDescriptor);
-static int Reverb_Process(effect_interface_t self,
+static int Reverb_Process(effect_handle_t self,
audio_buffer_t *inBuffer,
audio_buffer_t *outBuffer);
-static int Reverb_Command(effect_interface_t self,
+static int Reverb_Command(effect_handle_t self,
uint32_t cmdCode,
uint32_t cmdSize,
void *pCmdData,
uint32_t *replySize,
void *pReplyData);
-
+static int Reverb_GetDescriptor(effect_handle_t self,
+ effect_descriptor_t *pDescriptor);
/*------------------------------------
* internal functions
diff --git a/media/libeffects/visualizer/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp
index c957dba..80d1f69 100644
--- a/media/libeffects/visualizer/EffectVisualizer.cpp
+++ b/media/libeffects/visualizer/EffectVisualizer.cpp
@@ -23,21 +23,22 @@
#include <new>
#include <media/EffectVisualizerApi.h>
-namespace android {
-// effect_interface_t interface implementation for visualizer effect
-extern "C" const struct effect_interface_s gVisualizerInterface;
+extern "C" {
+
+// effect_handle_t interface implementation for visualizer effect
+extern const struct effect_interface_s gVisualizerInterface;
// Google Visualizer UUID: d069d9e0-8329-11df-9168-0002a5d5c51b
const effect_descriptor_t gVisualizerDescriptor = {
{0xe46b26a0, 0xdddd, 0x11db, 0x8afd, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // type
{0xd069d9e0, 0x8329, 0x11df, 0x9168, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
(EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_FIRST),
0, // TODO
1,
"Visualizer",
- "Google Inc.",
+ "The Android Open Source Project",
};
enum visualizer_state_e {
@@ -90,10 +91,10 @@ int Visualizer_configure(VisualizerContext *pContext, effect_config_t *pConfig)
if (pConfig->inputCfg.samplingRate != pConfig->outputCfg.samplingRate) return -EINVAL;
if (pConfig->inputCfg.channels != pConfig->outputCfg.channels) return -EINVAL;
if (pConfig->inputCfg.format != pConfig->outputCfg.format) return -EINVAL;
- if (pConfig->inputCfg.channels != CHANNEL_STEREO) return -EINVAL;
+ if (pConfig->inputCfg.channels != AUDIO_CHANNEL_OUT_STEREO) return -EINVAL;
if (pConfig->outputCfg.accessMode != EFFECT_BUFFER_ACCESS_WRITE &&
pConfig->outputCfg.accessMode != EFFECT_BUFFER_ACCESS_ACCUMULATE) return -EINVAL;
- if (pConfig->inputCfg.format != SAMPLE_FORMAT_PCM_S15) return -EINVAL;
+ if (pConfig->inputCfg.format != AUDIO_FORMAT_PCM_16_BIT) return -EINVAL;
memcpy(&pContext->mConfig, pConfig, sizeof(effect_config_t));
@@ -118,16 +119,16 @@ int Visualizer_configure(VisualizerContext *pContext, effect_config_t *pConfig)
int Visualizer_init(VisualizerContext *pContext)
{
pContext->mConfig.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
- pContext->mConfig.inputCfg.channels = CHANNEL_STEREO;
- pContext->mConfig.inputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pContext->mConfig.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
+ pContext->mConfig.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pContext->mConfig.inputCfg.samplingRate = 44100;
pContext->mConfig.inputCfg.bufferProvider.getBuffer = NULL;
pContext->mConfig.inputCfg.bufferProvider.releaseBuffer = NULL;
pContext->mConfig.inputCfg.bufferProvider.cookie = NULL;
pContext->mConfig.inputCfg.mask = EFFECT_CONFIG_ALL;
pContext->mConfig.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE;
- pContext->mConfig.outputCfg.channels = CHANNEL_STEREO;
- pContext->mConfig.outputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pContext->mConfig.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
+ pContext->mConfig.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pContext->mConfig.outputCfg.samplingRate = 44100;
pContext->mConfig.outputCfg.bufferProvider.getBuffer = NULL;
pContext->mConfig.outputCfg.bufferProvider.releaseBuffer = NULL;
@@ -145,12 +146,13 @@ int Visualizer_init(VisualizerContext *pContext)
//--- Effect Library Interface Implementation
//
-extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects) {
+int VisualizerLib_QueryNumberEffects(uint32_t *pNumEffects) {
*pNumEffects = 1;
return 0;
}
-extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor) {
+int VisualizerLib_QueryEffect(uint32_t index,
+ effect_descriptor_t *pDescriptor) {
if (pDescriptor == NULL) {
return -EINVAL;
}
@@ -161,14 +163,14 @@ extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescripto
return 0;
}
-extern "C" int EffectCreate(effect_uuid_t *uuid,
- int32_t sessionId,
- int32_t ioId,
- effect_interface_t *pInterface) {
+int VisualizerLib_Create(effect_uuid_t *uuid,
+ int32_t sessionId,
+ int32_t ioId,
+ effect_handle_t *pHandle) {
int ret;
int i;
- if (pInterface == NULL || uuid == NULL) {
+ if (pHandle == NULL || uuid == NULL) {
return -EINVAL;
}
@@ -183,25 +185,25 @@ extern "C" int EffectCreate(effect_uuid_t *uuid,
ret = Visualizer_init(pContext);
if (ret < 0) {
- LOGW("EffectCreate() init failed");
+ LOGW("VisualizerLib_Create() init failed");
delete pContext;
return ret;
}
- *pInterface = (effect_interface_t)pContext;
+ *pHandle = (effect_handle_t)pContext;
pContext->mState = VISUALIZER_STATE_INITIALIZED;
- LOGV("EffectCreate %p", pContext);
+ LOGV("VisualizerLib_Create %p", pContext);
return 0;
}
-extern "C" int EffectRelease(effect_interface_t interface) {
- VisualizerContext * pContext = (VisualizerContext *)interface;
+int VisualizerLib_Release(effect_handle_t handle) {
+ VisualizerContext * pContext = (VisualizerContext *)handle;
- LOGV("EffectRelease %p", interface);
+ LOGV("VisualizerLib_Release %p", handle);
if (pContext == NULL) {
return -EINVAL;
}
@@ -211,6 +213,22 @@ extern "C" int EffectRelease(effect_interface_t interface) {
return 0;
}
+int VisualizerLib_GetDescriptor(effect_uuid_t *uuid,
+ effect_descriptor_t *pDescriptor) {
+
+ if (pDescriptor == NULL || uuid == NULL){
+ LOGV("VisualizerLib_GetDescriptor() called with NULL pointer");
+ return -EINVAL;
+ }
+
+ if (memcmp(uuid, &gVisualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) {
+ memcpy(pDescriptor, &gVisualizerDescriptor, sizeof(effect_descriptor_t));
+ return 0;
+ }
+
+ return -EINVAL;
+} /* end VisualizerLib_GetDescriptor */
+
//
//--- Effect Control Interface Implementation
//
@@ -222,10 +240,10 @@ static inline int16_t clamp16(int32_t sample)
return sample;
}
-extern "C" int Visualizer_process(
- effect_interface_t self,audio_buffer_t *inBuffer, audio_buffer_t *outBuffer)
+int Visualizer_process(
+ effect_handle_t self,audio_buffer_t *inBuffer, audio_buffer_t *outBuffer)
{
- android::VisualizerContext * pContext = (android::VisualizerContext *)self;
+ VisualizerContext * pContext = (VisualizerContext *)self;
if (pContext == NULL) {
return -EINVAL;
@@ -244,7 +262,7 @@ extern "C" int Visualizer_process(
// this gives more interesting captures for display.
int32_t shift = 32;
int len = inBuffer->frameCount * 2;
- for (size_t i = 0; i < len; i++) {
+ for (int i = 0; i < len; i++) {
int32_t smp = inBuffer->s16[i];
if (smp < 0) smp = -smp - 1; // take care to keep the max negative in range
int32_t clz = __builtin_clz(smp);
@@ -293,10 +311,10 @@ extern "C" int Visualizer_process(
return 0;
} // end Visualizer_process
-extern "C" int Visualizer_command(effect_interface_t self, uint32_t cmdCode, uint32_t cmdSize,
+int Visualizer_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize,
void *pCmdData, uint32_t *replySize, void *pReplyData) {
- android::VisualizerContext * pContext = (android::VisualizerContext *)self;
+ VisualizerContext * pContext = (VisualizerContext *)self;
int retsize;
if (pContext == NULL || pContext->mState == VISUALIZER_STATE_UNINITIALIZED) {
@@ -412,11 +430,40 @@ extern "C" int Visualizer_command(effect_interface_t self, uint32_t cmdCode, uin
return 0;
}
-// effect_interface_t interface implementation for visualizer effect
+/* Effect Control Interface Implementation: get_descriptor */
+int Visualizer_getDescriptor(effect_handle_t self,
+ effect_descriptor_t *pDescriptor)
+{
+ VisualizerContext * pContext = (VisualizerContext *) self;
+
+ if (pContext == NULL || pDescriptor == NULL) {
+ LOGV("Visualizer_getDescriptor() invalid param");
+ return -EINVAL;
+ }
+
+ memcpy(pDescriptor, &gVisualizerDescriptor, sizeof(effect_descriptor_t));
+
+ return 0;
+} /* end Visualizer_getDescriptor */
+
+// effect_handle_t interface implementation for visualizer effect
const struct effect_interface_s gVisualizerInterface = {
Visualizer_process,
- Visualizer_command
+ Visualizer_command,
+ Visualizer_getDescriptor
};
-} // namespace
+audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
+ tag : AUDIO_EFFECT_LIBRARY_TAG,
+ version : EFFECT_LIBRARY_API_VERSION,
+ name : "Visualizer Library",
+ implementor : "The Android Open Source Project",
+ query_num_effects : VisualizerLib_QueryNumberEffects,
+ query_effect : VisualizerLib_QueryEffect,
+ create_effect : VisualizerLib_Create,
+ release_effect : VisualizerLib_Release,
+ get_descriptor : VisualizerLib_GetDescriptor,
+};
+
+}; // extern "C"